*\r
* Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irmp.c,v 1.104 2011/05/22 21:40:52 fm Exp $\r
+ * $Id: irmp.c,v 1.106 2011/08/16 07:51:19 fm Exp $\r
*\r
* ATMEGA88 @ 8 MHz\r
*\r
\r
#else\r
\r
-#ifndef CODEVISION\r
-\r
#ifdef PIC_CCS_COMPILER\r
\r
#include <string.h>\r
#include <avr/pgmspace.h>\r
\r
#endif // PIC_CCS_COMPILER\r
-#endif // CODEVISION\r
\r
#endif // windows\r
#endif // unix\r
#define ANALYZE_NEWLINE()\r
#endif\r
\r
+/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ * Protocol names\r
+ *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ */\r
+#if IRMP_PROTOCOL_NAMES == 1\r
+char *\r
+irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =\r
+{\r
+ "UNKNOWN",\r
+ "SIRCS",\r
+ "NEC",\r
+ "SAMSUNG",\r
+ "MATSUSH",\r
+ "KASEIKYO",\r
+ "RECS80",\r
+ "RC5",\r
+ "DENON",\r
+ "RC6",\r
+ "SAMSG32",\r
+ "APPLE",\r
+ "RECS80EX",\r
+ "NUBERT",\r
+ "BANG OLU",\r
+ "GRUNDIG",\r
+ "NOKIA",\r
+ "SIEMENS",\r
+ "FDC",\r
+ "RCCAR",\r
+ "JVC",\r
+ "RC6A",\r
+ "NIKON",\r
+ "RUWIDO",\r
+ "IR60",\r
+ "KATHREIN",\r
+ "NETBOX",\r
+ "NEC16",\r
+ "NEC42",\r
+ "LEGO",\r
+ "THOMSON",\r
+ "MERLIN"\r
+};\r
+#endif\r
+\r
+/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ * Logging\r
+ *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ */\r
#if IRMP_LOGGING == 1\r
#define BAUD 9600L\r
#include <util/setbaud.h>\r
\r
#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER sircs_param =\r
+static const PROGMEM IRMP_PARAMETER sircs_param =\r
{\r
IRMP_SIRCS_PROTOCOL, // protocol: ir protocol\r
SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER nec_param =\r
+static const PROGMEM IRMP_PARAMETER nec_param =\r
{\r
IRMP_NEC_PROTOCOL, // protocol: ir protocol\r
NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
NEC_FLAGS // flags: some flags\r
};\r
\r
-static PROGMEM IRMP_PARAMETER nec_rep_param =\r
+static const PROGMEM IRMP_PARAMETER nec_rep_param =\r
{\r
IRMP_NEC_PROTOCOL, // protocol: ir protocol\r
NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER nec42_param =\r
+static const PROGMEM IRMP_PARAMETER nec42_param =\r
{\r
IRMP_NEC42_PROTOCOL, // protocol: ir protocol\r
NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER samsung_param =\r
+static const PROGMEM IRMP_PARAMETER samsung_param =\r
{\r
IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol\r
SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER matsushita_param =\r
+static const PROGMEM IRMP_PARAMETER matsushita_param =\r
{\r
IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol\r
MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER kaseikyo_param =\r
+static const PROGMEM IRMP_PARAMETER kaseikyo_param =\r
{\r
IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol\r
KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER recs80_param =\r
+static const PROGMEM IRMP_PARAMETER recs80_param =\r
{\r
IRMP_RECS80_PROTOCOL, // protocol: ir protocol\r
RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER rc5_param =\r
+static const PROGMEM IRMP_PARAMETER rc5_param =\r
{\r
IRMP_RC5_PROTOCOL, // protocol: ir protocol\r
RC5_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
\r
#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER denon_param =\r
+static const PROGMEM IRMP_PARAMETER denon_param =\r
{\r
IRMP_DENON_PROTOCOL, // protocol: ir protocol\r
DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER rc6_param =\r
+static const PROGMEM IRMP_PARAMETER rc6_param =\r
{\r
IRMP_RC6_PROTOCOL, // protocol: ir protocol\r
\r
\r
#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER recs80ext_param =\r
+static const PROGMEM IRMP_PARAMETER recs80ext_param =\r
{\r
IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol\r
RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER nubert_param =\r
+static const PROGMEM IRMP_PARAMETER nubert_param =\r
{\r
IRMP_NUBERT_PROTOCOL, // protocol: ir protocol\r
NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER bang_olufsen_param =\r
+static const PROGMEM IRMP_PARAMETER bang_olufsen_param =\r
{\r
IRMP_BANG_OLUFSEN_PROTOCOL, // protocol: ir protocol\r
BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
static uint8_t first_bit;\r
\r
-static PROGMEM IRMP_PARAMETER grundig_param =\r
+static const PROGMEM IRMP_PARAMETER grundig_param =\r
{\r
IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol\r
\r
\r
#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER ruwido_param =\r
+static const PROGMEM IRMP_PARAMETER ruwido_param =\r
{\r
IRMP_RUWIDO_PROTOCOL, // protocol: ir protocol\r
SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse\r
\r
#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER fdc_param =\r
+static const PROGMEM IRMP_PARAMETER fdc_param =\r
{\r
IRMP_FDC_PROTOCOL, // protocol: ir protocol\r
FDC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER rccar_param =\r
+static const PROGMEM IRMP_PARAMETER rccar_param =\r
{\r
IRMP_RCCAR_PROTOCOL, // protocol: ir protocol\r
RCCAR_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER nikon_param =\r
+static const PROGMEM IRMP_PARAMETER nikon_param =\r
{\r
IRMP_NIKON_PROTOCOL, // protocol: ir protocol\r
NIKON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER kathrein_param =\r
+static const PROGMEM IRMP_PARAMETER kathrein_param =\r
{\r
IRMP_KATHREIN_PROTOCOL, // protocol: ir protocol\r
KATHREIN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER netbox_param =\r
+static const PROGMEM IRMP_PARAMETER netbox_param =\r
{\r
IRMP_NETBOX_PROTOCOL, // protocol: ir protocol\r
NETBOX_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value\r
\r
#if IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER lego_param =\r
+static const PROGMEM IRMP_PARAMETER lego_param =\r
{\r
IRMP_LEGO_PROTOCOL, // protocol: ir protocol\r
LEGO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_MERLIN_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER merlin_param =\r
+static const PROGMEM IRMP_PARAMETER merlin_param =\r
{\r
IRMP_MERLIN_PROTOCOL, // protocol: ir protocol\r
MERLIN_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value\r
\r
#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER thomson_param =\r
+static const PROGMEM IRMP_PARAMETER thomson_param =\r
{\r
IRMP_THOMSON_PROTOCOL, // protocol: ir protocol\r
THOMSON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
\r
#if IRMP_SUPPORT_IMON_PROTOCOL == 1\r
\r
-static PROGMEM IRMP_PARAMETER imon_param =\r
+static const PROGMEM IRMP_PARAMETER imon_param =\r
{\r
IRMP_IMON_PROTOCOL, // protocol: ir protocol\r
IMON_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1\r
static volatile uint16_t irmp_command;\r
static volatile uint16_t irmp_id; // only used for SAMSUNG protocol\r
static volatile uint8_t irmp_flags;\r
+// static volatile uint8_t irmp_busy_flag;\r
\r
#ifdef ANALYZE\r
static uint8_t IRMP_PIN;\r
}\r
break;\r
#endif\r
+#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
+ case IRMP_RC5_PROTOCOL:\r
+ irmp_address &= ~0x20; // clear toggle bit\r
+ rtc = TRUE;\r
+ break;\r
+#endif\r
#if IRMP_SUPPORT_IR60_PROTOCOL == 1\r
case IRMP_IR60_PROTOCOL:\r
if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame\r
return rtc;\r
}\r
\r
+// uint8_t\r
+// irmp_is_busy (void)\r
+// {\r
+// return irmp_busy_flag;\r
+// }\r
+\r
// these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()\r
static uint16_t irmp_tmp_address; // ir address\r
static uint16_t irmp_tmp_command; // ir command\r
{ // no...\r
if (! irmp_input) // receiving burst?\r
{ // yes...\r
+// irmp_busy_flag = TRUE;\r
#ifdef ANALYZE\r
if (! irmp_pulse_time)\r
{\r
ANALYZE_PRINTF ("%8d error 1: pause after start bit pulse %d too long: %d\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
}\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit\r
irmp_pulse_time = 0;\r
irmp_pause_time = 0;\r
\r
{\r
ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // wait for another start bit...\r
}\r
\r
{\r
ANALYZE_PRINTF ("error: stop bit timing wrong\n");\r
\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // wait for another start bit...\r
irmp_pulse_time = 0;\r
irmp_pause_time = 0;\r
ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // wait for another start bit...\r
irmp_pulse_time = 0;\r
irmp_pause_time = 0;\r
ANALYZE_NEWLINE ();\r
ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
{ // timing incorrect!\r
ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // reset flags and wait for next start bit\r
irmp_pause_time = 0;\r
}\r
\r
irmp_address = irmp_tmp_address; // store address\r
#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
- last_irmp_address = irmp_tmp_address; // store as last address, too\r
+ if (irmp_param.protocol == IRMP_NEC_PROTOCOL)\r
+ {\r
+ last_irmp_address = irmp_tmp_address; // store as last address, too\r
+ }\r
#endif\r
\r
#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
\r
if (irmp_ir_detected)\r
{\r
- if (last_irmp_command == irmp_command &&\r
- last_irmp_address == irmp_address &&\r
+ if (last_irmp_command == irmp_tmp_command &&\r
+ last_irmp_address == irmp_tmp_address &&\r
repetition_len < IRMP_KEY_REPETITION_LEN)\r
{\r
irmp_flags |= IRMP_FLAG_REPETITION;\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
}\r
\r
+// irmp_busy_flag = FALSE;\r
irmp_start_bit_detected = 0; // and wait for next start bit\r
irmp_tmp_command = 0;\r
irmp_pulse_time = 0;\r