]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
Version 2.0.3:
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index 208e22d537bf47151dbfb010693e716d6ce62265..9a707ba6e7c454819048d063ef5ee3f74367a9a0 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.108 2011/09/09 11:59:39 fm Exp $\r
+ * $Id: irmp.c,v 1.112 2012/02/13 10:59:07 fm Exp $\r
  *\r
  * ATMEGA88 @ 8 MHz\r
  *\r
  *---------------------------------------------------------------------------------------------------------------------------------------------------\r
  */\r
 \r
+#if defined(__18CXX)\r
+#define PIC_C18                                                             // Microchip C18 Compiler\r
+#endif\r
+\r
 #if defined(__PCM__) || defined(__PCB__) || defined(__PCH__)                // CCS PIC Compiler instead of AVR\r
 #define PIC_CCS_COMPILER\r
 #endif\r
@@ -325,14 +329,17 @@ typedef unsigned short  uint16_t;
 \r
 #else\r
 \r
-#ifdef PIC_CCS_COMPILER\r
+#if defined (PIC_CCS_COMPILER) || defined(PIC_C18)\r
 \r
 #include <string.h>\r
-typedef unsigned int8   uint8_t;\r
-typedef unsigned int16  uint16_t;\r
 #define PROGMEM\r
 #define memcpy_P        memcpy\r
 \r
+#if defined (PIC_CCS_COMPILER)\r
+typedef unsigned int8   uint8_t;\r
+typedef unsigned int16  uint16_t;\r
+#endif\r
+\r
 #else // AVR:\r
 \r
 #include <inttypes.h>\r
@@ -342,7 +349,7 @@ typedef unsigned int16  uint16_t;
 #include <util/delay.h>\r
 #include <avr/pgmspace.h>\r
 \r
-#endif  // PIC_CCS_COMPILER\r
+#endif  // PIC_CCS_COMPILER or PIC_C18\r
 \r
 #endif // windows\r
 #endif // unix\r
@@ -427,18 +434,18 @@ typedef unsigned int16  uint16_t;
 #define SIRCS_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define SIRCS_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
 \r
-#define NEC_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
-#define NEC_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
-#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN      ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX      ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
-#define NEC_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
-#define NEC_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
-#define NEC_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define NEC_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
+#define NEC_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define NEC_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN      ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX      ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define NEC_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define NEC_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define NEC_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define NEC_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
 // autodetect nec repetition frame within 50 msec:\r
 // NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms\r
 #if 0\r
@@ -1537,10 +1544,10 @@ static uint8_t                              IRMP_PIN;
 void\r
 irmp_init (void)\r
 {\r
-#ifndef PIC_CCS_COMPILER\r
+#if !defined(PIC_CCS_COMPILER) && !defined(PIC_C18)                     // only AVR\r
     IRMP_PORT &= ~(1<<IRMP_BIT);                                        // deactivate pullup\r
     IRMP_DDR &= ~(1<<IRMP_BIT);                                         // set pin to input\r
-#endif // PIC_CCS_COMPILER\r
+#endif\r
 \r
 #if IRMP_LOGGING == 1\r
     irmp_uart_init ();\r
@@ -1729,6 +1736,7 @@ static uint16_t irmp_tmp_id;
 #endif\r
 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
 static uint8_t  xor_check[6];                                                           // check kaseikyo "parity" bits\r
+static uint8_t  genre2;                                                                 // save genre2 bits here, later copied to MSB in flags\r
 #endif\r
 \r
 /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
@@ -1791,23 +1799,29 @@ irmp_store_bit (uint8_t value)
 #endif\r
 \r
 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
-    else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit >= 20 && irmp_bit < 24)\r
-    {\r
-        irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8));                   // store 4 system bits in upper nibble with LSB first\r
-    }\r
-\r
-    if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
+    else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
     {\r
-        if (value)\r
+        if (irmp_bit >= 20 && irmp_bit < 24)\r
         {\r
-            xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
+            irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8));       // store 4 system bits (genre 1) in upper nibble with LSB first\r
         }\r
-        else\r
+       else if (irmp_bit >= 24 && irmp_bit < 28)\r
         {\r
-            xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
+            genre2 |= (((uint8_t) (value)) << (irmp_bit - 20));                 // store 4 system bits (genre 2) in upper nibble with LSB first\r
         }\r
-    }\r
 \r
+        if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
+        {\r
+            if (value)\r
+            {\r
+                xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
+            }\r
+            else\r
+            {\r
+                xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
+            }\r
+        }\r
+    }\r
 #endif\r
 \r
     irmp_bit++;\r
@@ -1907,7 +1921,7 @@ irmp_ISR (void)
 #ifdef ANALYZE\r
                 if (! irmp_pulse_time)\r
                 {\r
-                    ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter);\r
+                    ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
                 }\r
 #endif\r
                 irmp_pulse_time++;                                              // increment counter\r
@@ -1921,6 +1935,9 @@ irmp_ISR (void)
                     wait_for_space          = 0;\r
                     irmp_tmp_command        = 0;\r
                     irmp_tmp_address        = 0;\r
+#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
+                    genre2                  = 0;\r
+#endif\r
 \r
 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
                     irmp_tmp_command2       = 0;\r
@@ -1965,7 +1982,7 @@ irmp_ISR (void)
                         else\r
 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\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_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
                             ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                         }\r
 //                      irmp_busy_flag = FALSE;\r
@@ -1982,7 +1999,7 @@ irmp_ISR (void)
                     irmp_param2.protocol = 0;\r
 #endif\r
 \r
-                    ANALYZE_PRINTF ("%8d [start-bit: pulse = %2d, pause = %2d]\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
+                    ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
 \r
 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
                     if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&\r
@@ -2001,7 +2018,7 @@ irmp_ISR (void)
                         irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
                     {\r
-                        ANALYZE_PRINTF ("protocol = NEC or JVC repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,\r
                                         JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
@@ -2029,13 +2046,39 @@ irmp_ISR (void)
                     else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN        && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
                              irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's NEC\r
-                        ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
-                                        NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
-                                        NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
+#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
+                        if (irmp_protocol == IRMP_JVC_PROTOCOL)                 // last protocol was JVC, awaiting repeat frame\r
+                        {                                                       // some jvc remote controls use nec repetition frame for jvc repetition frame\r
+                            ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                            NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
+                                            NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
+                            irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
+                        }\r
+                        else\r
+#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
+                        {\r
+                            ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                            NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
+                                            NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
+\r
+                            irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;\r
+                        }\r
+                    }\r
+                    else\r
 \r
-                        irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;\r
+#if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
+                    if (irmp_protocol == IRMP_JVC_PROTOCOL &&                   // last protocol was JVC, awaiting repeat frame\r
+                        irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= NEC_0_PAUSE_LEN_MIN         && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)\r
+                    {                                                           // it's JVC repetition type 3\r
+                        ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
+                                        NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);\r
+                        irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
                     }\r
                     else\r
+#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
+\r
 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
 \r
 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1\r
@@ -2339,7 +2382,7 @@ irmp_ISR (void)
                         irmp_param_p = (IRMP_PARAMETER *) &lego_param;\r
                     }\r
                     else\r
-#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
+#endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1\r
 \r
                     {\r
                         ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
@@ -2385,8 +2428,15 @@ irmp_ISR (void)
 \r
                         if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
                         {\r
-                            ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);\r
-                            ANALYZE_PRINTF ("pause_0: %3d - %3d\n", 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);\r
+                            ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
+                            ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);\r
+                        }\r
+                        else\r
+                        {\r
+                            ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,\r
+                                            2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);\r
+                            ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,\r
+                                            2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);\r
                         }\r
 \r
 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
@@ -2413,14 +2463,14 @@ irmp_ISR (void)
                     {\r
                         if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)\r
                         {\r
-                            ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
                             ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
                             ANALYZE_NEWLINE ();\r
                             irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);\r
                         }\r
                         else if (! last_value)  // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
                         {\r
-                            ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
                             ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
                             ANALYZE_NEWLINE ();\r
@@ -2442,7 +2492,7 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
                     if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
                     {\r
-                        ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                        ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
                         if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)\r
                         {                                                       // pause timings correct for "1"?\r
@@ -2462,7 +2512,7 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
                     if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)\r
                     {\r
-                        ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                        ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
                         if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)\r
                         {                                                       // pause timings correct for "1"?\r
@@ -2515,7 +2565,8 @@ irmp_ISR (void)
                         }\r
                         else\r
                         {\r
-                            ANALYZE_PRINTF ("error: stop bit timing wrong\n");\r
+                            ANALYZE_PRINTF ("error: stop bit timing wrong, irmp_bit = %d, irmp_pulse_time = %d, pulse_0_len_min = %d, pulse_0_len_max = %d\n",\r
+                                            irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
 \r
 //                          irmp_busy_flag = FALSE;\r
                             irmp_start_bit_detected = 0;                        // wait for another start bit...\r
@@ -2640,7 +2691,7 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
                             else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17))      // it was a JVC stop bit\r
                             {\r
-                                ANALYZE_PRINTF ("Switching to JVC protocol\n");\r
+                                ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
                                 irmp_param.stop_bit     = TRUE;                                     // set flag\r
                                 irmp_param.protocol     = IRMP_JVC_PROTOCOL;                        // switch protocol\r
                                 irmp_param.complete_len = irmp_bit;                                 // patch length: 16 or 17\r
@@ -2662,14 +2713,14 @@ irmp_ISR (void)
                                 //        0123456789ABC0123456789ABC0123456701234567\r
                                 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
                                 // NEC:   AAAAAAAAaaaaaaaaCCCCCCCCcccccccc\r
-                                irmp_tmp_address        |= (irmp_tmp_address2 & 0x0007) << 12;\r
+                                irmp_tmp_address        |= (irmp_tmp_address2 & 0x0007) << 13;      // fm 2012-02-13: 12 -> 13\r
                                 irmp_tmp_command        = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);\r
                             }\r
 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
 #if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
-                            else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 16)  // it was a JVC stop bit\r
+                            else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17))  // it was a JVC stop bit\r
                             {\r
-                                ANALYZE_PRINTF ("Switching to JVC protocol\n");\r
+                                ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);\r
                                 irmp_param.stop_bit     = TRUE;                                     // set flag\r
                                 irmp_param.protocol     = IRMP_JVC_PROTOCOL;                        // switch protocol\r
                                 irmp_param.complete_len = irmp_bit;                                 // patch length: 16 or 17\r
@@ -2702,7 +2753,7 @@ irmp_ISR (void)
 \r
                 if (got_light)\r
                 {\r
-                    ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                    ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
 #if IRMP_SUPPORT_MANCHESTER == 1\r
                     if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))                                     // Manchester\r
@@ -3211,7 +3262,7 @@ irmp_ISR (void)
 #endif\r
 \r
                 {\r
-                    ANALYZE_PRINTF ("%8d code detected, length = %d\n", time_counter, irmp_bit);\r
+                    ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);\r
                     irmp_ir_detected = TRUE;\r
 \r
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
@@ -3295,6 +3346,8 @@ irmp_ISR (void)
                                 ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);\r
                                 irmp_ir_detected = FALSE;\r
                             }\r
+\r
+                            irmp_flags |= genre2;      // write the genre2 bits into MSB of the flag byte\r
                         }\r
 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
 \r
@@ -3765,7 +3818,7 @@ next_tick (void)
 \r
             if (verbose)\r
             {\r
-                printf ("%8d ", time_counter);\r
+                printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);\r
             }\r
 \r
             if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r