From a03ad359eac6c94c5a136e48c66b435544def63c Mon Sep 17 00:00:00 2001 From: ukw Date: Fri, 5 Oct 2012 08:12:41 +0000 Subject: [PATCH] Version 2.3.0: some timer and variable name corrections git-svn-id: svn://mikrocontroller.net/irmp@104 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- README.txt | 4 +-- irmp.c | 16 +++++------ irmpprotocols.h | 4 +-- irsnd.c | 71 ++++++++++++++++++++++++++++++++++++------------- irsndconfig.h | 4 +-- 5 files changed, 67 insertions(+), 32 deletions(-) diff --git a/README.txt b/README.txt index 3882add..de5971d 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 2.2.4 11.07.2012 -Version IRSND: 2.2.3 18.06.2012 +Version IRMP: 2.3.0 05.10.2012 +Version IRSND: 2.3.0 05.10.2012 Dokumentation: diff --git a/irmp.c b/irmp.c index 5cd0c72..6f2f994 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2012 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.127 2012/07/11 13:13:50 fm Exp $ + * $Id: irmp.c,v 1.128 2012/10/05 07:58:39 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -3120,23 +3120,23 @@ irmp_ISR (void) #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) { - uint8_t xor; + uint8_t xor_value; // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", // xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]); - xor = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4); + xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4); - if (xor != (xor_check[2] & 0x0F)) + if (xor_value != (xor_check[2] & 0x0F)) { - ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, xor_check[2] & 0x0F); + ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F); irmp_ir_detected = FALSE; } - xor = xor_check[2] ^ xor_check[3] ^ xor_check[4]; + xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4]; - if (xor != xor_check[5]) + if (xor_value != xor_check[5]) { - ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]); + ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]); irmp_ir_detected = FALSE; } diff --git a/irmpprotocols.h b/irmpprotocols.h index 89b6226..dd7bcba 100644 --- a/irmpprotocols.h +++ b/irmpprotocols.h @@ -5,7 +5,7 @@ * * Copyright (c) 2012 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpprotocols.h,v 1.5 2012/07/11 12:44:30 fm Exp $ + * $Id: irmpprotocols.h,v 1.6 2012/10/05 07:58:39 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 @@ -484,7 +484,7 @@ typedef uint8_t PAUSE_LEN; #define THOMSON_FLAGS 0 // flags #define BOSE_START_BIT_PULSE_TIME 1060.0e-6 // 1060 usec pulse -#define BOSE_START_BIT_PAUSE_TIME 1430.0e-6 // 1430 usec pause +#define BOSE_START_BIT_PAUSE_TIME 1425.0e-6 // 1425 usec pause #define BOSE_PULSE_TIME 550.0e-6 // 550 usec pulse #define BOSE_1_PAUSE_TIME 1425.0e-6 // 1425 usec pause #define BOSE_0_PAUSE_TIME 437.0e-6 // 437 usec pause diff --git a/irsnd.c b/irsnd.c index caac904..ad14dd8 100644 --- a/irsnd.c +++ b/irsnd.c @@ -13,7 +13,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.59 2012/06/18 09:00:46 fm Exp $ + * $Id: irsnd.c,v 1.60 2012/10/05 07:58:39 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 @@ -24,6 +24,10 @@ #include "irsnd.h" +#ifndef F_CPU +# error F_CPU unkown +#endif + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * ATtiny pin definition of OC0A / OC0B * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B @@ -306,14 +310,19 @@ # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000) # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000) #else // AVR +# if F_CPU >= 16000000L +# define AVR_PRESCALER 8 +# else +# define AVR_PRESCALER 1 +# endif # define IRSND_FREQ_TYPE uint8_t -# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / 2) - 1) -# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / 2) - 1) -# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / 2) - 1) -# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / 2) - 1) -# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / 2) - 1) -# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / 2) - 1) -# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2) - 1) +# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 30000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 32000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 36000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 38000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 40000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 56000 / AVR_PRESCALER / 2) - 1) +# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) ((F_CPU / 455000 / AVR_PRESCALER / 2) - 1) #endif #define FDC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5) @@ -366,7 +375,6 @@ static void (*irsnd_callback_ptr) (uint8_t); /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Switch PWM on - * @details Switches PWM on with a narrow spike on all 3 channels -> leds glowing *--------------------------------------------------------------------------------------------------------------------------------------------------- */ static void @@ -605,16 +613,32 @@ irsnd_init (void) # if IRSND_OCx == IRSND_OC2 // use OC2 TCCR2 = (1<address, KASEIKYO_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4); genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4); - xor = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; + xor_value = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = xor << 4 | (command & 0x000F); // XXXXCCCC + irsnd_buffer[2] = xor_value << 4 | (command & 0x000F); // XXXXCCCC irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC - xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; + xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; - irsnd_buffer[5] = xor; + irsnd_buffer[5] = xor_value; irsnd_busy = TRUE; break; } @@ -2145,6 +2169,8 @@ irsnd_ISR (void) } else { + // printf ("current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); + if (pause_counter < pause_len) { if (pause_counter == 0) @@ -2263,6 +2289,15 @@ main (int argc, char ** argv) } putchar ('\n'); + + (void) irsnd_send_data (&irmp_data, TRUE); + + while (irsnd_busy) + { + irsnd_ISR (); + } + + putchar ('\n'); } else { diff --git a/irsndconfig.h b/irsndconfig.h index 59ecd41..46e33be 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -5,7 +5,7 @@ * * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.40 2012/06/18 09:00:46 fm Exp $ + * $Id: irsndconfig.h,v 1.41 2012/10/05 07:58:39 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -48,7 +48,7 @@ #define IRSND_SUPPORT_DENON_PROTOCOL 1 // DENON, Sharp >= 10000 ~200 bytes // more protocols, enable here! Enable Remarks F_INTERRUPTS Program Space -#define IRSND_SUPPORT_RC5_PROTOCOL 0 // RC5 >= 10000 ~150 bytes +#define IRSND_SUPPORT_RC5_PROTOCOL 1 // RC5 >= 10000 ~150 bytes #define IRSND_SUPPORT_RC6_PROTOCOL 0 // RC6 >= 10000 ~250 bytes #define IRSND_SUPPORT_RC6A_PROTOCOL 0 // RC6A >= 10000 ~250 bytes #define IRSND_SUPPORT_JVC_PROTOCOL 0 // JVC >= 10000 ~150 bytes -- 2.39.2