]> cloudbase.mooo.com Git - irmp.git/blobdiff - irsnd.c
Version 2.0.3:
[irmp.git] / irsnd.c
diff --git a/irsnd.c b/irsnd.c
index 09fa29520945bbc4c8d59ded57ae8f99d07438e3..ce93c1a16ceed81b8418afcf1a4e38e1b336aed0 100644 (file)
--- a/irsnd.c
+++ b/irsnd.c
@@ -12,7 +12,7 @@
  * ATmega164, ATmega324, ATmega644,  ATmega644P, ATmega1284\r
  * ATmega88,  ATmega88P, ATmega168,  ATmega168P, ATmega328P\r
  *\r
- * $Id: irsnd.c,v 1.41 2011/09/20 10:45:28 fm Exp $\r
+ * $Id: irsnd.c,v 1.45 2012/02/13 11:02:29 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
@@ -136,7 +136,8 @@ typedef unsigned short  uint16_t;
    || defined (__AVR_ATmega324__)   \\r
    || defined (__AVR_ATmega644__)   \\r
    || defined (__AVR_ATmega644P__)  \\r
-   || defined (__AVR_ATmega1284__)                      // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4\r
+   || defined (__AVR_ATmega1284__)  \\r
+   || defined (__AVR_ATmega1284P__)                     // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4\r
 #if IRSND_OCx == IRSND_OC2A                             // OC2A\r
 #define IRSND_PORT                              PORTD   // port D\r
 #define IRSND_DDR                               DDRD    // ddr D\r
@@ -182,6 +183,21 @@ typedef unsigned short  uint16_t;
 #else\r
 #error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h\r
 #endif // IRSND_OCx\r
+#elif defined (__AVR_ATmega8515__) \r
+#if IRSND_OCx == IRSND_OC0   \r
+#define IRSND_PORT                              PORTB   // port B\r
+#define IRSND_DDR                               DDRB    // ddr B\r
+#define IRSND_BIT                               0       // OC0\r
+#elif IRSND_OCx == IRSND_OC1A \r
+#define IRSND_PORT                              PORTD   // port D\r
+#define IRSND_DDR                               DDRD    // ddr D\r
+#define IRSND_BIT                               5       // OC1A\r
+#elif IRSND_OCx == IRSND_OC1B \r
+#define IRSND_PORT                              PORTE   // port E\r
+#define IRSND_DDR                               DDRE    // ddr E\r
+#define IRSND_BIT                               2       // OC1E\r
+#error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h\r
+#endif // IRSND_OCx\r
 \r
 #else\r
 #if !defined (unix) && !defined (WIN32)\r
@@ -713,16 +729,18 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait)
         case IRMP_KASEIKYO_PROTOCOL:\r
         {\r
             uint8_t xor;\r
+            uint16_t genre2;\r
 \r
             address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN);\r
             command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4);\r
+            genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 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[3] = (genre2 << 4) | (command & 0xF000) >> 12;                                         // ggggCCCC\r
             irsnd_buffer[4] = (command & 0x0FF0) >> 4;                                                          // CCCCCCCC\r
 \r
             xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4];\r
@@ -962,6 +980,7 @@ irsnd_stop (void)
 uint8_t\r
 irsnd_ISR (void)\r
 {\r
+    static uint8_t  send_trailer;\r
     static uint8_t  current_bit = 0xFF;\r
     static uint8_t  pulse_counter;\r
     static IRSND_PAUSE_LEN  pause_counter;\r
@@ -1061,6 +1080,12 @@ irsnd_ISR (void)
             }\r
             else\r
             {\r
+                if (send_trailer)\r
+                {\r
+                    irsnd_busy = FALSE;\r
+                    return irsnd_busy;\r
+                }\r
+\r
                 n_repeat_frames             = irsnd_repeat;\r
 \r
                 if (n_repeat_frames == IRSND_ENDLESS_REPETITION)\r
@@ -1984,6 +2009,8 @@ irsnd_ISR (void)
             }\r
             else\r
             {\r
+                irsnd_busy = TRUE;\r
+                send_trailer = TRUE;\r
                 n_repeat_frames = 0;\r
                 repeat_counter = 0;\r
             }\r
@@ -2016,7 +2043,6 @@ irsnd_ISR (void)
 int\r
 main (int argc, char ** argv)\r
 {\r
-    int         idx;\r
     int         protocol;\r
     int         address;\r
     int         command;\r
@@ -2054,11 +2080,6 @@ main (int argc, char ** argv)
             irsnd_ISR ();\r
         }\r
 \r
-        for (idx = 0; idx < 20; idx++)\r
-        {\r
-            irsnd_ISR ();\r
-        }\r
-\r
         putchar ('\n');\r
     }\r
     else\r