void setup() { Serial.begin(9600); TCCR2A = 0; TCCR2B = 0; digitalWrite(LED, LOW); digitalWrite(IRLED, LOW); pinMode(LED, OUTPUT); pinMode(IRLED, OUTPUT); pinMode(REGIONSWITCH, INPUT); pinMode(TRIGGER, INPUT); digitalWrite(REGIONSWITCH, HIGH); //Pull-up digitalWrite(TRIGGER, HIGH); delay_ten_us(5000); // Let everything settle for a bit // determine region if (digitalRead(REGIONSWITCH)) { region = US; // US DEBUGP(putstring_nl("US")); } else { region = EU; DEBUGP(putstring_nl("EU")); } // Tell the user what region we're in - 3 is US 4 is EU quickflashLEDx(3+region); // Indicate how big our database is DEBUGP(putstring("\n\rNA Codesize: "); putnum_ud(num_NAcodes); );
void sendCode(struct IrCode code, const uint16_t* times, const uint8_t* codes) { uint16_t ontime, offtime; // Read the carrier frequency from the first byte of code structure const uint8_t freq = (code.freq == 0) ? 0 : freq_to_timerval(code.freq); // set OCR for Timer1 to output this POWER code's carrier frequency OCR0A = freq; // OCR0B = freq / 3; // 33% duty cycle // Get the number of pairs, the second byte from the code struct const uint8_t numpairs = code.numpairs; // Get the number of bits we use to index into the timer table // This is the third byte of the structure const uint8_t bitcompression = code.bitcompression; // Print out the frequency of the carrier and the PWM settings #if DEBUG DEBUGP(putstring("\n\rOCR1: "); putnum_ud(freq); );
void loadDebugLog(void){ uint16_t addr = DEBUG_LOG_ADDRESS; uint8_t i; uint16_t temp; //putstring("\nDebugLog: "); for (i=0; i<= MESSAGE_COMPLETE_AND_PROCESSED; i++) { temp = internal_eeprom_read16(addr); if (temp == 0xFFFF) //if it's blank (0xffff), make it 0 error_log[i] = 0x0000; else error_log[i] = temp; addr += 2; } putstring("\r\nDebugLog:"); putstring("\r\n INIT_RX = "); putnum_ud(error_log[INIT_RX]); putstring ("\r\n SUCCESSFUL_RX = "); putnum_ud( error_log[SUCCESSFUL_RX] ); putstring("\r\n //rx errors: "); putstring ("\r\n NO_FIRST_BIT = "); putnum_ud( error_log[NO_FIRST_BIT] ); putstring ("\r\n NO_START_OF_BIT = "); putnum_ud( error_log[NO_START_OF_BIT] ); putstring ("\r\n NO_END_OF_BIT = "); putnum_ud( error_log[ NO_END_OF_BIT] ); putstring ("\r\n NO_PARITY_BIT = "); putnum_ud( error_log[NO_PARITY_BIT] ); putstring ("\r\n NO_END_OF_MESSAGE = "); putnum_ud( error_log[NO_END_OF_MESSAGE] ); putstring ("\r\n PARITY_ERROR = "); putnum_ud( error_log[PARITY_ERROR] ); putstring ("\r\n //tx errors: "); putstring ("\r\n NO_HANDSHAKE_INIT = "); putnum_ud( error_log[NO_HANDSHAKE_INIT] ); putstring ("\r\n NO_HANDSHAKE_ON_GOODCHANNEL = "); putnum_ud( error_log[NO_HANDSHAKE_ON_GOODCHANNEL] ); putstring ("\r\n RECEIVER_DIDNT_RELEASE_CLOCK_LINE = "); putnum_ud( error_log[RECEIVER_DIDNT_RELEASE_CLOCK_LINE] ); putstring ("\r\n NO_BYTE_TX_RECEIPT = "); putnum_ud( error_log[NO_BYTE_TX_RECEIPT] ); putstring ("\r\n TX_PARITY_ERROR_TIMEOUT = "); putnum_ud( error_log[TX_PARITY_ERROR_TIMEOUT] ); putstring ("\r\n\r\n SUCCESSFUL_TX = "); putnum_ud( error_log[SUCCESSFUL_TX] ); putstring ("\r\n MESSAGE_COMPLETE_AND_PROCESSED = "); putnum_ud( error_log[MESSAGE_COMPLETE_AND_PROCESSED] ); putstring ("\r\n \r\n"); }