]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
version 2.0.0-pre6: added support for ATtiny85, removed support for codevision, added...
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index 130a5ce28d5ed0386d003bc9adbeefa8470d27f8..bf75b69f1bf83419ed86399098c37371045ab9f8 100644 (file)
--- a/irmp.c
+++ b/irmp.c
@@ -3,7 +3,7 @@
  *\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
@@ -316,8 +316,6 @@ typedef unsigned short  uint16_t;
 \r
 #else\r
 \r
-#ifndef CODEVISION\r
-\r
 #ifdef PIC_CCS_COMPILER\r
 \r
 #include <string.h>\r
@@ -336,7 +334,6 @@ typedef unsigned int16  uint16_t;
 #include <avr/pgmspace.h>\r
 \r
 #endif  // PIC_CCS_COMPILER\r
-#endif  // CODEVISION\r
 \r
 #endif // windows\r
 #endif // unix\r
@@ -713,6 +710,53 @@ static int      verbose;
 #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
@@ -1536,6 +1580,7 @@ static volatile uint16_t                    irmp_address;
 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
@@ -1621,6 +1666,12 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
                 }\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
@@ -1708,6 +1759,12 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
     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
@@ -1883,6 +1940,7 @@ irmp_ISR (void)
         {                                                                       // no...\r
             if (! irmp_input)                                                   // receiving burst?\r
             {                                                                   // yes...\r
+//              irmp_busy_flag = TRUE;\r
 #ifdef ANALYZE\r
                 if (! irmp_pulse_time)\r
                 {\r
@@ -1947,6 +2005,7 @@ irmp_ISR (void)
                             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
@@ -2345,6 +2404,7 @@ irmp_ISR (void)
 \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
@@ -2518,6 +2578,7 @@ irmp_ISR (void)
                         {\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
@@ -2696,6 +2757,7 @@ irmp_ISR (void)
                                 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
@@ -2843,6 +2905,7 @@ irmp_ISR (void)
                                 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
@@ -2980,6 +3043,7 @@ irmp_ISR (void)
                         {                                                           // 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
@@ -3025,6 +3089,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                                 {                                                   // 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
@@ -3041,6 +3106,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                                 {                                                   // 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
@@ -3074,6 +3140,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                                 {                                                   // 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
@@ -3083,6 +3150,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                         {                                                           // 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
@@ -3137,6 +3205,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                     {                                                               // 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
@@ -3328,7 +3397,10 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
 \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
@@ -3347,8 +3419,8 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
 \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
@@ -3364,6 +3436,7 @@ printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX);
                     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