]> cloudbase.mooo.com Git - irmp.git/blobdiff - irsnd.c
corrected additional bit handling in SIRCS protocol
[irmp.git] / irsnd.c
diff --git a/irsnd.c b/irsnd.c
index 2df0b02a529ce6cb736bef24e8fc8807a272f2b2..efae8e4e6288adb2afeb1a397f961e2547799960 100644 (file)
--- a/irsnd.c
+++ b/irsnd.c
@@ -3,7 +3,7 @@
  *\r
  * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: irsnd.c,v 1.16 2010/06/08 23:34:14 fm Exp $\r
+ * $Id: irsnd.c,v 1.28 2011/01/13 15:54:57 fm Exp $\r
  *\r
  * This program is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
@@ -26,6 +26,9 @@
 \r
 #ifdef WIN32                                                                 // test/debug on windows\r
 #include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
 #define F_CPU 8000000L\r
 typedef unsigned char    uint8_t;\r
 typedef unsigned short    uint16_t;\r
@@ -51,6 +54,12 @@ typedef unsigned short    uint16_t;
 #include "irsndconfig.h"\r
 #include "irsnd.h"\r
 \r
+#if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r
+typedef uint16_t    IRSND_PAUSE_LEN;\r
+#else\r
+typedef uint8_t     IRSND_PAUSE_LEN;\r
+#endif\r
+\r
 #define SIRCS_START_BIT_PULSE_LEN               (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME + 0.5)\r
 #define SIRCS_START_BIT_PAUSE_LEN               (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME + 0.5)\r
 #define SIRCS_1_PULSE_LEN                       (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME + 0.5)\r
@@ -84,6 +93,14 @@ typedef unsigned short    uint16_t;
 #define MATSUSHITA_0_PAUSE_LEN                  (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME + 0.5)\r
 #define MATSUSHITA_FRAME_REPEAT_PAUSE_LEN       (uint16_t)(F_INTERRUPTS * MATSUSHITA_FRAME_REPEAT_PAUSE_TIME + 0.5)         // use uint16_t!\r
 \r
+#define KASEIKYO_START_BIT_PULSE_LEN            (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME + 0.5)\r
+#define KASEIKYO_START_BIT_PAUSE_LEN            (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME + 0.5)\r
+#define KASEIKYO_PULSE_LEN                      (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME + 0.5)\r
+#define KASEIKYO_1_PAUSE_LEN                    (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME + 0.5)\r
+#define KASEIKYO_0_PAUSE_LEN                    (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME + 0.5)\r
+#define KASEIKYO_AUTO_REPETITION_PAUSE_LEN      (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5)        // use uint16_t!\r
+#define KASEIKYO_FRAME_REPEAT_PAUSE_LEN         (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5)           // use uint16_t!\r
+\r
 #define RECS80_START_BIT_PULSE_LEN              (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5)\r
 #define RECS80_START_BIT_PAUSE_LEN              (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5)\r
 #define RECS80_PULSE_LEN                        (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5)\r
@@ -160,6 +177,29 @@ typedef unsigned short    uint16_t;
 #define FDC_0_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5)\r
 #define FDC_FRAME_REPEAT_PAUSE_LEN              (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5)                // use uint16_t!\r
 \r
+#define RCCAR_START_BIT_PULSE_LEN               (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5)\r
+#define RCCAR_START_BIT_PAUSE_LEN               (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5)\r
+#define RCCAR_PULSE_LEN                         (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5)\r
+#define RCCAR_1_PAUSE_LEN                       (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5)\r
+#define RCCAR_0_PAUSE_LEN                       (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5)\r
+#define RCCAR_FRAME_REPEAT_PAUSE_LEN            (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5)              // use uint16_t!\r
+\r
+#define JVC_START_BIT_PULSE_LEN                 (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME + 0.5)\r
+#define JVC_START_BIT_PAUSE_LEN                 (uint8_t)(F_INTERRUPTS * JVC_START_BIT_PAUSE_TIME + 0.5)\r
+#define JVC_REPEAT_START_BIT_PAUSE_LEN          (uint8_t)(F_INTERRUPTS * JVC_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r
+#define JVC_PULSE_LEN                           (uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME + 0.5)\r
+#define JVC_1_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME + 0.5)\r
+#define JVC_0_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME + 0.5)\r
+#define JVC_FRAME_REPEAT_PAUSE_LEN              (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME + 0.5)                // use uint16_t!\r
+\r
+#define NIKON_START_BIT_PULSE_LEN               (uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME + 0.5)\r
+#define NIKON_START_BIT_PAUSE_LEN               (uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME + 0.5)\r
+#define NIKON_REPEAT_START_BIT_PAUSE_LEN        (uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME + 0.5)\r
+#define NIKON_PULSE_LEN                         (uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME + 0.5)\r
+#define NIKON_1_PAUSE_LEN                       (uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME + 0.5)\r
+#define NIKON_0_PAUSE_LEN                       (uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME + 0.5)\r
+#define NIKON_FRAME_REPEAT_PAUSE_LEN            (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME + 0.5)                // use uint16_t!\r
+\r
 static volatile uint8_t                         irsnd_busy;\r
 static volatile uint8_t                         irsnd_protocol;\r
 static volatile uint8_t                         irsnd_buffer[6];\r
@@ -275,8 +315,12 @@ bitsrevervse (uint16_t x, uint8_t len)
 }\r
 \r
 \r
+#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r
+static uint8_t  sircs_additional_bitlen;\r
+#endif // IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r
+\r
 uint8_t\r
-irsnd_send_data (IRMP_DATA * irmp_data_p)\r
+irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait)\r
 {\r
 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r
     static uint8_t  toggle_bit_recs80;\r
@@ -286,13 +330,23 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
 #endif\r
 #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r
     static uint8_t  toggle_bit_rc5;\r
+#endif\r
+#if IRSND_SUPPORT_RC5_PROTOCOL == 1\r
+    static uint8_t  toggle_bit_rc6;\r
 #endif\r
     uint16_t        address;\r
     uint16_t        command;\r
 \r
-    while (irsnd_busy)\r
+    if (do_wait)\r
+    {\r
+        while (irsnd_busy)\r
+        {\r
+            // do nothing;\r
+        }\r
+    }\r
+    else if (irsnd_busy)\r
     {\r
-        ;\r
+        return (FALSE);\r
     }\r
 \r
     irsnd_protocol  = irmp_data_p->protocol;\r
@@ -303,17 +357,57 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
 #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1\r
         case IRMP_SIRCS_PROTOCOL:\r
         {\r
-            command = bitsrevervse (irmp_data_p->command, SIRCS_MINIMUM_DATA_LEN);\r
+            uint8_t  sircs_additional_command_len;\r
+            uint8_t  sircs_additional_address_len;\r
+\r
+            sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8;                             // additional bitlen\r
 \r
-            irsnd_buffer[0] = (command & 0x0FF0) >> 4;                                                         // CCCCCCCC\r
-            irsnd_buffer[1] = (command & 0x000F) << 4;                                                         // CCCC0000\r
+            if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN)\r
+            {\r
+                sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN;\r
+                sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN);\r
+            }\r
+            else\r
+            {\r
+                sircs_additional_command_len = sircs_additional_bitlen;\r
+                sircs_additional_address_len = 0;\r
+            }\r
+\r
+            command = bitsrevervse (irmp_data_p->command, 15);\r
+\r
+            irsnd_buffer[0] = (command & 0x7F80) >> 7;                                                  // CCCCCCCC\r
+            irsnd_buffer[1] = (command & 0x007F) << 1;                                                  // CCCC****\r
+\r
+            if (sircs_additional_address_len > 0)\r
+            {\r
+                address = bitsrevervse (irmp_data_p->address, 5);\r
+                irsnd_buffer[1] |= (address & 0x0010) >> 4;\r
+                irsnd_buffer[2] =  (address & 0x000F) << 4;\r
+            }\r
             irsnd_busy      = TRUE;\r
             break;\r
         }\r
 #endif\r
 #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r
-        case IRMP_NEC_PROTOCOL:\r
         case IRMP_APPLE_PROTOCOL:\r
+        {\r
+            command = irmp_data_p->command | (irmp_data_p->address << 8);                               // store address as ID in upper byte of command\r
+            address = 0x87EE;                                                                           // set fixed NEC-lookalike address (customer ID of apple)\r
+\r
+            address = bitsrevervse (address, NEC_ADDRESS_LEN);\r
+            command = bitsrevervse (command, NEC_COMMAND_LEN);\r
+\r
+            irsnd_protocol = IRMP_NEC_PROTOCOL;                                                         // APPLE protocol is NEC with id instead of inverted command\r
+\r
+            irsnd_buffer[0] = (address & 0xFF00) >> 8;                                                  // AAAAAAAA\r
+            irsnd_buffer[1] = (address & 0x00FF);                                                       // AAAAAAAA\r
+            irsnd_buffer[2] = (command & 0xFF00) >> 8;                                                  // CCCCCCCC\r
+            irsnd_buffer[3] = (command & 0x00FF);                                                       // CCCCCCCC\r
+\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+        case IRMP_NEC_PROTOCOL:\r
         {\r
             address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN);\r
             command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN);\r
@@ -322,12 +416,8 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
             irsnd_buffer[1] = (address & 0x00FF);                                                               // AAAAAAAA\r
             irsnd_buffer[2] = (command & 0xFF00) >> 8;                                                          // CCCCCCCC\r
 \r
-            if (irsnd_protocol == IRMP_APPLE_PROTOCOL)\r
-            {\r
-                irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command\r
-                irsnd_buffer[3] = 0x8B;                                                                         // 10001011\r
-            }\r
-            else\r
+            irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command\r
+            irsnd_buffer[3] = 0x8B;                                                                         // 10001011\r
             {\r
                 irsnd_buffer[3] = ~((command & 0xFF00) >> 8);                                                   // cccccccc\r
             }\r
@@ -376,6 +466,29 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
             break;\r
         }\r
 #endif\r
+#if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r
+        case IRMP_KASEIKYO_PROTOCOL:\r
+        {\r
+            uint8_t xor;\r
+\r
+            address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN);\r
+            command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4);\r
+\r
+            xor = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F;\r
+\r
+            irsnd_buffer[0] = (address & 0xFF00) >> 8;                                                          // AAAAAAAA\r
+            irsnd_buffer[1] = (address & 0x00FF);                                                               // AAAAAAAA\r
+            irsnd_buffer[2] = xor << 4 | (command & 0x000F);                                                    // XXXXCCCC\r
+            irsnd_buffer[3] = 0 | (command & 0xF000) >> 12;                                                     // 0000CCCC\r
+            irsnd_buffer[4] = (command & 0x0FF0) >> 4;                                                          // CCCCCCCC\r
+\r
+            xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4];\r
+\r
+            irsnd_buffer[5] = xor;\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r
         case IRMP_RECS80_PROTOCOL:\r
         {\r
@@ -412,6 +525,32 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
             break;\r
         }\r
 #endif\r
+#if IRSND_SUPPORT_RC6_PROTOCOL == 1\r
+        case IRMP_RC6_PROTOCOL:\r
+        {\r
+            toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08;\r
+\r
+            irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5);                   // 1MMMTAAA, MMM = 000\r
+            irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5);    // AAAAACCC\r
+            irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3;                                               // CCCCC\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
+#if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r
+        case IRMP_RC6A_PROTOCOL:\r
+        {\r
+            toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08;\r
+\r
+            irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12);                                                // 1MMMT0AA, MMM = 110\r
+            irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ;                                                              // AAAAAAAA\r
+            irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6;    // AAAACCCC\r
+            irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4;                                                                 // CCCCCCCC\r
+            irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4;                                                                 // CCCC\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
 #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r
         case IRMP_DENON_PROTOCOL:\r
         {\r
@@ -478,7 +617,8 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
         {\r
             irsnd_buffer[0] = ((irmp_data_p->address & 0x0FFF) >> 5);                                           // SAAAAAAA\r
             irsnd_buffer[1] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x7F) >> 5);      // AAAAA0CC\r
-            irsnd_buffer[2] = (irmp_data_p->command << 3);                                                      // CCCCC0\r
+            irsnd_buffer[2] = (irmp_data_p->command << 3) | ((~irmp_data_p->command & 0x01) << 2);              // CCCCCc\r
+\r
             irsnd_busy      = TRUE;\r
             break;\r
         }\r
@@ -489,11 +629,45 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
             address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN);\r
             command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN);\r
 \r
-            irsnd_buffer[0] = (address & 0xFF00) >> 8;                                                          // AAAAAAAA\r
-            irsnd_buffer[1] = (address & 0x00FF);                                                               // AAAAAAAA\r
-            irsnd_buffer[2] = 0;                                                                                // 00000000\r
-            irsnd_buffer[3] = (command &  0x0FE0) >> 5;                                                         // 0CCCCCCC\r
-            irsnd_buffer[4] = ((command & 0x001F) << 3) | 0x07;                                                 // CCCCC111\r
+            irsnd_buffer[0] = (address & 0xFF);                                                                 // AAAAAAAA\r
+            irsnd_buffer[1] = 0;                                                                                // 00000000\r
+            irsnd_buffer[2] = 0;                                                                                // 0000RRRR\r
+            irsnd_buffer[3] = (command & 0xFF);                                                                 // CCCCCCCC\r
+            irsnd_buffer[4] = ~(command & 0xFF);                                                                // cccccccc\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
+#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r
+        case IRMP_RCCAR_PROTOCOL:\r
+        {\r
+            address = bitsrevervse (irmp_data_p->address, 2);                                                   //                            A0 A1\r
+            command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2);                               // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V\r
+\r
+            irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7);  //          C0 C1 A0 A1 D0 D1 D2 D3\r
+            irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3);                              //          D4 D5 D6 D7 V  0  0  0\r
+                                                                                                                \r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
+#if IRSND_SUPPORT_JVC_PROTOCOL == 1\r
+        case IRMP_JVC_PROTOCOL:\r
+        {\r
+            address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN);\r
+            command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN);\r
+\r
+            irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8;                              // AAAACCCC\r
+            irsnd_buffer[1] = (command & 0x00FF);                                                               // CCCCCCCC\r
+\r
+            irsnd_busy      = TRUE;\r
+            break;\r
+        }\r
+#endif\r
+#if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r
+        case IRMP_NIKON_PROTOCOL:\r
+        {\r
+            irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6;                                             // CC\r
             irsnd_busy      = TRUE;\r
             break;\r
         }\r
@@ -517,9 +691,9 @@ irsnd_ISR (void)
 {\r
     static uint8_t  current_bit = 0xFF;\r
     static uint8_t  pulse_counter;\r
-    static uint8_t  pause_counter;\r
+    static IRSND_PAUSE_LEN  pause_counter;\r
     static uint8_t  startbit_pulse_len;\r
-    static uint8_t  startbit_pause_len;\r
+    static IRSND_PAUSE_LEN  startbit_pause_len;\r
     static uint8_t  pulse_1_len;\r
     static uint8_t  pause_1_len;\r
     static uint8_t  pulse_0_len;\r
@@ -539,7 +713,7 @@ irsnd_ISR (void)
     static uint8_t  last_bit_value;\r
 #endif\r
     static uint8_t  pulse_len = 0xFF;\r
-    static uint8_t  pause_len = 0xFF;\r
+    static IRSND_PAUSE_LEN  pause_len = 0xFF;\r
 \r
     if (irsnd_busy)\r
     {\r
@@ -627,7 +801,7 @@ irsnd_ISR (void)
                         pulse_0_len                 = SIRCS_0_PULSE_LEN;\r
                         pause_0_len                 = SIRCS_PAUSE_LEN;\r
                         has_stop_bit                = SIRCS_STOP_BIT;\r
-                        complete_data_len           = SIRCS_MINIMUM_DATA_LEN;\r
+                        complete_data_len           = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen;\r
                         n_auto_repetitions          = (repeat_counter == 0) ? SIRCS_FRAMES : 1;     // 3 frames auto repetition if first frame\r
                         auto_repetition_pause_len   = SIRCS_AUTO_REPETITION_PAUSE_LEN;              // 25ms pause\r
                         repeat_frame_pause_len      = SIRCS_FRAME_REPEAT_PAUSE_LEN;\r
@@ -716,6 +890,24 @@ irsnd_ISR (void)
                         break;\r
                     }\r
 #endif\r
+#if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r
+                    case IRMP_KASEIKYO_PROTOCOL:\r
+                    {\r
+                        startbit_pulse_len          = KASEIKYO_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = KASEIKYO_START_BIT_PAUSE_LEN;\r
+                        pulse_1_len                 = KASEIKYO_PULSE_LEN;\r
+                        pause_1_len                 = KASEIKYO_1_PAUSE_LEN;\r
+                        pulse_0_len                 = KASEIKYO_PULSE_LEN;\r
+                        pause_0_len                 = KASEIKYO_0_PAUSE_LEN;\r
+                        has_stop_bit                = KASEIKYO_STOP_BIT;\r
+                        complete_data_len           = KASEIKYO_COMPLETE_DATA_LEN;\r
+                        n_auto_repetitions          = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1;  // 2 frames auto repetition if first frame\r
+                        auto_repetition_pause_len   = KASEIKYO_AUTO_REPETITION_PAUSE_LEN;           // 75 ms pause\r
+                        repeat_frame_pause_len      = KASEIKYO_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
+                        break;\r
+                    }\r
+#endif\r
 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r
                     case IRMP_RECS80_PROTOCOL:\r
                     {\r
@@ -768,6 +960,38 @@ irsnd_ISR (void)
                         break;\r
                     }\r
 #endif\r
+#if IRSND_SUPPORT_RC6_PROTOCOL == 1\r
+                    case IRMP_RC6_PROTOCOL:\r
+                    {\r
+                        startbit_pulse_len          = RC6_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = RC6_START_BIT_PAUSE_LEN;\r
+                        pulse_len                   = RC6_BIT_LEN;\r
+                        pause_len                   = RC6_BIT_LEN;\r
+                        has_stop_bit                = RC6_STOP_BIT;\r
+                        complete_data_len           = RC6_COMPLETE_DATA_LEN_SHORT;\r
+                        n_auto_repetitions          = 1;                                            // 1 frame\r
+                        auto_repetition_pause_len   = 0;\r
+                        repeat_frame_pause_len      = RC6_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_36_KHZ);\r
+                        break;\r
+                    }\r
+#endif\r
+#if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r
+                    case IRMP_RC6A_PROTOCOL:\r
+                    {\r
+                        startbit_pulse_len          = RC6_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = RC6_START_BIT_PAUSE_LEN;\r
+                        pulse_len                   = RC6_BIT_LEN;\r
+                        pause_len                   = RC6_BIT_LEN;\r
+                        has_stop_bit                = RC6_STOP_BIT;\r
+                        complete_data_len           = RC6_COMPLETE_DATA_LEN_LONG;\r
+                        n_auto_repetitions          = 1;                                            // 1 frame\r
+                        auto_repetition_pause_len   = 0;\r
+                        repeat_frame_pause_len      = RC6_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_36_KHZ);\r
+                        break;\r
+                    }\r
+#endif\r
 #if IRSND_SUPPORT_DENON_PROTOCOL == 1\r
                     case IRMP_DENON_PROTOCOL:\r
                     {\r
@@ -890,6 +1114,67 @@ irsnd_ISR (void)
                         break;\r
                     }\r
 #endif\r
+#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r
+                    case IRMP_RCCAR_PROTOCOL:\r
+                    {\r
+                        startbit_pulse_len          = RCCAR_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = RCCAR_START_BIT_PAUSE_LEN;\r
+                        complete_data_len           = RCCAR_COMPLETE_DATA_LEN;\r
+                        pulse_1_len                 = RCCAR_PULSE_LEN;\r
+                        pause_1_len                 = RCCAR_1_PAUSE_LEN;\r
+                        pulse_0_len                 = RCCAR_PULSE_LEN;\r
+                        pause_0_len                 = RCCAR_0_PAUSE_LEN;\r
+                        has_stop_bit                = RCCAR_STOP_BIT;\r
+                        n_auto_repetitions          = 1;                                            // 1 frame\r
+                        auto_repetition_pause_len   = 0;\r
+                        repeat_frame_pause_len      = RCCAR_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
+                        break;\r
+                    }\r
+#endif\r
+#if IRSND_SUPPORT_JVC_PROTOCOL == 1\r
+                    case IRMP_JVC_PROTOCOL:\r
+                    {\r
+                        if (repeat_counter != 0)                                                    // skip start bit if repetition frame\r
+                        {\r
+                            current_bit = 0;\r
+                        }\r
+\r
+                        startbit_pulse_len          = JVC_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = JVC_START_BIT_PAUSE_LEN;\r
+                        complete_data_len           = JVC_COMPLETE_DATA_LEN;\r
+                        pulse_1_len                 = JVC_PULSE_LEN;\r
+                        pause_1_len                 = JVC_1_PAUSE_LEN;\r
+                        pulse_0_len                 = JVC_PULSE_LEN;\r
+                        pause_0_len                 = JVC_0_PAUSE_LEN;\r
+                        has_stop_bit                = JVC_STOP_BIT;\r
+                        n_auto_repetitions          = 1;                                            // 1 frame\r
+                        auto_repetition_pause_len   = 0;\r
+                        repeat_frame_pause_len      = JVC_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
+\r
+                        break;\r
+                    }\r
+#endif\r
+#if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r
+                    case IRMP_NIKON_PROTOCOL:\r
+                    {\r
+                        startbit_pulse_len          = NIKON_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = 271; // NIKON_START_BIT_PAUSE_LEN;\r
+                        complete_data_len           = NIKON_COMPLETE_DATA_LEN;\r
+                        pulse_1_len                 = NIKON_PULSE_LEN;\r
+                        pause_1_len                 = NIKON_1_PAUSE_LEN;\r
+                        pulse_0_len                 = NIKON_PULSE_LEN;\r
+                        pause_0_len                 = NIKON_0_PAUSE_LEN;\r
+                        has_stop_bit                = NIKON_STOP_BIT;\r
+                        n_auto_repetitions          = 1;                                            // 1 frame\r
+                        auto_repetition_pause_len   = 0;\r
+                        repeat_frame_pause_len      = NIKON_FRAME_REPEAT_PAUSE_LEN;\r
+                        irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
+\r
+                        break;\r
+                    }\r
+#endif\r
                     default:\r
                     {\r
                         irsnd_busy = FALSE;\r
@@ -918,6 +1203,9 @@ irsnd_ISR (void)
 #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1\r
                 case IRMP_MATSUSHITA_PROTOCOL:\r
 #endif\r
+#if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1\r
+                case IRMP_KASEIKYO_PROTOCOL:\r
+#endif\r
 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1\r
                 case IRMP_RECS80_PROTOCOL:\r
 #endif\r
@@ -933,14 +1221,24 @@ irsnd_ISR (void)
 #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
                 case IRMP_BANG_OLUFSEN_PROTOCOL:\r
 #endif\r
-#if IRSND_SUPPORT_NEC_PROTOCOL == 1\r
+#if IRSND_SUPPORT_FDC_PROTOCOL == 1\r
                 case IRMP_FDC_PROTOCOL:\r
 #endif\r
+#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1\r
+                case IRMP_RCCAR_PROTOCOL:\r
+#endif\r
+#if IRSND_SUPPORT_JVC_PROTOCOL == 1\r
+                case IRMP_JVC_PROTOCOL:\r
+#endif\r
+#if IRSND_SUPPORT_NIKON_PROTOCOL == 1\r
+                case IRMP_NIKON_PROTOCOL:\r
+#endif\r
 \r
 \r
-#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1  || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \\r
-    IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || \\r
-    IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1\r
+#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1  || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 ||   \\r
+    IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \\r
+    IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 ||   \\r
+    IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1\r
                 {\r
                     if (pulse_counter == 0)\r
                     {\r
@@ -1087,6 +1385,12 @@ irsnd_ISR (void)
 #if IRSND_SUPPORT_RC5_PROTOCOL == 1\r
                 case IRMP_RC5_PROTOCOL:\r
 #endif\r
+#if IRSND_SUPPORT_RC6_PROTOCOL == 1\r
+                case IRMP_RC6_PROTOCOL:\r
+#endif\r
+#if IRSND_SUPPORT_RC6A_PROTOCOL == 1\r
+                case IRMP_RC6A_PROTOCOL:\r
+#endif\r
 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1\r
                 case IRMP_SIEMENS_PROTOCOL:\r
 #endif\r
@@ -1097,7 +1401,8 @@ irsnd_ISR (void)
                 case IRMP_NOKIA_PROTOCOL:\r
 #endif\r
 \r
-#if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+#if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \\r
+    IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
                 {\r
                     if (pulse_counter == pulse_len && pause_counter == pause_len)\r
                     {\r
@@ -1164,15 +1469,51 @@ irsnd_ISR (void)
                                 first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r
                             }\r
                         }\r
-                        else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_SIEMENS_PROTOCOL)\r
+                        else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL ||\r
+                             //     irsnd_protocol == IRMP_SIEMENS_PROTOCOL)\r
 #endif\r
                         {\r
                             if (current_bit == 0xFF)                                                    // 1 start bit\r
                             {\r
+#if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r
+                                if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL)\r
+                                {\r
+                                    pulse_len = startbit_pulse_len;\r
+                                    pause_len = startbit_pause_len;\r
+                                }\r
+#endif\r
                                 first_pulse = TRUE;\r
                             }\r
                             else                                                                        // send n'th bit\r
                             {\r
+#if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1\r
+                                if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL)\r
+                                {\r
+                                    pulse_len = RC6_BIT_LEN;\r
+                                    pause_len = RC6_BIT_LEN;\r
+\r
+                                    if (irsnd_protocol == IRMP_RC6_PROTOCOL)\r
+                                    {\r
+                                        if (current_bit == 4)                                           // toggle bit (double len)\r
+                                        {\r
+                                            pulse_len = 2 * RC6_BIT_LEN;\r
+                                            pause_len = 2 * RC6_BIT_LEN;\r
+                                        }\r
+                                    }\r
+                                    else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL)\r
+                                    {\r
+                                        if (current_bit == 4)                                           // toggle bit (double len)\r
+                                        {\r
+                                            pulse_len = 2 * RC6_BIT_LEN + RC6_BIT_LEN;                  // hack!\r
+                                            pause_len = 2 * RC6_BIT_LEN;\r
+                                        }\r
+                                        else if (current_bit == 5)                                      // toggle bit (double len)\r
+                                        {\r
+                                            pause_len = 2 * RC6_BIT_LEN;\r
+                                        }\r
+                                    }\r
+                                }\r
+#endif\r
                                 first_pulse = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? TRUE : FALSE;\r
                             }\r
 \r
@@ -1223,7 +1564,8 @@ irsnd_ISR (void)
                     }\r
                     break;\r
                 }\r
-#endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
+#endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 ||\r
+       // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1\r
 \r
                 default:\r
                 {\r
@@ -1237,6 +1579,12 @@ irsnd_ISR (void)
         {\r
             if (repeat_counter < n_repeat_frames)\r
             {\r
+#if IRSND_SUPPORT_FDC_PROTOCOL == 1\r
+                if (irsnd_protocol == IRMP_FDC_PROTOCOL)\r
+                {\r
+                    irsnd_buffer[2] |= 0x0F;\r
+                }\r
+#endif\r
                 repeat_counter++;\r
                 irsnd_busy = TRUE;\r
             }\r
@@ -1305,7 +1653,7 @@ main (int argc, char ** argv)
 \r
         irsnd_init ();\r
 \r
-        (void) irsnd_send_data (&irmp_data);\r
+        (void) irsnd_send_data (&irmp_data, TRUE);\r
 \r
         while (irsnd_busy)\r
         {\r