]> cloudbase.mooo.com Git - irmp.git/blobdiff - irsnd.c
Version 1.6.3: merged manchester decoding, changed output formats of debug modes...
[irmp.git] / irsnd.c
diff --git a/irsnd.c b/irsnd.c
index 2df0b02a529ce6cb736bef24e8fc8807a272f2b2..c2a4da771c327e9cd2514ba113faa1aed796b272 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.18 2010/06/10 21:24:50 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
@@ -153,12 +153,12 @@ typedef unsigned short    uint16_t;
 #define IRSND_FREQ_56_KHZ                       (uint8_t) ((F_CPU / 56000 / 2) - 1)\r
 #define IRSND_FREQ_455_KHZ                      (uint8_t) ((F_CPU / 455000 / 2) - 1)\r
 \r
-#define FDC_START_BIT_PULSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)\r
-#define FDC_START_BIT_PAUSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)\r
-#define FDC_PULSE_LEN                           (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)\r
-#define FDC_1_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME + 0.5)\r
-#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
+#define FDC1_START_BIT_PULSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PULSE_TIME + 0.5)\r
+#define FDC1_START_BIT_PAUSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PAUSE_TIME + 0.5)\r
+#define FDC1_PULSE_LEN                           (uint8_t)(F_INTERRUPTS * FDC1_PULSE_TIME + 0.5)\r
+#define FDC1_1_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * FDC1_1_PAUSE_TIME + 0.5)\r
+#define FDC1_0_PAUSE_LEN                         (uint8_t)(F_INTERRUPTS * FDC1_0_PAUSE_TIME + 0.5)\r
+#define FDC1_FRAME_REPEAT_PAUSE_LEN              (uint16_t)(F_INTERRUPTS * FDC1_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
@@ -276,7 +276,7 @@ bitsrevervse (uint16_t x, uint8_t len)
 \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
@@ -290,9 +290,16 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
     uint16_t        address;\r
     uint16_t        command;\r
 \r
-    while (irsnd_busy)\r
+    if (do_wait)\r
     {\r
-        ;\r
+        while (irsnd_busy)\r
+        {\r
+            // do nothing;\r
+        }\r
+    }\r
+    else if (irsnd_busy)\r
+    {\r
+        return (FALSE);\r
     }\r
 \r
     irsnd_protocol  = irmp_data_p->protocol;\r
@@ -483,11 +490,11 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
             break;\r
         }\r
 #endif\r
-#if IRSND_SUPPORT_FDC_PROTOCOL == 1\r
-        case IRMP_FDC_PROTOCOL:\r
+#if IRSND_SUPPORT_FDC1_PROTOCOL == 1\r
+        case IRMP_FDC1_PROTOCOL:\r
         {\r
-            address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN);\r
-            command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN);\r
+            address = bitsrevervse (irmp_data_p->address, FDC1_ADDRESS_LEN);\r
+            command = bitsrevervse (irmp_data_p->command, FDC1_COMMAND_LEN);\r
 \r
             irsnd_buffer[0] = (address & 0xFF00) >> 8;                                                          // AAAAAAAA\r
             irsnd_buffer[1] = (address & 0x00FF);                                                               // AAAAAAAA\r
@@ -872,20 +879,20 @@ irsnd_ISR (void)
                         break;\r
                     }\r
 #endif\r
-#if IRSND_SUPPORT_FDC_PROTOCOL == 1\r
-                    case IRMP_FDC_PROTOCOL:\r
+#if IRSND_SUPPORT_FDC1_PROTOCOL == 1\r
+                    case IRMP_FDC1_PROTOCOL:\r
                     {\r
-                        startbit_pulse_len          = FDC_START_BIT_PULSE_LEN;\r
-                        startbit_pause_len          = FDC_START_BIT_PAUSE_LEN;\r
-                        complete_data_len           = FDC_COMPLETE_DATA_LEN;\r
-                        pulse_1_len                 = FDC_PULSE_LEN;\r
-                        pause_1_len                 = FDC_1_PAUSE_LEN;\r
-                        pulse_0_len                 = FDC_PULSE_LEN;\r
-                        pause_0_len                 = FDC_0_PAUSE_LEN;\r
-                        has_stop_bit                = FDC_STOP_BIT;\r
+                        startbit_pulse_len          = FDC1_START_BIT_PULSE_LEN;\r
+                        startbit_pause_len          = FDC1_START_BIT_PAUSE_LEN;\r
+                        complete_data_len           = FDC1_COMPLETE_DATA_LEN;\r
+                        pulse_1_len                 = FDC1_PULSE_LEN;\r
+                        pause_1_len                 = FDC1_1_PAUSE_LEN;\r
+                        pulse_0_len                 = FDC1_PULSE_LEN;\r
+                        pause_0_len                 = FDC1_0_PAUSE_LEN;\r
+                        has_stop_bit                = FDC1_STOP_BIT;\r
                         n_auto_repetitions          = 1;                                            // 1 frame\r
                         auto_repetition_pause_len   = 0;\r
-                        repeat_frame_pause_len      = FDC_FRAME_REPEAT_PAUSE_LEN;\r
+                        repeat_frame_pause_len      = FDC1_FRAME_REPEAT_PAUSE_LEN;\r
                         irsnd_set_freq (IRSND_FREQ_38_KHZ);\r
                         break;\r
                     }\r
@@ -934,13 +941,13 @@ irsnd_ISR (void)
                 case IRMP_BANG_OLUFSEN_PROTOCOL:\r
 #endif\r
 #if IRSND_SUPPORT_NEC_PROTOCOL == 1\r
-                case IRMP_FDC_PROTOCOL:\r
+                case IRMP_FDC1_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
+    IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC1_PROTOCOL == 1\r
                 {\r
                     if (pulse_counter == 0)\r
                     {\r
@@ -1305,7 +1312,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