/** * Transmit Samsung data * * @param address * Pointer to store the address of the received data * @param command * Pointer to store the command of the received data * @return * IR_OK if data received successfully, one of several errormessages if not */uint8_t transmitSamsung(uint8_t address, uint8_t command) { OCR0A = (((F_CPU/2000)/IR_SAMS_F_MOD) -1); // set up modulation /* Send startbit */ setTimerVal(65536-IR_SAMS_ST_BIT); setIrPort(); while(!isTimerOvfl()) {} clearIrPort(); /* Send startpause */ setTimerVal(65536-IR_SAMS_ST_PAUSE); while(!isTimerOvfl()) {} /* first send address */ uint8_t byteToSend = address; for (uint8_t i = 0; i < 65; i++) { if (i==16) { /* then send address again */ //byteToSend = address; } else if (i==32) { /* then send command */ byteToSend = command; } else if (i==48) { /* then send inverted command */ byteToSend = ~command; } if ((i&1) == 1) { /* if odd, ir-pause */ if ((byteToSend>>((i>>1)&0x7))&1) { setTimerVal(65536-IR_SAMS_LOW_ONE); } else { setTimerVal(65536-IR_SAMS_LOW_ZERO); } while(!isTimerOvfl()) {} } else { /* if even, ir-bit */ setIrPort(); setTimerVal(65536-IR_SAMS_HIGH); while(!isTimerOvfl()) {} clearIrPort(); } } clearIrPort(); // set port low to be on the safe side repeateTime = IR_SAMS_REPETITION; // set up repitition time return IR_OK;}