From 7644ac04e209441d89d900125995b2d398cfd4b4 Mon Sep 17 00:00:00 2001 From: ukw Date: Mon, 12 Sep 2011 07:39:26 +0000 Subject: [PATCH 1/1] version 2.0.0-pre7: added support for ATtiny84, added ISR in main.c, corrected timer1_init() for ATTiny85 git-svn-id: svn://mikrocontroller.net/irmp@77 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- README.txt | 4 +- irmp.aps | 2 +- irmp.c | 58 +++++++++++++++----- irmp.h | 6 ++- irmpconfig.h | 12 +++-- irsnd.aps | 2 +- irsnd.c | 143 ++++++++++++++++++++++++++++++++++++++++++++------ irsndconfig.h | 14 ++--- main.c | 33 ++++++++---- 9 files changed, 221 insertions(+), 53 deletions(-) diff --git a/README.txt b/README.txt index bfd1d78..5914be5 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 2.0.0-pre6 06.09.2011 -Version IRSND: 2.0.0-pre6 06.09.2011 +Version IRMP: 2.0.0-pre7 12.09.2011 +Version IRSND: 2.0.0-pre7 12.09.2011 Dokumentation: diff --git a/irmp.aps b/irmp.aps index ec97492..3e62b7f 100644 --- a/irmp.aps +++ b/irmp.aps @@ -1 +1 @@ -irmp07-Jan-2010 20:23:4906-Sep-2011 16:15:23241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irmp.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cirmp.cirmp.hirmpconfig.hdefault\irmp.lssdefault\irmp.mapdefaultNOatmega88111irmp.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20100110\bin\avr-gcc.exeC:\Program Files\WinAVR-20100110\utils\bin\make.exe00000main.c100001irmp.c100002irmp.h100003irmpconfig.h1 +irmp07-Jan-2010 20:23:4912-Sep-2011 09:33:45241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irmp.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cirmp.cirmp.hirmpconfig.hdefault\irmp.lssdefault\irmp.mapdefaultNOatmega88111irmp.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20100110\bin\avr-gcc.exeC:\Program Files\WinAVR-20100110\utils\bin\make.exe00000main.c100001irmp.c100002irmp.h100003irmpconfig.h1 diff --git a/irmp.c b/irmp.c index bf75b69..db87cc3 100644 --- a/irmp.c +++ b/irmp.c @@ -3,11 +3,19 @@ * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.106 2011/08/16 07:51:19 fm Exp $ + * $Id: irmp.c,v 1.108 2011/09/09 11:59:39 fm Exp $ * * ATMEGA88 @ 8 MHz * - * Typical manufacturers: + * Supported mikrocontrollers: + * + * ATtiny84, ATtiny85 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P + * + * Typical manufacturers of remote controls: * * SIRCS - Sony * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers @@ -696,13 +704,13 @@ typedef unsigned int16 uint16_t; #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t! #ifdef ANALYZE -#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } -#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } -#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } -#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } -static int silent; -static int time_counter; -static int verbose; +#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } +#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } +#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } +#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } +static int silent; +static int time_counter; +static int verbose; #else #define ANALYZE_PUTCHAR(a) #define ANALYZE_ONLY_NORMAL_PUTCHAR(a) @@ -710,6 +718,10 @@ static int verbose; #define ANALYZE_NEWLINE() #endif +#if IRMP_USE_CALLBACK == 1 +static void (*irmp_callback_ptr) (uint8_t); +#endif // IRMP_USE_CALLBACK == 1 + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Protocol names *--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -1027,9 +1039,9 @@ static const PROGMEM IRMP_PARAMETER nec42_param = NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 NEC42_ADDRESS_OFFSET, // address_offset: address offset - NEC42_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address + NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address NEC42_COMMAND_OFFSET, // command_offset: command offset - NEC42_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command + NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame NEC_STOP_BIT, // stop_bit: flag: frame has stop bit NEC_LSB, // lsb_first: flag: LSB first @@ -1765,6 +1777,14 @@ irmp_get_data (IRMP_DATA * irmp_data_p) // return irmp_busy_flag; // } +#if IRMP_USE_CALLBACK == 1 +void +irmp_set_callback_ptr (void (*cb)(uint8_t)) +{ + irmp_callback_ptr = cb; +} +#endif // IRMP_USE_CALLBACK == 1 + // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR() static uint16_t irmp_tmp_address; // ir address static uint16_t irmp_tmp_command; // ir command @@ -1932,6 +1952,19 @@ irmp_ISR (void) irmp_input = input(IRMP_PIN); +#if IRMP_USE_CALLBACK == 1 + if (irmp_callback_ptr) + { + static uint8_t last_inverted_input; + + if (last_inverted_input != !irmp_input) + { + (*irmp_callback_ptr) (! irmp_input); + last_inverted_input = !irmp_input; + } + } +#endif // IRMP_USE_CALLBACK == 1 + irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined if (! irmp_ir_detected) // ir code already detected? @@ -3059,9 +3092,8 @@ irmp_ISR (void) #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) { -printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX); ANALYZE_PRINTF ("Switching to NEC16 protocol\n"); - irmp_param.protocol = IRMP_NEC16_PROTOCOL; + irmp_param.protocol = IRMP_NEC16_PROTOCOL; irmp_param.address_offset = NEC16_ADDRESS_OFFSET; irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN; irmp_param.command_offset = NEC16_COMMAND_OFFSET; diff --git a/irmp.h b/irmp.h index fdb2c95..7504907 100644 --- a/irmp.h +++ b/irmp.h @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.h,v 1.64 2011/08/16 07:51:19 fm Exp $ + * $Id: irmp.h,v 1.65 2011/09/08 13:22:16 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -534,4 +534,8 @@ extern uint8_t irmp_ISR (void); extern char * irmp_protocol_names[IRMP_N_PROTOCOLS + 1]; #endif +#if IRMP_USE_CALLBACK == 1 +extern void irmp_set_callback_ptr (void (*cb)(uint8_t)); +#endif // IRSND_USE_CALLBACK == 1 + #endif /* _WC_IRMP_H_ */ diff --git a/irmpconfig.h b/irmpconfig.h index 297ec2f..5958c8f 100644 --- a/irmpconfig.h +++ b/irmpconfig.h @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpconfig.h,v 1.71 2011/08/16 07:32:39 fm Exp $ + * $Id: irmpconfig.h,v 1.74 2011/09/11 13:17:38 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -54,8 +54,8 @@ #define IRMP_SUPPORT_RC5_PROTOCOL 0 // RC5 >= 10000 ~250 bytes #define IRMP_SUPPORT_RC6_PROTOCOL 0 // RC6 & RC6A >= 10000 ~250 bytes #define IRMP_SUPPORT_JVC_PROTOCOL 0 // JVC >= 10000 ~150 bytes -#define IRMP_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 ~50 bytes -#define IRMP_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 ~150 bytes +#define IRMP_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 ~100 bytes +#define IRMP_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 ~300 bytes #define IRMP_SUPPORT_IR60_PROTOCOL 0 // IR60 (SAB2008) >= 10000 ~300 bytes #define IRMP_SUPPORT_GRUNDIG_PROTOCOL 0 // Grundig >= 10000 ~300 bytes #define IRMP_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens Gigaset >= 15000 ~550 bytes @@ -109,6 +109,12 @@ */ #define IRMP_PROTOCOL_NAMES 0 // 1: access protocol names, 0: do not (default), +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Use Callbacks to indicate input signal + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define IRMP_USE_CALLBACK 0 // flag: 0 = don't use callbacks, 1 = use callbacks, default is 0 + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * DO NOT CHANGE THE FOLLOWING LINES ! *--------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/irsnd.aps b/irsnd.aps index 1b423dc..386137e 100644 --- a/irsnd.aps +++ b/irsnd.aps @@ -1 +1 @@ -irsnd07-Jan-2010 20:23:4906-Sep-2011 16:10:48241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irsnd.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000irsndmain.cirsnd.cirmp.hirsnd.hirsndconfig.hdefault\irsnd.lssdefault\irsnd.mapdefaultNOatmega88111irsnd.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20100110\bin\avr-gcc.exeC:\Program Files\WinAVR-20100110\utils\bin\make.exe00000irsndmain.c100001irmp.h100002irsnd.c100003irsnd.h100004irsndconfig.h1 +irsnd07-Jan-2010 20:23:4907-Sep-2011 16:01:18241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irsnd.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000irsndmain.cirsnd.cirmp.hirsnd.hirsndconfig.hdefault\irsnd.lssdefault\irsnd.mapdefaultNOatmega88111irsnd.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20100110\bin\avr-gcc.exeC:\Program Files\WinAVR-20100110\utils\bin\make.exe00000irsndmain.c100001irmp.h100002irsnd.c100003irsnd.h100004irsndconfig.h1 diff --git a/irsnd.c b/irsnd.c index fbd6ded..47bea6c 100644 --- a/irsnd.c +++ b/irsnd.c @@ -3,7 +3,15 @@ * * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.c,v 1.38 2011/05/22 21:40:53 fm Exp $ + * Supported mikrocontrollers: + * + * ATtiny84, ATtiny85 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P + * + * $Id: irsnd.c,v 1.40 2011/09/09 11:59:40 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 @@ -64,7 +72,20 @@ typedef unsigned short uint16_t; * ATmega pin definition of OC2 / OC2A / OC2B / OC0 / OC0A / OC0B *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#if defined (__AVR_ATtiny85__) // ATtiny85 uses OC0A = PB0 or OC0B = PB1 +#if defined (__AVR_ATtiny84__) // ATtiny85 uses OC0A = PB2 or OC0B = PA7 +#if IRSND_OCx == IRSND_OC0A // OC0A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 2 // OC0A +#elif IRSND_OCx == IRSND_OC0B // OC0B +#define IRSND_PORT PORTA // port A +#define IRSND_DDR DDRA // ddr A +#define IRSND_BIT 7 // OC0B +#else +#error Wrong value for IRSND_OCx, choose IRSND_OC0A or IRSND_OC0B in irsndconfig.h +#endif // IRSND_OCx + +#elif defined (__AVR_ATtiny85__) // ATtiny85 uses OC0A = PB0 or OC0B = PB1 #if IRSND_OCx == IRSND_OC0A // OC0A #define IRSND_PORT PORTB // port B #define IRSND_DDR DDRB // ddr B @@ -137,10 +158,10 @@ typedef unsigned short uint16_t; #elif defined (__AVR_ATmega48__) \ || defined (__AVR_ATmega88__) \ + || defined (__AVR_ATmega88P__) \ || defined (__AVR_ATmega168__) \ || defined (__AVR_ATmega168P__) \ - || defined (__AVR_ATmega328__) \ - || defined (__AVR_ATmega328P__) // ATmega48|88|168|168P|328P uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5 + || defined (__AVR_ATmega328P__) // ATmega48|88|168|168|328 uses OC2A = PB3 or OC2B = PD3 or OC0A = PD6 or OC0B = PD5 #if IRSND_OCx == IRSND_OC2A // OC2A #define IRSND_PORT PORTB // port B #define IRSND_DDR DDRB // ddr B @@ -599,11 +620,10 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC - + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = 0x8B; // 10001011 (id) irsnd_busy = TRUE; break; } @@ -615,13 +635,35 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_NEC16_PROTOCOL == 1 + case IRMP_NEC16_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN); - irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with fix bitmask instead of inverted command - irsnd_buffer[3] = 0x8B; // 10001011 - { - irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc - } - + irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_NEC42_PROTOCOL == 1 + case IRMP_NEC42_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN); + + irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA + irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa + irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa + irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC + irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc + irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc irsnd_busy = TRUE; break; } @@ -1077,6 +1119,42 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_NEC16_PROTOCOL == 1 + case IRMP_NEC16_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif +#if IRSND_SUPPORT_NEC42_PROTOCOL == 1 + case IRMP_NEC42_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC42_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 case IRMP_SAMSUNG_PROTOCOL: { @@ -1472,6 +1550,12 @@ irsnd_ISR (void) #if IRSND_SUPPORT_NEC_PROTOCOL == 1 case IRMP_NEC_PROTOCOL: #endif +#if IRSND_SUPPORT_NEC16_PROTOCOL == 1 + case IRMP_NEC16_PROTOCOL: +#endif +#if IRSND_SUPPORT_NEC42_PROTOCOL == 1 + case IRMP_NEC42_PROTOCOL: +#endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 case IRMP_SAMSUNG_PROTOCOL: case IRMP_SAMSUNG32_PROTOCOL: @@ -1517,7 +1601,8 @@ irsnd_ISR (void) #endif -#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \ +#if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \ + IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 || \ IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 || IRSND_SUPPORT_RECS80_PROTOCOL == 1 || IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 || IRSND_SUPPORT_DENON_PROTOCOL == 1 || \ IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || \ IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 @@ -1557,6 +1642,32 @@ irsnd_ISR (void) else #endif +#if IRSND_SUPPORT_NEC16_PROTOCOL == 1 + if (irsnd_protocol == IRMP_NEC16_PROTOCOL) + { + if (current_bit < NEC16_ADDRESS_LEN) // send address bits + { + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit / 8] & (1<<(7-(current_bit % 8)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) + { + pulse_len = NEC_PULSE_LEN; + pause_len = NEC_START_BIT_PAUSE_LEN - 1; + } + else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit / 8] & (1<<(7-(cur_bit % 8)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + } + else +#endif + #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) { diff --git a/irsndconfig.h b/irsndconfig.h index eb9f1ad..2bb4414 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.22 2011/05/20 09:31:25 fm Exp $ + * $Id: irsndconfig.h,v 1.26 2011/09/11 13:17:38 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -39,12 +39,12 @@ #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 1 // RC5 >= 10000 ~150 bytes +#define IRSND_SUPPORT_RC5_PROTOCOL 0 // 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 -#define IRSND_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 DON'T CHANGE, NOT SUPPORTED YET! -#define IRSND_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 DON'T CHANGE, NOT SUPPORTED YET! +#define IRSND_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 ~150 bytes +#define IRSND_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 ~150 bytes #define IRSND_SUPPORT_IR60_PROTOCOL 0 // IR60 (SAB2008) >= 10000 DON'T CHANGE, NOT SUPPORTED YET! #define IRSND_SUPPORT_GRUNDIG_PROTOCOL 0 // Grundig >= 10000 ~300 bytes #define IRSND_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens, Gigaset >= 15000 ~150 bytes @@ -56,7 +56,7 @@ #define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 0 // Bang&Olufsen >= 10000 ~250 bytes #define IRSND_SUPPORT_RECS80_PROTOCOL 0 // RECS80 >= 20000 ~100 bytes #define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0 // RECS80EXT >= 20000 ~100 bytes -#define IRSND_SUPPORT_THOMSON_PROTOCOL 1 // Thomson >= 10000 ~250 bytes +#define IRSND_SUPPORT_THOMSON_PROTOCOL 0 // Thomson >= 10000 ~250 bytes #define IRSND_SUPPORT_NIKON_PROTOCOL 0 // NIKON >= 10000 ~150 bytes #define IRSND_SUPPORT_NETBOX_PROTOCOL 0 // Netbox keyboard >= 10000 DON'T CHANGE, NOT SUPPORTED YET! #define IRSND_SUPPORT_IMON_PROTOCOL 0 // IMON keyboard >= 10000 DON'T CHANGE, NOT SUPPORTED YET! @@ -82,8 +82,8 @@ * IRSND_OC2A = OC2A on ATmegas supporting OC2A, e.g. ATmega88 * IRSND_OC2B = OC2B on ATmegas supporting OC2B, e.g. ATmega88 * IRSND_OC0 = OC0 on ATmegas supporting OC0, e.g. ATmega162 - * IRSND_OC0A = OC0A on ATmegas/ATtinys supporting OC0A, e.g. ATtiny85 - * IRSND_OC0B = OC0B on ATmegas/ATtinys supporting OC0B, e.g. ATtiny85 + * IRSND_OC0A = OC0A on ATmegas/ATtinys supporting OC0A, e.g. ATtiny84, ATtiny85 + * IRSND_OC0B = OC0B on ATmegas/ATtinys supporting OC0B, e.g. ATtiny84, ATtiny85 *--------------------------------------------------------------------------------------------------------------------------------------------------- */ #define IRSND_OCx IRSND_OC2B // use OC2B diff --git a/main.c b/main.c index 9877762..589bb88 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: main.c,v 1.9 2011/04/11 12:54:25 fm Exp $ + * $Id: main.c,v 1.10 2011/09/08 13:22:16 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -32,21 +32,36 @@ void timer1_init (void) { -#if defined (__AVR_ATtiny85__) // ATtiny85: - OCR1A = (F_CPU / (2 * F_INTERRUPTS) / 2) - 1; // compare value: 1/28800 of CPU frequency, presc = 2 - TCCR1 = (1 << CTC1) | (1 << CS11); // switch CTC Mode on, set prescaler to 2 -#else // ATmegaXX: - OCR1A = (F_CPU / (2 * F_INTERRUPTS)) - 1; // compare value: 1/28800 of CPU frequency - TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1 +#if defined (__AVR_ATtiny85__) // ATtiny85: + OCR1A = (F_CPU / F_INTERRUPTS / 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4 + TCCR1 = (1 << CTC1) | (1 << CS11) | (1 << CS10); // switch CTC Mode on, set prescaler to 4 +#else // ATmegaXX: + OCR1A = (F_CPU / F_INTERRUPTS) - 1; // compare value: 1/15000 of CPU frequency + TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1 #endif #ifdef TIMSK1 - TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare + TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare #else - TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare + TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare #endif } +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Timer 1 output compare A interrupt service routine, called every 1/15000 sec + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#ifdef TIM1_COMPA_vect // ATtiny84 +ISR(TIM1_COMPA_vect) +#else +ISR(TIMER1_COMPA_vect) +#endif +{ + (void) irmp_ISR(); // call irmp ISR + // call other timer interrupt routines... +} + + int main (void) { -- 2.39.2