*\r
* Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irsnd.c,v 1.7 2010/04/14 13:21:39 fm Exp $\r
+ * $Id: irsnd.c,v 1.9 2010/04/28 14:58:59 fm Exp $\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
#endif // WIN32\r
#endif // unix\r
\r
-#include "irmpconfig.h"\r
#include "irmp.h"\r
+#include "irsndconfig.h"\r
#include "irsnd.h"\r
\r
-/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
- * Change settings from 1 to 0 if you want to disable one or more encoders.\r
- * This saves program space.\r
- * 1 enable decoder\r
- * 0 disable decoder\r
- *---------------------------------------------------------------------------------------------------------------------------------------------------\r
- */\r
-#define IRSND_SUPPORT_SIRCS_PROTOCOL 1 // flag: support SIRCS uses ~150 bytes\r
-#define IRSND_SUPPORT_NEC_PROTOCOL 1 // flag: support NEC uses ~100 bytes\r
-#define IRSND_SUPPORT_SAMSUNG_PROTOCOL 1 // flag: support Samsung + Samsung32 uses ~300 bytes\r
-#define IRSND_SUPPORT_MATSUSHITA_PROTOCOL 1 // flag: support Matsushita uses ~150 bytes\r
-#define IRSND_SUPPORT_KASEIKYO_PROTOCOL 0 // flag: support Kaseikyo NOT SUPPORTED YET!\r
-#define IRSND_SUPPORT_RECS80_PROTOCOL 1 // flag: support RECS80 uses ~100 bytes\r
-#define IRSND_SUPPORT_RC5_PROTOCOL 1 // flag: support RC5 uses ~250 bytes\r
-#define IRSND_SUPPORT_DENON_PROTOCOL 1 // flag: support DENON uses ~200 bytes\r
-#define IRSND_SUPPORT_RC6_PROTOCOL 0 // flag: support RC6 NOT SUPPORTED YET!\r
-#define IRSND_SUPPORT_RECS80EXT_PROTOCOL 1 // flag: support RECS80EXT uses ~100 bytes\r
-#define IRSND_SUPPORT_NUBERT_PROTOCOL 1 // flag: support NUBERT uses ~100 bytes\r
-#define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 1 // flag: support Bang&Olufsen uses ~250 bytes\r
-\r
-\r
-/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
- * Change hardware pin here:\r
- *---------------------------------------------------------------------------------------------------------------------------------------------------\r
- */\r
-#if defined (__AVR_ATmega32__) || defined (__AVR_ATmega644P__)\r
-#define IRSND_PORT PORTD // port D\r
-#define IRSND_DDR DDRD // ddr D\r
-#define IRSND_BIT 7 // OC2A\r
-#else\r
-#define IRSND_PORT PORTB // port B\r
-#define IRSND_DDR DDRB // ddr B\r
-#define IRSND_BIT 3 // OC2A\r
-#endif // __AVR...\r
-\r
-\r
#define SIRCS_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)\r
#define SIRCS_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)\r
#define SIRCS_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)\r
TCCR2 |= (1<<COM20)|(1<<WGM21); // = 0x42: toggle OC2A on compare match, clear Timer 2 at compare match OCR2A\r
#else\r
TCCR2A |= (1<<COM2A0)|(1<<WGM21); // = 0x42: toggle OC2A on compare match, clear Timer 2 at compare match OCR2A\r
-#endif // __AVR...\r
+#endif // __AVR...\r
#endif // DEBUG\r
irsnd_is_on = TRUE;\r
}\r
TCCR2 &= ~(1<<COM20); // normal port operation, OC2A disconnected.\r
#else\r
TCCR2A &= ~(1<<COM2A0); // normal port operation, OC2A disconnected.\r
-#endif // __AVR...\r
+#endif // __AVR...\r
IRSND_PORT &= ~(1<<IRSND_BIT); // set IRSND_BIT to low\r
#endif // DEBUG\r
irsnd_is_on = FALSE;\r
OCR2 = freq;\r
#else\r
OCR2A = freq;\r
-#endif // __AVR...\r
+#endif // __AVR...\r
#endif // DEBUG\r
}\r
\r
#else\r
TCCR2A = (1<<WGM21); // CTC mode\r
TCCR2B |= (1<<CS20); // 0x01, start Timer 2, no prescaling\r
-#endif // __AVR... \r
+#endif // __AVR... \r
\r
irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency\r
#endif // DEBUG\r
{\r
command = bitsrevervse (irmp_data_p->command, SIRCS_MINIMUM_DATA_LEN);\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC\r
irsnd_buffer[1] = (command & 0x000F) << 4; // CCCC0000\r
irsnd_busy = TRUE;\r
#endif\r
#if IRSND_SUPPORT_NEC_PROTOCOL == 1\r
case IRMP_NEC_PROTOCOL:\r
+ case IRMP_APPLE_PROTOCOL:\r
{\r
address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN);\r
command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN);\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r
irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r
irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC\r
- irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc\r
+\r
+ if (irsnd_protocol == IRMP_APPLE_PROTOCOL)\r
+ {\r
+ irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command\r
+ irsnd_buffer[3] = 0x8B; // 10001011\r
+ }\r
+ else\r
+ {\r
+ irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc\r
+ }\r
+\r
irsnd_busy = TRUE;\r
break;\r
}\r
address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN);\r
command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN);\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r
irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r
irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC\r
address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN);\r
command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN);\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r
irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r
irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC\r
address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN);\r
command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN);\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC\r
irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA\r
irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA\r
{\r
toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40;\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) |\r
((irmp_data_p->command & 0x0038) >> 3); // STAAACCC\r
irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000\r
{\r
toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40;\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) |\r
((irmp_data_p->command & 0x0030) >> 4); // STAAAACC\r
irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000\r
{\r
toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40;\r
\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 |\r
((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC\r
irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000\r
#if IRSND_SUPPORT_DENON_PROTOCOL == 1\r
case IRMP_DENON_PROTOCOL:\r
{\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC\r
irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC0\r
irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAACCC\r
#if IRSND_SUPPORT_NUBERT_PROTOCOL == 1\r
case IRMP_NUBERT_PROTOCOL:\r
{\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC\r
irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000\r
irsnd_busy = TRUE;\r
#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
case IRMP_BANG_OLUFSEN_PROTOCOL:\r
{\r
- irsnd_protocol = irmp_data_p->protocol;\r
irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC\r
irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC\r
irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000\r