* ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284\r
* ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P\r
*\r
- * $Id: irsnd.c,v 1.47 2012/02/16 12:37:30 fm Exp $\r
+ * $Id: irsnd.c,v 1.48 2012/02/24 14:24:28 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
#define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r
#define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r
\r
+#define IR60_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * IR60_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t!\r
+\r
#define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5)\r
#define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5)\r
#define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t!\r
\r
\r
#ifdef PIC_C18\r
+#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1)\r
#else // AVR\r
+#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2) - 1)\r
#define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2) - 1)\r
#define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2) - 1)\r
#define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2) - 1)\r
IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off)\r
#else\r
\r
-\r
#if IRSND_OCx == IRSND_OC2 // use OC2\r
TCCR2 |= (1<<COM20)|(1<<WGM21); // toggle OC2 on compare match, clear Timer 2 at compare match OCR2\r
#elif IRSND_OCx == IRSND_OC2A // use OC2A\r
#ifndef DEBUG\r
\r
#if defined(PIC_C18)\r
- OpenPWM(freq); \r
- SetDCPWM( (uint16_t) freq * 2); // freq*2 = Duty cycles 50%\r
+ OpenPWM(freq); \r
+ SetDCPWM( (uint16_t) freq * 2); // freq*2 = Duty cycles 50%\r
#else //AVR\r
\r
#if IRSND_OCx == IRSND_OC2\r
{\r
#ifndef DEBUG\r
#if defined(PIC_C18)\r
- OpenTimer;\r
- irsnd_set_freq (IRSND_FREQ_36_KHZ); //default frequency\r
- IRSND_PIN = 1; //default PWM output pin off (0=PWM on, 1=PWM off)\r
+ OpenTimer;\r
+ irsnd_set_freq (IRSND_FREQ_36_KHZ); //default frequency\r
+ IRSND_PIN = 1; //default PWM output pin off (0=PWM on, 1=PWM off)\r
#else\r
-\r
IRSND_PORT &= ~(1<<IRSND_BIT); // set IRSND_BIT to low\r
IRSND_DDR |= (1<<IRSND_BIT); // set IRSND_BIT to output\r
\r
#else\r
#error wrong value of IRSND_OCx\r
#endif\r
-\r
irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency\r
#endif //PIC_C18\r
#endif // DEBUG\r
command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN);\r
\r
irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA\r
- irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa\r
+ irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa\r
irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa\r
irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC\r
irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc\r
break;\r
}\r
#endif\r
+#if IRSND_SUPPORT_IR60_PROTOCOL == 1\r
+ case IRMP_IR60_PROTOCOL:\r
+ {\r
+ command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN);\r
+ irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame)\r
+ irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame)\r
+\r
+ irsnd_busy = TRUE;\r
+ break;\r
+ }\r
+#endif\r
#if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
case IRMP_NOKIA_PROTOCOL:\r
{\r
uint8_t\r
irsnd_ISR (void)\r
{\r
- static uint8_t send_trailer = FALSE;\r
- static uint8_t current_bit = 0;// 0xFF;\r
- static uint8_t pulse_counter = 0;\r
- static IRSND_PAUSE_LEN pause_counter = 0;\r
- static uint8_t startbit_pulse_len = 0;\r
- static IRSND_PAUSE_LEN startbit_pause_len = 0;\r
- static uint8_t pulse_1_len = 0;\r
- static uint8_t pause_1_len = 0;\r
- static uint8_t pulse_0_len = 0;\r
- static uint8_t pause_0_len = 0;\r
- static uint8_t has_stop_bit = 0;\r
- static uint8_t new_frame = TRUE;\r
- static uint8_t complete_data_len = 0;\r
- static uint8_t n_repeat_frames = 0; // number of repetition frames\r
- static uint8_t n_auto_repetitions = 0; // number of auto_repetitions\r
- static uint8_t auto_repetition_counter = 0; // auto_repetition counter\r
- static uint16_t auto_repetition_pause_len = 0; // pause before auto_repetition, uint16_t!\r
- static uint16_t auto_repetition_pause_counter = 0; // pause before auto_repetition, uint16_t!\r
- static uint8_t repeat_counter = 0; // repeat counter\r
- static uint16_t repeat_frame_pause_len = 0; // pause before repeat, uint16_t!\r
- static uint16_t packet_repeat_pause_counter = 0; // pause before repeat, uint16_t!\r
+ static uint8_t send_trailer = FALSE;\r
+ static uint8_t current_bit = 0xFF;\r
+ static uint8_t pulse_counter = 0;\r
+ static IRSND_PAUSE_LEN pause_counter = 0;\r
+ static uint8_t startbit_pulse_len = 0;\r
+ static IRSND_PAUSE_LEN startbit_pause_len = 0;\r
+ static uint8_t pulse_1_len = 0;\r
+ static uint8_t pause_1_len = 0;\r
+ static uint8_t pulse_0_len = 0;\r
+ static uint8_t pause_0_len = 0;\r
+ static uint8_t has_stop_bit = 0;\r
+ static uint8_t new_frame = TRUE;\r
+ static uint8_t complete_data_len = 0;\r
+ static uint8_t n_repeat_frames = 0; // number of repetition frames\r
+ static uint8_t n_auto_repetitions = 0; // number of auto_repetitions\r
+ static uint8_t auto_repetition_counter = 0; // auto_repetition counter\r
+ static uint16_t auto_repetition_pause_len = 0; // pause before auto_repetition, uint16_t!\r
+ static uint16_t auto_repetition_pause_counter = 0; // pause before auto_repetition, uint16_t!\r
+ static uint8_t repeat_counter = 0; // repeat counter\r
+ static uint16_t repeat_frame_pause_len = 0; // pause before repeat, uint16_t!\r
+ static uint16_t packet_repeat_pause_counter = 0; // pause before repeat, uint16_t!\r
#if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
- static uint8_t last_bit_value;\r
+ static uint8_t last_bit_value;\r
#endif\r
- static uint8_t pulse_len = 0xFF;\r
- static IRSND_PAUSE_LEN pause_len = 0xFF;\r
+ static uint8_t pulse_len = 0xFF;\r
+ static IRSND_PAUSE_LEN pause_len = 0xFF;\r
\r
if (irsnd_busy)\r
{\r
{\r
auto_repetition_pause_counter = 0;\r
\r
- if (irsnd_protocol == IRMP_DENON_PROTOCOL)\r
+ if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame\r
{\r
current_bit = 16;\r
complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1;\r
}\r
- else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig info frame\r
+ else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame\r
{\r
current_bit = 15;\r
complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN;\r
}\r
- else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia info frame\r
+ else if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame\r
+ {\r
+ current_bit = 7;\r
+ complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1;\r
+ }\r
+ else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame\r
{\r
if (auto_repetition_counter + 1 < n_auto_repetitions)\r
{\r
return irsnd_busy;\r
}\r
\r
-\r
n_repeat_frames = irsnd_repeat;\r
\r
if (n_repeat_frames == IRSND_ENDLESS_REPETITION)\r
complete_data_len = GRUNDIG_COMPLETE_DATA_LEN;\r
n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames\r
auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause\r
- repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r
+ repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r
irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
-\r
+ break;\r
+ }\r
+#endif\r
+#if IRSND_SUPPORT_IR60_PROTOCOL == 1\r
+ case IRMP_IR60_PROTOCOL:\r
+ {\r
+ startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r
+ startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1;\r
+ pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r
+ pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN;\r
+ has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT;\r
+ complete_data_len = IR60_COMPLETE_DATA_LEN;\r
+ n_auto_repetitions = IR60_FRAMES; // 2 frames\r
+ auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause\r
+ repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause\r
+ irsnd_set_freq (IRSND_FREQ_30_KHZ);\r
break;\r
}\r
#endif\r
auto_repetition_pause_len = 0;\r
repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN;\r
irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
-\r
break;\r
}\r
#endif\r
auto_repetition_pause_len = 0;\r
repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN;\r
irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
-\r
break;\r
}\r
#endif\r
#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1\r
case IRMP_GRUNDIG_PROTOCOL:\r
#endif\r
+#if IRSND_SUPPORT_IR60_PROTOCOL == 1\r
+ case IRMP_IR60_PROTOCOL:\r
+#endif\r
#if IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
case IRMP_NOKIA_PROTOCOL:\r
#endif\r
\r
#if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \\r
- IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+ IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
{\r
if (pulse_counter == pulse_len && pause_counter == pause_len)\r
{\r
{\r
current_bit = 0xFF;\r
\r
-#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
- if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r
+#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+ if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r
{\r
auto_repetition_counter++;\r
\r
{\r
uint8_t first_pulse;\r
\r
-#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
- if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r
+#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+ if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL)\r
{\r
if (current_bit == 0xFF || // start bit of start-frame\r
(irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig)\r
+ (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60)\r
(irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia)\r
{\r
pulse_len = startbit_pulse_len;\r
break;\r
}\r
#endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||\r
- // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+ // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
\r
default:\r
{\r