From a48187fa5b6eeab9fdfbcbc8f09d8e0127bd1e73 Mon Sep 17 00:00:00 2001 From: ukw Date: Fri, 24 Feb 2012 14:25:32 +0000 Subject: [PATCH] Version 2.1.2: - added IR60 protocol for IRSND git-svn-id: svn://mikrocontroller.net/irmp@91 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- README.txt | 2 +- irmp.h | 8 ++-- irmpconfig.h | 4 +- irsnd.c | 129 +++++++++++++++++++++++++++++++------------------- irsndconfig.h | 6 +-- 5 files changed, 92 insertions(+), 57 deletions(-) diff --git a/README.txt b/README.txt index 269b77c..c547e71 100644 --- a/README.txt +++ b/README.txt @@ -2,7 +2,7 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- Version IRMP: 2.1.2 24.02.2012 -Version IRSND: 2.1.0 16.02.2012 +Version IRSND: 2.1.2 24.02.2012 Dokumentation: diff --git a/irmp.h b/irmp.h index f7a3b25..1e54f2c 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.71 2012/02/24 11:40:41 fm Exp $ + * $Id: irmp.h,v 1.72 2012/02/24 14:24:27 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -311,7 +311,7 @@ typedef uint8_t PAUSE_LEN; #define GRUNDIG_NOKIA_IR60_FLAGS (IRMP_PARAM_FLAG_IS_MANCHESTER | IRMP_PARAM_FLAG_1ST_PULSE_IS_1) // flags #define GRUNDIG_FRAMES 2 // GRUNDIG sends each frame 1+1 times -#define GRUNDIG_AUTO_REPETITION_PAUSE_TIME 20.0e-3 // repetition after 20ms +#define GRUNDIG_AUTO_REPETITION_PAUSE_TIME 20.0e-3 // repetition after 20ms #define GRUNDIG_ADDRESS_OFFSET 0 // no address #define GRUNDIG_ADDRESS_LEN 0 // no address #define GRUNDIG_COMMAND_OFFSET 1 // skip 1 start bit @@ -319,13 +319,15 @@ typedef uint8_t PAUSE_LEN; #define GRUNDIG_COMPLETE_DATA_LEN 10 // complete length: 1 start bit + 9 data bits #define NOKIA_FRAMES 3 // NOKIA sends each frame 1 + 1 + 1 times -#define NOKIA_AUTO_REPETITION_PAUSE_TIME 20.0e-3 // repetition after 20ms +#define NOKIA_AUTO_REPETITION_PAUSE_TIME 20.0e-3 // repetition after 20ms #define NOKIA_ADDRESS_OFFSET 9 // skip 9 bits (1 start bit + 8 data bits) #define NOKIA_ADDRESS_LEN 8 // 7 address bits #define NOKIA_COMMAND_OFFSET 1 // skip 1 bit (1 start bit) #define NOKIA_COMMAND_LEN 8 // read 8 command bits #define NOKIA_COMPLETE_DATA_LEN 17 // complete length: 1 start bit + 8 address bits + 8 command bits +#define IR60_FRAMES 2 // IR60 sends each frame 1+1 times +#define IR60_AUTO_REPETITION_PAUSE_TIME 22.2e-3 // repetition after 22.2ms #define IR60_TIMEOUT_TIME 5000.0e-6 // timeout grundig frame, switch to IR60 #define IR60_ADDRESS_OFFSET 0 // skip 1 bits #define IR60_ADDRESS_LEN 0 // read 0 address bits diff --git a/irmpconfig.h b/irmpconfig.h index 2eeeab9..b081135 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.81 2012/02/24 11:40:41 fm Exp $ + * $Id: irmpconfig.h,v 1.82 2012/02/24 14:24:27 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -56,7 +56,7 @@ #define IRMP_SUPPORT_JVC_PROTOCOL 0 // JVC >= 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_IR60_PROTOCOL 1 // 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 #define IRMP_SUPPORT_NOKIA_PROTOCOL 0 // Nokia >= 10000 ~300 bytes diff --git a/irsnd.c b/irsnd.c index 0427374..17e78f5 100644 --- a/irsnd.c +++ b/irsnd.c @@ -12,7 +12,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.47 2012/02/16 12:37:30 fm Exp $ + * $Id: irsnd.c,v 1.48 2012/02/24 14:24:28 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 @@ -328,12 +328,15 @@ typedef unsigned short uint16_t; #define NOKIA_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * NOKIA_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define IR60_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * IR60_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! + #define SIEMENS_START_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME + 0.5) #define SIEMENS_BIT_LEN (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME + 0.5) #define SIEMENS_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #ifdef PIC_C18 +#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2 / Pre_Scaler / PIC_Scaler) - 1) #define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2 / Pre_Scaler / PIC_Scaler) - 1) #define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2 / Pre_Scaler / PIC_Scaler) - 1) #define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2 / Pre_Scaler / PIC_Scaler) - 1) @@ -341,6 +344,7 @@ typedef unsigned short uint16_t; #define IRSND_FREQ_56_KHZ (uint8_t) ((F_CPU / 56000 / 2 / Pre_Scaler / PIC_Scaler) - 1) #define IRSND_FREQ_455_KHZ (uint8_t) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1) #else // AVR +#define IRSND_FREQ_30_KHZ (uint8_t) ((F_CPU / 30000 / 2) - 1) #define IRSND_FREQ_32_KHZ (uint8_t) ((F_CPU / 32000 / 2) - 1) #define IRSND_FREQ_36_KHZ (uint8_t) ((F_CPU / 36000 / 2) - 1) #define IRSND_FREQ_38_KHZ (uint8_t) ((F_CPU / 38000 / 2) - 1) @@ -413,7 +417,6 @@ irsnd_on (void) IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) #else - #if IRSND_OCx == IRSND_OC2 // use OC2 TCCR2 |= (1<command, NEC42_COMMAND_LEN); irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA - irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // 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 @@ -913,6 +914,17 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_IR60_PROTOCOL == 1 + case IRMP_IR60_PROTOCOL: + { + command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN); + irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) + irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) + + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_PROTOCOL: { @@ -1026,32 +1038,32 @@ irsnd_stop (void) uint8_t irsnd_ISR (void) { - static uint8_t send_trailer = FALSE; - static uint8_t current_bit = 0;// 0xFF; - static uint8_t pulse_counter = 0; - static IRSND_PAUSE_LEN pause_counter = 0; - static uint8_t startbit_pulse_len = 0; - static IRSND_PAUSE_LEN startbit_pause_len = 0; - static uint8_t pulse_1_len = 0; - static uint8_t pause_1_len = 0; - static uint8_t pulse_0_len = 0; - static uint8_t pause_0_len = 0; - static uint8_t has_stop_bit = 0; - static uint8_t new_frame = TRUE; - static uint8_t complete_data_len = 0; - static uint8_t n_repeat_frames = 0; // number of repetition frames - static uint8_t n_auto_repetitions = 0; // number of auto_repetitions - static uint8_t auto_repetition_counter = 0; // auto_repetition counter - static uint16_t auto_repetition_pause_len = 0; // pause before auto_repetition, uint16_t! - static uint16_t auto_repetition_pause_counter = 0; // pause before auto_repetition, uint16_t! - static uint8_t repeat_counter = 0; // repeat counter - static uint16_t repeat_frame_pause_len = 0; // pause before repeat, uint16_t! - static uint16_t packet_repeat_pause_counter = 0; // pause before repeat, uint16_t! + static uint8_t send_trailer = FALSE; + static uint8_t current_bit = 0xFF; + static uint8_t pulse_counter = 0; + static IRSND_PAUSE_LEN pause_counter = 0; + static uint8_t startbit_pulse_len = 0; + static IRSND_PAUSE_LEN startbit_pause_len = 0; + static uint8_t pulse_1_len = 0; + static uint8_t pause_1_len = 0; + static uint8_t pulse_0_len = 0; + static uint8_t pause_0_len = 0; + static uint8_t has_stop_bit = 0; + static uint8_t new_frame = TRUE; + static uint8_t complete_data_len = 0; + static uint8_t n_repeat_frames = 0; // number of repetition frames + static uint8_t n_auto_repetitions = 0; // number of auto_repetitions + static uint8_t auto_repetition_counter = 0; // auto_repetition counter + static uint16_t auto_repetition_pause_len = 0; // pause before auto_repetition, uint16_t! + static uint16_t auto_repetition_pause_counter = 0; // pause before auto_repetition, uint16_t! + static uint8_t repeat_counter = 0; // repeat counter + static uint16_t repeat_frame_pause_len = 0; // pause before repeat, uint16_t! + static uint16_t packet_repeat_pause_counter = 0; // pause before repeat, uint16_t! #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - static uint8_t last_bit_value; + static uint8_t last_bit_value; #endif - static uint8_t pulse_len = 0xFF; - static IRSND_PAUSE_LEN pause_len = 0xFF; + static uint8_t pulse_len = 0xFF; + static IRSND_PAUSE_LEN pause_len = 0xFF; if (irsnd_busy) { @@ -1065,17 +1077,22 @@ irsnd_ISR (void) { auto_repetition_pause_counter = 0; - if (irsnd_protocol == IRMP_DENON_PROTOCOL) + if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame { current_bit = 16; complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1; } - else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig info frame + else if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame { current_bit = 15; complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN; } - else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia info frame + else if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame + { + current_bit = 7; + complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1; + } + else if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame { if (auto_repetition_counter + 1 < n_auto_repetitions) { @@ -1134,7 +1151,6 @@ irsnd_ISR (void) return irsnd_busy; } - n_repeat_frames = irsnd_repeat; if (n_repeat_frames == IRSND_ENDLESS_REPETITION) @@ -1469,9 +1485,24 @@ irsnd_ISR (void) complete_data_len = GRUNDIG_COMPLETE_DATA_LEN; n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause irsnd_set_freq (IRSND_FREQ_38_KHZ); - + break; + } +#endif +#if IRSND_SUPPORT_IR60_PROTOCOL == 1 + case IRMP_IR60_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = IR60_COMPLETE_DATA_LEN; + n_auto_repetitions = IR60_FRAMES; // 2 frames + auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_30_KHZ); break; } #endif @@ -1563,7 +1594,6 @@ irsnd_ISR (void) auto_repetition_pause_len = 0; repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; } #endif @@ -1582,7 +1612,6 @@ irsnd_ISR (void) auto_repetition_pause_len = 0; repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN; irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; } #endif @@ -1865,12 +1894,15 @@ irsnd_ISR (void) #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 case IRMP_GRUNDIG_PROTOCOL: #endif +#if IRSND_SUPPORT_IR60_PROTOCOL == 1 + case IRMP_IR60_PROTOCOL: +#endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 case IRMP_NOKIA_PROTOCOL: #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || \ - IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 + IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 { if (pulse_counter == pulse_len && pause_counter == pause_len) { @@ -1880,8 +1912,8 @@ irsnd_ISR (void) { current_bit = 0xFF; -#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) +#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) { auto_repetition_counter++; @@ -1919,11 +1951,12 @@ irsnd_ISR (void) { uint8_t first_pulse; -#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) +#if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) { if (current_bit == 0xFF || // start bit of start-frame (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig) + (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60) (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia) { pulse_len = startbit_pulse_len; @@ -2033,7 +2066,7 @@ irsnd_ISR (void) break; } #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || - // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 + // IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 default: { diff --git a/irsndconfig.h b/irsndconfig.h index 746f57a..070c7c3 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.29 2012/02/16 12:39:36 fm Exp $ + * $Id: irsndconfig.h,v 1.30 2012/02/24 14:24:28 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -45,8 +45,8 @@ #define IRSND_SUPPORT_JVC_PROTOCOL 0 // JVC >= 10000 ~150 bytes #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_IR60_PROTOCOL 1 // IR60 (SAB2008) >= 10000 ~250 bytes +#define IRSND_SUPPORT_GRUNDIG_PROTOCOL 1 // Grundig >= 10000 ~300 bytes #define IRSND_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens, Gigaset >= 15000 ~150 bytes #define IRSND_SUPPORT_NOKIA_PROTOCOL 0 // Nokia >= 10000 ~400 bytes -- 2.39.2