]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
Version 2.3.6: corrected detection of inverted Denon frames
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index 3af90e3646f40f734e36a2c527b38dbfa03cba8e..04f8eae182bc081f4b783d73ca46ecd472bc7038 100644 (file)
--- a/irmp.c
+++ b/irmp.c
@@ -1,17 +1,17 @@
 /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
  * irmp.c - infrared multi-protocol decoder, supports several remote control protocols\r
  *\r
- * Copyright (c) 2009-2012 Frank Meyer - frank(at)fli4l.de\r
+ * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: irmp.c,v 1.124 2012/06/18 08:49:29 fm Exp $\r
+ * $Id: irmp.c,v 1.137 2013/01/17 07:33:13 fm Exp $\r
  *\r
  * ATMEGA88 @ 8 MHz\r
  *\r
  * Supported mikrocontrollers:\r
  *\r
- * ATtiny167\r
+ * ATtiny87,  ATtiny167\r
  * ATtiny45,  ATtiny85\r
- * ATtiny84\r
+ * ATtiny44,  ATtiny84\r
  * ATmega8,   ATmega16,  ATmega32\r
  * ATmega162\r
  * ATmega164, ATmega324, ATmega644,  ATmega644P, ATmega1284\r
@@ -42,7 +42,8 @@
     IRMP_SUPPORT_RC6_PROTOCOL == 1 ||                   \\r
     IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 ||    \\r
     IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 ||     \\r
-    IRMP_SUPPORT_IR60_PROTOCOL\r
+    IRMP_SUPPORT_IR60_PROTOCOL == 1 ||                  \\r
+    IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1\r
 #  define IRMP_SUPPORT_MANCHESTER                   1\r
 #else\r
 #  define IRMP_SUPPORT_MANCHESTER                   0\r
 #define RECS80_0_PAUSE_LEN_MIN                  ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define RECS80_0_PAUSE_LEN_MAX                  ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
 \r
+\r
+#if IRMP_SUPPORT_BOSE_PROTOCOL == 1 // BOSE conflicts with RC5, so keep tolerance for RC5 minimal here:\r
+#define RC5_START_BIT_LEN_MIN                   ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_05 + 0.5) - 1)\r
+#define RC5_START_BIT_LEN_MAX                   ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_05 + 0.5) + 1)\r
+#else\r
 #define RC5_START_BIT_LEN_MIN                   ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define RC5_START_BIT_LEN_MAX                   ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#endif\r
 \r
 #define RC5_BIT_LEN_MIN                         ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define RC5_BIT_LEN_MAX                         ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
 #define LEGO_0_PAUSE_LEN_MIN                    ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
 #define LEGO_0_PAUSE_LEN_MAX                    ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
 \r
+#define BOSE_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define BOSE_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define BOSE_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define BOSE_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define BOSE_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define BOSE_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define BOSE_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define BOSE_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define BOSE_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define BOSE_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define BOSE_FRAME_REPEAT_PAUSE_LEN_MAX          (uint16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5)\r
+\r
+#define A1TVBOX_START_BIT_PULSE_LEN_MIN         ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define A1TVBOX_START_BIT_PULSE_LEN_MAX         ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define A1TVBOX_START_BIT_PAUSE_LEN_MIN         ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define A1TVBOX_START_BIT_PAUSE_LEN_MAX         ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define A1TVBOX_BIT_PULSE_LEN_MIN               ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define A1TVBOX_BIT_PULSE_LEN_MAX               ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define A1TVBOX_BIT_PAUSE_LEN_MIN               ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define A1TVBOX_BIT_PAUSE_LEN_MAX               ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+\r
 #define AUTO_FRAME_REPETITION_LEN               (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5)       // use uint16_t!\r
 \r
 #ifdef ANALYZE\r
 #  define ANALYZE_PUTCHAR(a)                    { if (! silent)             { putchar (a);          } }\r
 #  define ANALYZE_ONLY_NORMAL_PUTCHAR(a)        { if (! silent && !verbose) { putchar (a);          } }\r
 #  define ANALYZE_PRINTF(...)                   { if (verbose)              { printf (__VA_ARGS__); } }\r
+#  define ANALYZE_ONLY_NORMAL_PRINTF(...)       { if (! silent && !verbose) { printf (__VA_ARGS__); } }\r
 #  define ANALYZE_NEWLINE()                     { if (verbose)              { putchar ('\n');       } }\r
 static int                                      silent;\r
 static int                                      time_counter;\r
@@ -368,6 +397,7 @@ static int                                      verbose;
 #  define ANALYZE_PUTCHAR(a)\r
 #  define ANALYZE_ONLY_NORMAL_PUTCHAR(a)\r
 #  define ANALYZE_PRINTF(...)\r
+#  define ANALYZE_ONLY_NORMAL_PRINTF(...)\r
 #  define ANALYZE_NEWLINE()\r
 #endif\r
 \r
@@ -379,7 +409,7 @@ static void                                     (*irmp_callback_ptr) (uint8_t);
  *  Protocol names\r
  *---------------------------------------------------------------------------------------------------------------------------------------------------\r
  */\r
-#if IRMP_PROTOCOL_NAMES == 1\r
+#if defined(UNIX_OR_WINDOWS) || IRMP_PROTOCOL_NAMES == 1\r
 char *\r
 irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =\r
 {\r
@@ -413,7 +443,9 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =
     "NEC16",\r
     "NEC42",\r
     "LEGO",\r
-    "THOMSON"\r
+    "THOMSON",\r
+    "BOSE",\r
+    "A1TVBOX",\r
 };\r
 #endif\r
 \r
@@ -427,7 +459,9 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =
 #include "irmpextlog.h"\r
 #else                                                               // normal UART log (IRMP_EXT_LOGGING == 0)\r
 #define BAUD                                    9600L\r
+#ifndef UNIX_OR_WINDOWS\r
 #include <util/setbaud.h>\r
+#endif\r
 \r
 #ifdef UBRR0H\r
 \r
@@ -478,6 +512,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =
 void\r
 irmp_uart_init (void)\r
 {\r
+#ifndef UNIX_OR_WINDOWS\r
 #if (IRMP_EXT_LOGGING == 0)                                                                         // use UART\r
     UART0_UBRRH = UBRRH_VALUE;                                                                      // set baud rate\r
     UART0_UBRRL = UBRRL_VALUE;\r
@@ -493,6 +528,7 @@ irmp_uart_init (void)
 #else                                                                                               // other log method\r
         initextlog();                                                         \r
 #endif //IRMP_EXT_LOGGING\r
+#endif // UNIX_OR_WINDOWS\r
 }\r
 \r
 /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
@@ -504,6 +540,7 @@ irmp_uart_init (void)
 void\r
 irmp_uart_putc (unsigned char ch)\r
 {\r
+#ifndef UNIX_OR_WINDOWS\r
 #if (IRMP_EXT_LOGGING == 0)\r
     while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE))\r
     {\r
@@ -514,6 +551,9 @@ irmp_uart_putc (unsigned char ch)
 #else\r
     sendextlog(ch); //Use external log\r
 #endif\r
+#else\r
+    fputc (ch, stderr);\r
+#endif // UNIX_OR_WINDOWS\r
 }\r
 \r
 /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
@@ -525,6 +565,8 @@ irmp_uart_putc (unsigned char ch)
 #define ENDBITS                        1000                                 // number of sequenced highbits to detect end\r
 #define DATALEN                         700                                 // log buffer size\r
 \r
+#if 0                                                                       // old log routine\r
+\r
 static void\r
 irmp_log (uint8_t val)\r
 {\r
@@ -594,6 +636,98 @@ irmp_log (uint8_t val)
     }\r
 }\r
 \r
+#else                                                                       // new log routine\r
+\r
+static void\r
+irmp_log (uint8_t val)\r
+{\r
+    static uint8_t  buf[DATALEN];                                           // logging buffer\r
+    static uint16_t buf_idx;                                                // index\r
+    static uint8_t  startcycles;                                            // current number of start-zeros\r
+    static uint16_t cnt;                                                    // counts sequenced highbits - to detect end\r
+    static uint8_t  last_val = 1;\r
+\r
+    if (! val && (startcycles < STARTCYCLES) && !buf_idx)                   // prevent that single random zeros init logging\r
+    {\r
+        startcycles++;\r
+    }\r
+    else\r
+    {\r
+        startcycles = 0;\r
+\r
+        if (! val || buf_idx != 0)                                          // start or continue logging on "0", "1" cannot init logging\r
+        {\r
+            if (last_val == val)\r
+            {\r
+                cnt++;\r
+\r
+                if (val && cnt > ENDBITS)                                   // if high received then look at log-stop condition\r
+                {                                                           // if stop condition is true, output on uart\r
+                    uint8_t     i8;\r
+                    uint16_t    i;\r
+                    uint16_t    j;\r
+                    uint8_t     v = '1';\r
+                    uint16_t    d;\r
+\r
+                    for (i8 = 0; i8 < STARTCYCLES; i8++)\r
+                    {\r
+                        irmp_uart_putc ('0');                               // the ignored starting zeros\r
+                    }\r
+\r
+                    for (i = 0; i < buf_idx; i++)\r
+                    {\r
+                        d = buf[i];\r
+\r
+                        if (d == 0xff)\r
+                        {\r
+                            i++;\r
+                            d = buf[i];\r
+                            i++;\r
+                            d |= ((uint16_t) buf[i] << 8);\r
+                        }\r
+\r
+                        for (j = 0; j < d; j++)\r
+                        {\r
+                            irmp_uart_putc (v);\r
+                        }\r
+\r
+                        v = (v == '1') ? '0' : '1';\r
+                    }\r
+\r
+                    for (i8 = 0; i8 < 20; i8++)\r
+                    {\r
+                        irmp_uart_putc ('1');\r
+                    }\r
+\r
+                    irmp_uart_putc ('\n');\r
+                    buf_idx = 0;\r
+                    last_val = 1;\r
+                    cnt = 0;\r
+                }\r
+            }\r
+            else if (buf_idx < DATALEN - 3)\r
+            {\r
+                if (cnt >= 0xff)\r
+                {\r
+                    buf[buf_idx++]  = 0xff;\r
+                    buf[buf_idx++]  = (cnt & 0xff);\r
+                    buf[buf_idx]    = (cnt >> 8);\r
+                }\r
+                else\r
+                {\r
+                    buf[buf_idx] = cnt;\r
+                }\r
+\r
+                buf_idx++;\r
+                cnt = 1;\r
+                last_val = val;\r
+            }\r
+        }\r
+    }\r
+}\r
+\r
+#endif\r
+\r
 #else\r
 #define irmp_log(val)\r
 #endif //IRMP_LOGGING\r
@@ -1194,6 +1328,57 @@ static const PROGMEM IRMP_PARAMETER thomson_param =
 \r
 #endif\r
 \r
+#if IRMP_SUPPORT_BOSE_PROTOCOL == 1\r
+\r
+static const PROGMEM IRMP_PARAMETER bose_param =\r
+{\r
+    IRMP_BOSE_PROTOCOL,                                                 // protocol:        ir protocol\r
+    BOSE_PULSE_LEN_MIN,                                                 // pulse_1_len_min: minimum length of pulse with bit value 1\r
+    BOSE_PULSE_LEN_MAX,                                                 // pulse_1_len_max: maximum length of pulse with bit value 1\r
+    BOSE_1_PAUSE_LEN_MIN,                                               // pause_1_len_min: minimum length of pause with bit value 1\r
+    BOSE_1_PAUSE_LEN_MAX,                                               // pause_1_len_max: maximum length of pause with bit value 1\r
+    BOSE_PULSE_LEN_MIN,                                                 // pulse_0_len_min: minimum length of pulse with bit value 0\r
+    BOSE_PULSE_LEN_MAX,                                                 // pulse_0_len_max: maximum length of pulse with bit value 0\r
+    BOSE_0_PAUSE_LEN_MIN,                                               // pause_0_len_min: minimum length of pause with bit value 0\r
+    BOSE_0_PAUSE_LEN_MAX,                                               // pause_0_len_max: maximum length of pause with bit value 0\r
+    BOSE_ADDRESS_OFFSET,                                                // address_offset:  address offset\r
+    BOSE_ADDRESS_OFFSET + BOSE_ADDRESS_LEN,                             // address_end:     end of address\r
+    BOSE_COMMAND_OFFSET,                                                // command_offset:  command offset\r
+    BOSE_COMMAND_OFFSET + BOSE_COMMAND_LEN,                             // command_end:     end of command\r
+    BOSE_COMPLETE_DATA_LEN,                                             // complete_len:    complete length of frame\r
+    BOSE_STOP_BIT,                                                      // stop_bit:        flag: frame has stop bit\r
+    BOSE_LSB,                                                           // lsb_first:       flag: LSB first\r
+    BOSE_FLAGS                                                          // flags:           some flags\r
+};\r
+\r
+#endif\r
+\r
+#if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1\r
+\r
+static const PROGMEM IRMP_PARAMETER a1tvbox_param =\r
+{\r
+    IRMP_A1TVBOX_PROTOCOL,                                              // protocol:        ir protocol\r
+\r
+    A1TVBOX_BIT_PULSE_LEN_MIN,                                          // pulse_1_len_min: here: minimum length of short pulse\r
+    A1TVBOX_BIT_PULSE_LEN_MAX,                                          // pulse_1_len_max: here: maximum length of short pulse\r
+    A1TVBOX_BIT_PAUSE_LEN_MIN,                                          // pause_1_len_min: here: minimum length of short pause\r
+    A1TVBOX_BIT_PAUSE_LEN_MAX,                                          // pause_1_len_max: here: maximum length of short pause\r
+    0,                                                                  // pulse_0_len_min: here: not used\r
+    0,                                                                  // pulse_0_len_max: here: not used\r
+    0,                                                                  // pause_0_len_min: here: not used\r
+    0,                                                                  // pause_0_len_max: here: not used\r
+    A1TVBOX_ADDRESS_OFFSET,                                             // address_offset:  address offset\r
+    A1TVBOX_ADDRESS_OFFSET + A1TVBOX_ADDRESS_LEN,                       // address_end:     end of address\r
+    A1TVBOX_COMMAND_OFFSET,                                             // command_offset:  command offset\r
+    A1TVBOX_COMMAND_OFFSET + A1TVBOX_COMMAND_LEN,                       // command_end:     end of command\r
+    A1TVBOX_COMPLETE_DATA_LEN,                                          // complete_len:    complete length of frame\r
+    A1TVBOX_STOP_BIT,                                                   // stop_bit:        flag: frame has stop bit\r
+    A1TVBOX_LSB,                                                        // lsb_first:       flag: LSB first\r
+    A1TVBOX_FLAGS                                                       // flags:           some flags\r
+};\r
+\r
+#endif\r
+\r
 static uint8_t                              irmp_bit;                   // current bit position\r
 static IRMP_PARAMETER                       irmp_param;\r
 \r
@@ -1248,6 +1433,15 @@ irmp_init (void)
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;\r
  #endif\r
    GPIO_Init(IRMP_PORT, &GPIO_InitStructure);\r
+#elif defined(STELLARIS_ARM_CORTEX_M4)\r
+     // Enable the GPIO port\r
+     ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);\r
+\r
+     // Set as an input\r
+     ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN);\r
+     ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN,\r
+                          GPIO_STRENGTH_2MA,\r
+                          GPIO_PIN_TYPE_STD_WPU);\r
 #else                                                                   // AVR\r
     IRMP_PORT &= ~(1<<IRMP_BIT);                                        // deactivate pullup\r
     IRMP_DDR &= ~(1<<IRMP_BIT);                                         // set pin to input\r
@@ -1301,6 +1495,15 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
                 }\r
                 break;\r
 #endif\r
+#if IRMP_SUPPORT_BOSE_PROTOCOL == 1\r
+            case IRMP_BOSE_PROTOCOL:\r
+                if ((irmp_command >> 8) == (~irmp_command & 0x00FF))\r
+                {\r
+                    irmp_command &= 0xff;\r
+                    rtc = TRUE;\r
+                }\r
+                break;\r
+#endif\r
 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1\r
             case IRMP_SIEMENS_PROTOCOL:\r
             case IRMP_RUWIDO_PROTOCOL:\r
@@ -1390,7 +1593,7 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
                 else\r
                 {\r
                     ANALYZE_PRINTF ("CRC error in LEGO protocol\n");\r
-                    rtc = TRUE;\r
+                    // rtc = TRUE;                              // don't accept codes with CRC errors\r
                 }\r
                 break;\r
             }\r
@@ -1591,10 +1794,11 @@ irmp_ISR (void)
     static PAUSE_LEN    irmp_pause_time;                                        // count bit time for pause\r
     static uint16_t     last_irmp_address = 0xFFFF;                             // save last irmp address to recognize key repetition\r
     static uint16_t     last_irmp_command = 0xFFFF;                             // save last irmp command to recognize key repetition\r
-    static uint16_t     repetition_len;                                         // SIRCS repeats frame 2-5 times with 45 ms pause\r
+    static uint16_t     key_repetition_len;                                     // SIRCS repeats frame 2-5 times with 45 ms pause\r
     static uint8_t      repetition_frame_number;\r
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
     static uint16_t     last_irmp_denon_command;                                // save last irmp command to recognize DENON frame repetition\r
+    static uint16_t     denon_repetition_len = 0xFFFF;                          // denon repetition len of 2nd auto generated frame\r
 #endif\r
 #if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
     static uint8_t      rc5_cmd_bit6;                                           // bit 6 of RC5 command is the inverted 2nd start bit\r
@@ -1669,16 +1873,22 @@ irmp_ISR (void)
                 }\r
                 else\r
                 {\r
-                    if (repetition_len < 0xFFFF)                                // avoid overflow of counter\r
+                    if (key_repetition_len < 0xFFFF)                            // avoid overflow of counter\r
                     {\r
-                        repetition_len++;\r
+                        key_repetition_len++;\r
 \r
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
-                        if (repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0)\r
+                        if (denon_repetition_len < 0xFFFF)                      // avoid overflow of counter\r
                         {\r
-                            ANALYZE_PRINTF ("%8.3fms error 6: did not receive inverted command repetition\n",\r
-                                            (double) (time_counter * 1000) / F_INTERRUPTS);\r
-                            last_irmp_denon_command = 0;\r
+                            denon_repetition_len++;\r
+\r
+                            if (denon_repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0)\r
+                            {\r
+                                ANALYZE_PRINTF ("%8.3fms error 6: did not receive inverted command repetition\n",\r
+                                                (double) (time_counter * 1000) / F_INTERRUPTS);\r
+                                last_irmp_denon_command = 0;\r
+                                denon_repetition_len = 0xFFFF;\r
+                            }\r
                         }\r
 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1\r
                     }\r
@@ -1957,6 +2167,18 @@ irmp_ISR (void)
                     else\r
 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
 \r
+#if IRMP_SUPPORT_BOSE_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= BOSE_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= BOSE_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= BOSE_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BOSE_START_BIT_PAUSE_LEN_MAX)\r
+                    {\r
+                        ANALYZE_PRINTF ("protocol = BOSE, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        BOSE_START_BIT_PULSE_LEN_MIN, BOSE_START_BIT_PULSE_LEN_MAX,\r
+                                        BOSE_START_BIT_PAUSE_LEN_MIN, BOSE_START_BIT_PAUSE_LEN_MAX);\r
+                        irmp_param_p = (IRMP_PARAMETER *) &bose_param;\r
+                    }\r
+                    else\r
+#endif // IRMP_SUPPORT_BOSE_PROTOCOL == 1\r
+\r
 #if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
                     if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)\r
@@ -2110,6 +2332,20 @@ irmp_ISR (void)
                     else\r
 #endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
 \r
+#if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= A1TVBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= A1TVBOX_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= A1TVBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= A1TVBOX_START_BIT_PAUSE_LEN_MAX)\r
+                    {                                                           // it's A1TVBOX\r
+                        ANALYZE_PRINTF ("protocol = A1TVBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        A1TVBOX_START_BIT_PULSE_LEN_MIN, A1TVBOX_START_BIT_PULSE_LEN_MAX,\r
+                                        A1TVBOX_START_BIT_PAUSE_LEN_MIN, A1TVBOX_START_BIT_PAUSE_LEN_MAX);\r
+                        irmp_param_p = (IRMP_PARAMETER *) &a1tvbox_param;\r
+                        last_pause = 0;\r
+                        last_value = 1;\r
+                    }\r
+                    else\r
+#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
+\r
                     {\r
                         ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
 //                      irmp_busy_flag = FALSE;\r
@@ -2934,7 +3170,7 @@ irmp_ISR (void)
 \r
             if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0)    // enough bits received?\r
             {\r
-                if (last_irmp_command == irmp_tmp_command && repetition_len < AUTO_FRAME_REPETITION_LEN)\r
+                if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN)\r
                 {\r
                     repetition_frame_number++;\r
                 }\r
@@ -2948,8 +3184,8 @@ irmp_ISR (void)
                 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))\r
                 {\r
                     ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
-                                    repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
-                    repetition_len = 0;\r
+                                    repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);\r
+                    key_repetition_len = 0;\r
                 }\r
                 else\r
 #endif\r
@@ -2959,8 +3195,8 @@ irmp_ISR (void)
                 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)\r
                 {\r
                     ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
-                                    repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
-                    repetition_len = 0;\r
+                                    repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);\r
+                    key_repetition_len = 0;\r
                 }\r
                 else\r
 #endif\r
@@ -2970,8 +3206,8 @@ irmp_ISR (void)
                 if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01))\r
                 {\r
                     ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
-                                    repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
-                    repetition_len = 0;\r
+                                    repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);\r
+                    key_repetition_len = 0;\r
                 }\r
                 else\r
 #endif\r
@@ -2981,8 +3217,8 @@ irmp_ISR (void)
                 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))\r
                 {\r
                     ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
-                                    repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);\r
-                    repetition_len = 0;\r
+                                    repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);\r
+                    key_repetition_len = 0;\r
                 }\r
                 else\r
 #endif\r
@@ -3001,14 +3237,29 @@ irmp_ISR (void)
 \r
                             irmp_protocol = irmp_param.protocol;                    // store protocol\r
                             irmp_address = irmp_tmp_address;                        // store address\r
-                            irmp_command = irmp_tmp_command ;                       // store command\r
+                            irmp_command = irmp_tmp_command                       // store command\r
                         }\r
                         else\r
                         {\r
-                            ANALYZE_PRINTF ("%8.3fms waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
-                            irmp_ir_detected = FALSE;\r
-                            last_irmp_denon_command = irmp_tmp_command;\r
-                            repetition_len = 0;\r
+                            if ((irmp_tmp_command & 0x03) == 0x00)\r
+                            {\r
+                                ANALYZE_PRINTF ("%8.3fms info Denon: waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
+                                last_irmp_denon_command = irmp_tmp_command;\r
+                                denon_repetition_len = 0;\r
+                                irmp_ir_detected = FALSE;\r
+                            }\r
+                            else if ((irmp_tmp_command & 0x03) == 0x03)\r
+                            {\r
+                                ANALYZE_PRINTF ("%8.3fms error Denon: got unexpected inverted command, ignoring it\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
+                                last_irmp_denon_command = 0;\r
+                                irmp_ir_detected = FALSE;\r
+                            }\r
+                            else    // fm 2013-01-17: 0x01 or 0x10: there is no inverted command\r
+                            {\r
+                                irmp_protocol = irmp_param.protocol;                // store protocol\r
+                                irmp_address = irmp_tmp_address;                    // store address\r
+                                irmp_command = irmp_tmp_command;                    // store command\r
+                            }\r
                         }\r
                     }\r
                     else\r
@@ -3035,18 +3286,19 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
                         if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0)  // repetition frame\r
                         {\r
-                            if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)\r
+                            if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)\r
                             {\r
-                                ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len);\r
+                                ANALYZE_PRINTF ("Detected NEC repetition frame, key_repetition_len = %d\n", key_repetition_len);\r
+                                ANALYZE_ONLY_NORMAL_PRINTF("REPETETION FRAME                ");\r
                                 irmp_tmp_address = last_irmp_address;                   // address is last address\r
                                 irmp_tmp_command = last_irmp_command;                   // command is last command\r
                                 irmp_flags |= IRMP_FLAG_REPETITION;\r
-                                repetition_len = 0;\r
+                                key_repetition_len = 0;\r
                             }\r
                             else\r
                             {\r
-                                ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n",\r
-                                                repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);\r
+                                ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, key_repetition_len = %d > %d\n",\r
+                                                key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);\r
                                 irmp_ir_detected = FALSE;\r
                             }\r
                         }\r
@@ -3055,23 +3307,23 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
                         if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
                         {\r
-                            uint8_t xor;\r
+                            uint8_t xor_value;\r
                             // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",\r
                             //                 xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]);\r
 \r
-                            xor = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);\r
+                            xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);\r
 \r
-                            if (xor != (xor_check[2] & 0x0F))\r
+                            if (xor_value != (xor_check[2] & 0x0F))\r
                             {\r
-                                ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, xor_check[2] & 0x0F);\r
+                                ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F);\r
                                 irmp_ir_detected = FALSE;\r
                             }\r
 \r
-                            xor = xor_check[2] ^ xor_check[3] ^ xor_check[4];\r
+                            xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4];\r
 \r
-                            if (xor != xor_check[5])\r
+                            if (xor_value != xor_check[5])\r
                             {\r
-                                ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);\r
+                                ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]);\r
                                 irmp_ir_detected = FALSE;\r
                             }\r
 \r
@@ -3132,7 +3384,7 @@ irmp_ISR (void)
                 {\r
                     if (last_irmp_command == irmp_tmp_command &&\r
                         last_irmp_address == irmp_tmp_address &&\r
-                        repetition_len < IRMP_KEY_REPETITION_LEN)\r
+                        key_repetition_len < IRMP_KEY_REPETITION_LEN)\r
                     {\r
                         irmp_flags |= IRMP_FLAG_REPETITION;\r
                     }\r
@@ -3140,7 +3392,7 @@ irmp_ISR (void)
                     last_irmp_address = irmp_tmp_address;                           // store as last address, too\r
                     last_irmp_command = irmp_tmp_command;                           // store as last command, too\r
 \r
-                    repetition_len = 0;\r
+                    key_repetition_len = 0;\r
                 }\r
                 else\r
                 {\r
@@ -3162,6 +3414,12 @@ irmp_ISR (void)
             }\r
         }\r
     }\r
+\r
+#if defined(STELLARIS_ARM_CORTEX_M4)\r
+    // Clear the timer interrupt\r
+    TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);\r
+#endif\r
+\r
     return (irmp_ir_detected);\r
 }\r
 \r
@@ -3531,6 +3789,10 @@ get_fdc_key (uint16_t cmd)
 static int         analyze = FALSE;\r
 static int         list = FALSE;\r
 static IRMP_DATA   irmp_data;\r
+static int         expected_protocol;\r
+static int         expected_address;\r
+static int         expected_command;\r
+static int         do_check_expected_values;\r
 \r
 static void\r
 next_tick (void)\r
@@ -3554,8 +3816,8 @@ next_tick (void)
             {\r
                 if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)\r
                 {\r
-                    printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n",\r
-                            irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key);\r
+                    printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key='%c'",\r
+                            irmp_data.protocol,  irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, key);\r
                 }\r
                 else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F))                 // function keys\r
                 {\r
@@ -3596,19 +3858,39 @@ next_tick (void)
                         default                  : p = "<UNKNWON>";     break;\r
                     }\r
 \r
-                    printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n",\r
-                            irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p);\r
+                    printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key=%s",\r
+                            irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, p);\r
+                }\r
+                else\r
+                {\r
+                    printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x",\r
+                            irmp_data.protocol,  irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key);\r
+                }\r
+            }\r
+            else\r
+            {\r
+                printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x",\r
+                        irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags);\r
+            }\r
+\r
+            if (do_check_expected_values)\r
+            {\r
+                if (irmp_data.protocol != expected_protocol ||\r
+                    irmp_data.address  != expected_address  ||\r
+                    irmp_data.command  != expected_command)\r
+                {\r
+                    printf ("\nerror 7: expected values differ: p=%2d (%s), a=0x%04x, c=0x%04x\n",\r
+                            expected_protocol, irmp_protocol_names[expected_protocol], expected_address, expected_command);\r
                 }\r
                 else\r
                 {\r
-                    printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n",\r
-                            irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key);\r
+                    printf (" checked!\n");\r
                 }\r
+                do_check_expected_values = FALSE;                           // only check 1st frame in a line!\r
             }\r
             else\r
             {\r
-                printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",\r
-                        irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);\r
+                putchar ('\n');\r
             }\r
         }\r
     }\r
@@ -3739,6 +4021,7 @@ main (int argc, char ** argv)
         else if (ch == '\n')\r
         {\r
             IRMP_PIN = 0xff;\r
+            time_counter = 0;\r
 \r
             if (list && pause > 0)\r
             {\r
@@ -3758,6 +4041,8 @@ main (int argc, char ** argv)
         }\r
         else if (ch == '#')\r
         {\r
+            time_counter = 0;\r
+\r
             if (analyze)\r
             {\r
                 while ((ch = getchar()) != '\n' && ch != EOF)\r
@@ -3767,13 +4052,81 @@ main (int argc, char ** argv)
             }\r
             else\r
             {\r
+                char            buf[1024];\r
+                char *          p;\r
+                int             idx = -1;\r
+\r
                 puts ("-------------------------------------------------------------------");\r
                 putchar (ch);\r
 \r
+\r
                 while ((ch = getchar()) != '\n' && ch != EOF)\r
                 {\r
                     if (ch != '\r')                                                         // ignore CR in DOS/Windows files\r
                     {\r
+                        if (ch == '[' && idx == -1)\r
+                        {\r
+                            idx = 0;\r
+                        }\r
+                        else if (idx >= 0)\r
+                        {\r
+                            if (ch == ']')\r
+                            {\r
+                                do_check_expected_values = FALSE;\r
+                                buf[idx] = '\0';\r
+                                idx = -1;\r
+\r
+                                expected_protocol = atoi (buf);\r
+\r
+                                if (expected_protocol > 0)\r
+                                {\r
+                                    p = buf;\r
+                                    while (*p)\r
+                                    {\r
+                                        if (*p == 'x')\r
+                                        {\r
+                                            p++;\r
+\r
+                                            if (sscanf (p, "%x", &expected_address) == 1)\r
+                                            {\r
+                                                do_check_expected_values = TRUE;\r
+                                            }\r
+                                            break;\r
+                                        }\r
+                                        p++;\r
+                                    }\r
+\r
+                                    if (do_check_expected_values)\r
+                                    {\r
+                                        do_check_expected_values = FALSE;\r
+\r
+                                        while (*p)\r
+                                        {\r
+                                            if (*p == 'x')\r
+                                            {\r
+                                                p++;\r
+\r
+                                                if (sscanf (p, "%x", &expected_command) == 1)\r
+                                                {\r
+                                                    do_check_expected_values = TRUE;\r
+                                                }\r
+                                                break;\r
+                                            }\r
+                                            p++;\r
+                                        }\r
+\r
+                                        if (do_check_expected_values)\r
+                                        {\r
+                                            // printf ("!%2d %04x %04x!\n", expected_protocol, expected_address, expected_command);\r
+                                        }\r
+                                    }\r
+                                }\r
+                            }\r
+                            else if (idx < 1024 - 2)\r
+                            {\r
+                                buf[idx++] = ch;\r
+                            }\r
+                        }\r
                         putchar (ch);\r
                     }\r
                 }\r