summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorukw2010-06-10 10:04:01 +0000
committerukw2010-06-10 10:04:01 +0000
commit879b06c217259fbe72821796716ad23834248f01 (patch)
tree864100011cbe7c316bdd0f4459add81ba2f3fc10
parentb5ea7869b5946d1dcf8a586d8e0d081cde940989 (diff)
downloadirmp-879b06c217259fbe72821796716ad23834248f01.zip
Version 1.6.1: changed interfaces of irmp_ISR(), irsnd_send_data(), changed debug output of silent, normal and verbose modes, changed uart routines for more portability
git-svn-id: svn://mikrocontroller.net/irmp@22 aeb2e35e-bfc4-4214-b83c-9e8de998ed28
-rw-r--r--IR-Data/test-suite.sh10
-rw-r--r--README.txt4
-rw-r--r--irmp.aps2
-rw-r--r--irmp.c151
-rw-r--r--irmp.h4
-rw-r--r--irmpconfig.h8
-rw-r--r--irsnd.c17
-rw-r--r--irsnd.h4
-rw-r--r--irsndmain.c2
-rw-r--r--main.c4
10 files changed, 135 insertions, 71 deletions
diff --git a/IR-Data/test-suite.sh b/IR-Data/test-suite.sh
index a54440c..da04f68 100644
--- a/IR-Data/test-suite.sh
+++ b/IR-Data/test-suite.sh
@@ -8,7 +8,7 @@
#
# Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de
#
-# $Id: test-suite.sh,v 1.9 2010/06/08 22:22:13 fm Exp $
+# $Id: test-suite.sh,v 1.10 2010/06/09 12:04:04 fm Exp $
#----------------------------------------------------------------------------
for j in \
@@ -50,9 +50,9 @@ for j in \
sharp-denon2.txt
do
echo "testing $j ..."
- if ../irmp < $j | grep -q error
+ if ../irmp -v < $j | grep -q error
then
- ../irmp < $j | grep error
+ ../irmp -v < $j | grep error
echo "test failed"
exit 1
fi
@@ -65,9 +65,9 @@ for j in \
fdc-15kHz.txt
do
echo "testing $j ..."
- if ../irmp-15kHz < $j | grep -q error
+ if ../irmp-15kHz -v < $j | grep -q error
then
- ../irmp-15kHz < $j | grep error
+ ../irmp-15kHz -v < $j | grep error
echo "test failed"
exit 1
fi
diff --git a/README.txt b/README.txt
index bef0a1f..4eb7581 100644
--- a/README.txt
+++ b/README.txt
@@ -1,8 +1,8 @@
IRMP - Infrared Multi Protocol Decoder
--------------------------------------
-Version IRMP: 1.6.0 09.06.2010
-Version IRSND: 1.6.0 09.06.2010
+Version IRMP: 1.6.1 10.06.2010
+Version IRSND: 1.6.1 10.06.2010
Dokumentation:
diff --git a/irmp.aps b/irmp.aps
index 9ad8f4b..664e6c2 100644
--- a/irmp.aps
+++ b/irmp.aps
@@ -1 +1 @@
-<AVRStudio><MANAGEMENT><ProjectName>irmp</ProjectName><Created>07-Jan-2010 20:23:49</Created><LastEdit>29-Mar-2010 11:32:13</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>07-Jan-2010 20:23:49</Created><Version>4</Version><Build>4, 18, 0, 670</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\irmp.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\avr\irmp\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega88.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>irmp.c</SOURCEFILE><HEADERFILE>irmp.h</HEADERFILE><HEADERFILE>irmpconfig.h</HEADERFILE><OTHERFILE>default\irmp.lss</OTHERFILE><OTHERFILE>default\irmp.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega88</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>irmp.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\Program Files\WinAVR-20090313\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\Program Files\WinAVR-20090313\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>1</Status></File00000><File00001><FileId>00001</FileId><FileName>irmp.c</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>irmp.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>irmpconfig.h</FileName><Status>1</Status></File00003></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
+<AVRStudio><MANAGEMENT><ProjectName>irmp</ProjectName><Created>07-Jan-2010 20:23:49</Created><LastEdit>09-Jun-2010 11:02:51</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>07-Jan-2010 20:23:49</Created><Version>4</Version><Build>4, 18, 0, 670</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\irmp.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\avr\irmp\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega88.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>irmp.c</SOURCEFILE><HEADERFILE>irmp.h</HEADERFILE><HEADERFILE>irmpconfig.h</HEADERFILE><OTHERFILE>default\irmp.lss</OTHERFILE><OTHERFILE>default\irmp.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega88</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>irmp.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\Program Files\WinAVR-20090313\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\Program Files\WinAVR-20090313\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>1</Status></File00000><File00001><FileId>00001</FileId><FileName>irmp.c</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>irmp.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>irmpconfig.h</FileName><Status>1</Status></File00003></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
diff --git a/irmp.c b/irmp.c
index 4e45d51..774980d 100644
--- a/irmp.c
+++ b/irmp.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: irmp.c,v 1.35 2010/06/08 22:22:36 fm Exp $
+ * $Id: irmp.c,v 1.39 2010/06/10 10:09:47 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -521,25 +521,60 @@ typedef unsigned int16 uint16_t;
#define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!
#ifdef DEBUG
-#define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } }
-#define DEBUG_PRINTF(...) { if (! silent) { printf (__VA_ARGS__); } }
+#define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } }
+#define DEBUG_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }
+#define DEBUG_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }
+#define DEBUG_NEWLINE() { if (verbose) { putchar ('\n'); } }
static int silent;
static int time_counter;
+static int verbose;
#else
#define DEBUG_PUTCHAR(a)
+#define DEBUG_ONLY_NORMAL_PUTCHAR(a)
#define DEBUG_PRINTF(...)
+#define DEBUG_NEWLINE()
#endif
#if IRMP_LOGGING == 1
-#define UART_BAUD 9600L
+#define BAUD 9600L
+#include <util/setbaud.h>
+
+#ifdef UBRR0H
+
+#define UART0_UBRRH UBRR0H
+#define UART0_UBRRL UBRR0L
+#define UART0_UCSRA UCSR0A
+#define UART0_UCSRB UCSR0B
+#define UART0_UCSRC UCSR0C
+#define UART0_UDRE_BIT_VALUE (1<<UDRE0)
+#define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)
+#define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)
+#ifdef URSEL0
+#define UART0_URSEL_BIT_VALUE (1<<URSEL0)
+#else
+#define UART0_URSEL_BIT_VALUE (0)
+#endif
+#define UART0_TXEN_BIT_VALUE (1<<TXEN0)
+#define UART0_UDR_BIT_VALUE (1<<UDR0)
+
+#else
-// calculate real baud rate:
-#define UBRR_VAL ((F_CPU + UART_BAUD * 8) / (UART_BAUD * 16) - 1) // round
-#define BAUD_REAL (F_CPU / (16 * (UBRR_VAL + 1))) // real baudrate
-#define BAUD_ERROR ((BAUD_REAL * 1000) / UART_BAUD) // error in promille
+#define UART0_UBRRH UBRRH
+#define UART0_UBRRL UBRRL
+#define UART0_UCSRA UCSRA
+#define UART0_UCSRB UCSRB
+#define UART0_UCSRC UCSRC
+#define UART0_UDRE_BIT_VALUE (1<<UDRE)
+#define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)
+#define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)
+#ifdef URSEL
+#define UART0_URSEL_BIT_VALUE (1<<URSEL)
+#else
+#define UART0_URSEL_BIT_VALUE (0)
+#endif
+#define UART0_TXEN_BIT_VALUE (1<<TXEN)
+#define UART0_UDR_BIT_VALUE (1<<UDR)
-#if ((BAUD_ERROR < 990) || (BAUD_ERROR > 1010))
-# error Error of baud rate of RS232 UARTx is more than 1%. That is too high!
#endif
/*---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -550,9 +585,17 @@ static int time_counter;
void
irmp_uart_init (void)
{
- UCSR0B |= (1<<TXEN0); // activate UART0 TX
- UBRR0H = UBRR_VAL >> 8; // store baudrate (upper byte)
- UBRR0L = UBRR_VAL & 0xFF; // store baudrate (lower byte)
+ UART0_UBRRH = UBRRH_VALUE; // set baud rate
+ UART0_UBRRL = UBRRL_VALUE;
+
+#if USE_2X
+ UART0_UCSRA = (1<<U2X);
+#else
+ UART0_UCSRA = 0;
+#endif
+
+ UART0_UCSRC = UART0_UCSZ1_BIT_VALUE | UART0_UCSZ0_BIT_VALUE | UART0_URSEL_BIT_VALUE;
+ UART0_UCSRB |= UART0_TXEN_BIT_VALUE; // enable UART TX
}
/*---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -564,12 +607,12 @@ irmp_uart_init (void)
void
irmp_uart_putc (unsigned char ch)
{
- while (!(UCSR0A & (1<<UDRE0)))
+ while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE))
{
;
}
- UDR0 = ch;
+ UART0_UDR = ch;
}
/*---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1206,7 +1249,7 @@ irmp_store_bit (uint8_t value)
* @details ISR routine, called 10000 times per second
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/
-void
+uint8_t
irmp_ISR (void)
{
static uint8_t irmp_start_bit_detected; // flag: start bit detected
@@ -1287,6 +1330,7 @@ irmp_ISR (void)
if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
{ // yes...
DEBUG_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit
irmp_pulse_time = 0;
irmp_pause_time = 0;
@@ -1565,14 +1609,14 @@ irmp_ISR (void)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
}
else if (! last_value)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
}
}
@@ -1586,14 +1630,14 @@ irmp_ISR (void)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
}
else if (! last_value)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
}
}
@@ -1607,14 +1651,14 @@ irmp_ISR (void)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
}
else if (! last_value)
{
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
}
}
@@ -1629,13 +1673,13 @@ irmp_ISR (void)
if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)
{ // pause timings correct for "1"?
DEBUG_PUTCHAR ('1'); // yes, store 1
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
}
else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
{ // pause timings correct for "0"?
DEBUG_PUTCHAR ('0'); // yes, store 0
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
}
}
@@ -1767,6 +1811,7 @@ irmp_ISR (void)
else
{
DEBUG_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // wait for another start bit...
irmp_pulse_time = 0;
@@ -1792,7 +1837,7 @@ irmp_ISR (void)
DEBUG_PUTCHAR ('1');
irmp_store_bit (1);
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
last_value = 0;
}
@@ -1812,7 +1857,7 @@ irmp_ISR (void)
}
DEBUG_PUTCHAR (rc5_value + '0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (rc5_value);
}
@@ -1831,7 +1876,7 @@ irmp_ISR (void)
DEBUG_PUTCHAR ('0');
irmp_store_bit (0);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
last_value = 1;
}
@@ -1851,7 +1896,7 @@ irmp_ISR (void)
}
DEBUG_PUTCHAR (grundig_value + '0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (grundig_value);
}
@@ -1878,7 +1923,7 @@ irmp_ISR (void)
DEBUG_PUTCHAR ('0');
irmp_store_bit (0);
last_value = 0;
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
break;
default:
@@ -1887,7 +1932,7 @@ irmp_ISR (void)
DEBUG_PUTCHAR ('0');
irmp_store_bit (0);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
last_value = 1;
}
@@ -1911,7 +1956,7 @@ irmp_ISR (void)
}
DEBUG_PUTCHAR (rc5_value + '0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (rc5_value);
}
@@ -1932,7 +1977,7 @@ irmp_ISR (void)
DEBUG_PUTCHAR ('0');
irmp_store_bit (0);
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
last_value = 1;
}
@@ -1952,7 +1997,7 @@ irmp_ISR (void)
}
DEBUG_PUTCHAR (siemens_value + '0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (siemens_value);
}
@@ -1983,14 +2028,14 @@ irmp_ISR (void)
if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)
{
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
wait_for_space = 0;
}
else
{
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
wait_for_space = 0;
}
@@ -2000,6 +2045,7 @@ irmp_ISR (void)
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2024,6 +2070,7 @@ irmp_ISR (void)
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2040,6 +2087,7 @@ irmp_ISR (void)
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2049,7 +2097,7 @@ irmp_ISR (void)
if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)
{ // pulse & pause timings correct for "1"?
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
last_value = 1;
wait_for_space = 0;
@@ -2057,7 +2105,7 @@ irmp_ISR (void)
else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)
{ // pulse & pause timings correct for "0"?
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
last_value = 0;
wait_for_space = 0;
@@ -2065,13 +2113,14 @@ irmp_ISR (void)
else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)
{
DEBUG_PUTCHAR (last_value + '0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (last_value);
wait_for_space = 0;
}
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2080,6 +2129,7 @@ irmp_ISR (void)
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2091,7 +2141,7 @@ irmp_ISR (void)
irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
{ // pulse & pause timings correct for "1"?
DEBUG_PUTCHAR ('1');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (1);
wait_for_space = 0;
}
@@ -2099,13 +2149,14 @@ irmp_ISR (void)
irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)
{ // pulse & pause timings correct for "0"?
DEBUG_PUTCHAR ('0');
- DEBUG_PUTCHAR ('\n');
+ DEBUG_NEWLINE ();
irmp_store_bit (0);
wait_for_space = 0;
}
else
{ // timing incorrect!
DEBUG_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
irmp_start_bit_detected = 0; // reset flags and wait for next start bit
irmp_pause_time = 0;
}
@@ -2252,6 +2303,10 @@ irmp_ISR (void)
repetition_counter = 0;
}
+ else
+ {
+ DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
+ }
irmp_start_bit_detected = 0; // and wait for next start bit
irmp_tmp_command = 0;
@@ -2260,6 +2315,7 @@ irmp_ISR (void)
}
}
}
+ return (irmp_ir_detected);
}
#ifdef DEBUG
@@ -2320,7 +2376,6 @@ int
main (int argc, char ** argv)
{
int i;
- int verbose = FALSE;
int analyze = FALSE;
int ch;
int last_ch = 0;
@@ -2371,7 +2426,6 @@ main (int argc, char ** argv)
else if (! strcmp (argv[1], "-a"))
{
analyze = TRUE;
- verbose = TRUE;
}
else if (! strcmp (argv[1], "-s"))
{
@@ -2392,7 +2446,7 @@ main (int argc, char ** argv)
{
if (last_ch != ch)
{
- if (verbose && pause > 0)
+ if (analyze && pause > 0)
{
printf ("pause: %d\n", pause);
@@ -2457,7 +2511,7 @@ main (int argc, char ** argv)
{
if (last_ch != ch)
{
- if (verbose)
+ if (analyze)
{
printf ("pulse: %d ", pulse);
@@ -2514,7 +2568,7 @@ main (int argc, char ** argv)
{
IRMP_PIN = 0xff;
- if (verbose && pause > 0)
+ if (analyze && pause > 0)
{
printf ("pause: %d\n", pause);
}
@@ -2524,7 +2578,7 @@ main (int argc, char ** argv)
{
for (i = 0; i < 8000; i++) // newline: long pause of 800 msec
{
- irmp_ISR ();
+ (void) irmp_ISR ();
}
}
first_pulse = TRUE;
@@ -2549,12 +2603,13 @@ main (int argc, char ** argv)
if (! analyze)
{
- irmp_ISR ();
+ (void) irmp_ISR ();
}
if (irmp_get_data (&irmp_data))
{
- printf ("protcol = %d, address = 0x%04x, code = 0x%04x, flags = 0x%02x\n",
+ DEBUG_ONLY_NORMAL_PUTCHAR (' ');
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",
irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);
}
}
diff --git a/irmp.h b/irmp.h
index ba3beb7..f952637 100644
--- a/irmp.h
+++ b/irmp.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: irmp.h,v 1.26 2010/06/08 23:34:14 fm Exp $
+ * $Id: irmp.h,v 1.27 2010/06/10 10:05:56 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -313,7 +313,7 @@ extern uint8_t irmp_get_data (IRMP_DATA *);
* ISR routine
* @details ISR routine, called 10000 times per second
*/
-extern void irmp_ISR (void);
+extern uint8_t irmp_ISR (void);
#ifdef __cplusplus
}
diff --git a/irmpconfig.h b/irmpconfig.h
index 1f074ae..8d8b7d4 100644
--- a/irmpconfig.h
+++ b/irmpconfig.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: irmpconfig.h,v 1.11 2010/06/08 23:34:14 fm Exp $
+ * $Id: irmpconfig.h,v 1.12 2010/06/10 10:09:47 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -22,7 +22,7 @@
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/
#ifndef F_INTERRUPTS
-#define F_INTERRUPTS 10000 // interrupts per second
+#define F_INTERRUPTS 10000 // interrupts per second, min: 10000, max: 15000
#endif
/*---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -81,6 +81,8 @@
* Set IRMP_LOGGING to 1 if want to log data to UART with 9600Bd
*---------------------------------------------------------------------------------------------------------------------------------------------------
*/
-#define IRMP_LOGGING 0 // 1: log IR signal (scan), 0: do not (default)
+#ifndef IRMP_LOGGING
+#define IRMP_LOGGING 0 // 1: log IR signal (scan), 0: do not (default)
+#endif
#endif /* _WC_IRMPCONFIG_H_ */
diff --git a/irsnd.c b/irsnd.c
index 2df0b02..b6138f0 100644
--- a/irsnd.c
+++ b/irsnd.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: irsnd.c,v 1.16 2010/06/08 23:34:14 fm Exp $
+ * $Id: irsnd.c,v 1.17 2010/06/10 10:05:56 fm Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -276,7 +276,7 @@ bitsrevervse (uint16_t x, uint8_t len)
uint8_t
-irsnd_send_data (IRMP_DATA * irmp_data_p)
+irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait)
{
#if IRSND_SUPPORT_RECS80_PROTOCOL == 1
static uint8_t toggle_bit_recs80;
@@ -290,9 +290,16 @@ irsnd_send_data (IRMP_DATA * irmp_data_p)
uint16_t address;
uint16_t command;
- while (irsnd_busy)
+ if (do_wait)
{
- ;
+ while (irsnd_busy)
+ {
+ // do nothing;
+ }
+ }
+ else if (irsnd_busy)
+ {
+ return (FALSE);
}
irsnd_protocol = irmp_data_p->protocol;
@@ -1305,7 +1312,7 @@ main (int argc, char ** argv)
irsnd_init ();
- (void) irsnd_send_data (&irmp_data);
+ (void) irsnd_send_data (&irmp_data, TRUE);
while (irsnd_busy)
{
diff --git a/irsnd.h b/irsnd.h
index 11f5227..b5f214b 100644
--- a/irsnd.h
+++ b/irsnd.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: irsnd.h,v 1.2 2010/04/14 13:21:39 fm Exp $
+ * $Id: irsnd.h,v 1.3 2010/06/10 10:05:56 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -36,7 +36,7 @@ extern uint8_t irsnd_is_busy (void);
* @param pointer to IRMP data structure
* @return TRUE: successful, FALSE: failed
*/
-extern uint8_t irsnd_send_data (IRMP_DATA *);
+extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);
/**
* ISR routine
diff --git a/irsndmain.c b/irsndmain.c
index 9a25c8f..c50c818 100644
--- a/irsndmain.c
+++ b/irsndmain.c
@@ -143,7 +143,7 @@ main (void)
irmp_data.command = 0x0001;
irmp_data.flags = 0;
- irsnd_send_data (&irmp_data);
+ irsnd_send_data (&irmp_data, TRUE);
_delay_ms (1000);
}
}
diff --git a/main.c b/main.c
index faab8ea..cc37574 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de
*
- * $Id: main.c,v 1.5 2010/03/29 09:33:29 fm Exp $
+ * $Id: main.c,v 1.6 2010/06/10 10:09:47 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -86,7 +86,7 @@ interrupt [TIM1_COMPA] void timer1_compa_isr(void)
ISR(TIMER1_COMPA_vect)
#endif // CODEVISION
{
- irmp_ISR(); // call irmp ISR
+ (void) irmp_ISR(); // call irmp ISR
// call other timer interrupt routines...
}