From c7c9a4a1320292cd9a71e01ad571626cfa4a30d3 Mon Sep 17 00:00:00 2001 From: ukw Date: Tue, 15 Jun 2010 15:40:11 +0000 Subject: [PATCH] Version 1.6.6: added FDC & RC-CAR protocol to IRSND git-svn-id: svn://mikrocontroller.net/irmp@30 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- IR-Data/test-suite.sh | 40 ++++++++++++++++++--------- irmp.c | 4 ++- irmp.h | 12 ++++----- irsnd.c | 63 +++++++++++++++++++++++++++++++++++++------ irsndconfig.h | 20 +++++++------- 5 files changed, 100 insertions(+), 39 deletions(-) diff --git a/IR-Data/test-suite.sh b/IR-Data/test-suite.sh index da04f68..f9ce053 100644 --- a/IR-Data/test-suite.sh +++ b/IR-Data/test-suite.sh @@ -8,9 +8,11 @@ # # Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de # -# $Id: test-suite.sh,v 1.10 2010/06/09 12:04:04 fm Exp $ +# $Id: test-suite.sh,v 1.11 2010/06/15 12:21:06 fm Exp $ #---------------------------------------------------------------------------- +cd `dirname $0` + for j in \ Dbox.txt \ DK_Digital.txt \ @@ -36,7 +38,7 @@ for j in \ denon.txt \ elta_radio.txt \ nec-repetition.txt \ - nec-skymaster-dt500.txt \ + nec-skymaster-dt500.txt \ nec.txt \ nubert-subwoofer.txt \ orion_vcr_07660BM070.txt \ @@ -52,26 +54,38 @@ do echo "testing $j ..." if ../irmp -v < $j | grep -q error then - ../irmp -v < $j | grep error - echo "test failed" - exit 1 + ../irmp -v < $j | grep error + echo "test failed" + exit 1 fi done -for j in \ - Siemens-Gigaset-M740AV-15kHz.txt \ - bo_beolink1000-15kHz.txt \ - denon-15kHz.txt \ - fdc-15kHz.txt +for j in \ + Siemens-Gigaset-M740AV-15kHz.txt \ + bo_beolink1000-15kHz.txt \ + denon-15kHz.txt do echo "testing $j ..." if ../irmp-15kHz -v < $j | grep -q error then - ../irmp-15kHz -v < $j | grep error - echo "test failed" - exit 1 + ../irmp-15kHz -v < $j | grep error + echo "test failed" + exit 1 fi done +# for j in \ +# fdc-20kHz.txt +# do +# echo "testing $j ..." +# if ../irmp-20kHz -v < $j | grep -q error +# then +# ../irmp-20kHz -v < $j | grep error +# echo "test failed" +# exit 1 +# fi +# done + + echo "all tests successful" exit 0 diff --git a/irmp.c b/irmp.c index 8418b28..98bb00a 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.51 2010/06/15 12:01:20 fm Exp $ + * $Id: irmp.c,v 1.52 2010/06/15 15:47:21 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -1244,10 +1244,12 @@ irmp_get_data (IRMP_DATA * irmp_data_p) // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0 irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0 +printf ("\n! %04x ", irmp_command); irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0 ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0 ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0 rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0 +printf ("%04x\n", irmp_command); break; #endif default: diff --git a/irmp.h b/irmp.h index b9aee4e..909cc73 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.33 2010/06/14 15:55:11 fm Exp $ + * $Id: irmp.h,v 1.34 2010/06/15 15:47:21 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -43,7 +43,7 @@ extern "C" #define IRMP_GRUNDIG_PROTOCOL 15 // Grundig #define IRMP_NOKIA_PROTOCOL 16 // Nokia #define IRMP_SIEMENS_PROTOCOL 17 // Siemens, e.g. Gigaset -#define IRMP_FDC_PROTOCOL 18 // FDC keyboard - protocol 2 +#define IRMP_FDC_PROTOCOL 18 // FDC keyboard #define IRMP_RCCAR_PROTOCOL 19 // RC Car // some flags of struct IRMP_PARAMETER: @@ -289,7 +289,7 @@ extern "C" #define FDC_PULSE_TIME 360.0e-6 // 360 usec pulse #define FDC_1_PAUSE_TIME 650.0e-6 // 650 usec pause #define FDC_0_PAUSE_TIME 180.0e-6 // 180 usec pause -#define FDC_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40ms +#define FDC_FRAME_REPEAT_PAUSE_TIME 60.0e-3 // frame repeat after 60ms #define FDC_ADDRESS_OFFSET 0 // skip 0 bits #define FDC_ADDRESS_LEN 8 // read 8 address bits #define FDC_COMMAND_OFFSET 24 // skip 24 bits (8 address bits + 12 status bits + 4 repeat bits) @@ -306,9 +306,9 @@ extern "C" #define RCCAR_0_PAUSE_TIME 900.0e-6 // 180 usec pause #define RCCAR_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40ms #define RCCAR_ADDRESS_OFFSET 0 // skip 0 bits -#define RCCAR_ADDRESS_LEN 0 // read 8 address bits -#define RCCAR_COMMAND_OFFSET 0 // skip 24 bits (8 address bits + 12 status bits + 4 repeat bits) -#define RCCAR_COMMAND_LEN 13 // read 8 bits +#define RCCAR_ADDRESS_LEN 0 // read 0 address bits +#define RCCAR_COMMAND_OFFSET 0 // skip 0 bits +#define RCCAR_COMMAND_LEN 13 // read 13 bits #define RCCAR_COMPLETE_DATA_LEN 13 // complete length #define RCCAR_STOP_BIT 1 // has stop bit #define RCCAR_LSB 1 // LSB...MSB diff --git a/irsnd.c b/irsnd.c index 570b916..029d476 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.19 2010/06/14 15:55:11 fm Exp $ + * $Id: irsnd.c,v 1.20 2010/06/15 15:47:21 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 @@ -160,6 +160,13 @@ typedef unsigned short uint16_t; #define FDC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME + 0.5) #define FDC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * FDC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define RCCAR_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME + 0.5) +#define RCCAR_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME + 0.5) +#define RCCAR_PULSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME + 0.5) +#define RCCAR_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME + 0.5) +#define RCCAR_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME + 0.5) +#define RCCAR_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RCCAR_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + static volatile uint8_t irsnd_busy; static volatile uint8_t irsnd_protocol; static volatile uint8_t irsnd_buffer[6]; @@ -496,11 +503,24 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN); command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN); - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = 0; // 00000000 - irsnd_buffer[3] = (command & 0x0FE0) >> 5; // 0CCCCCCC - irsnd_buffer[4] = ((command & 0x001F) << 3) | 0x07; // CCCCC111 + irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA + irsnd_buffer[1] = 0; // 00000000 + irsnd_buffer[2] = 0; // 0000RRRR + irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC + irsnd_buffer[4] = ~(command & 0xFF); // cccccccc + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 + case IRMP_RCCAR_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, 2); // A0 A1 + command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V + + irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3 + irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0 + irsnd_busy = TRUE; break; } @@ -896,6 +916,24 @@ irsnd_ISR (void) irsnd_set_freq (IRSND_FREQ_38_KHZ); break; } +#endif +#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 + case IRMP_RCCAR_PROTOCOL: + { + startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN; + startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN; + complete_data_len = RCCAR_COMPLETE_DATA_LEN; + pulse_1_len = RCCAR_PULSE_LEN; + pause_1_len = RCCAR_1_PAUSE_LEN; + pulse_0_len = RCCAR_PULSE_LEN; + pause_0_len = RCCAR_0_PAUSE_LEN; + has_stop_bit = RCCAR_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif default: { @@ -940,14 +978,17 @@ irsnd_ISR (void) #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 case IRMP_BANG_OLUFSEN_PROTOCOL: #endif -#if IRSND_SUPPORT_NEC_PROTOCOL == 1 +#if IRSND_SUPPORT_FDC_PROTOCOL == 1 case IRMP_FDC_PROTOCOL: #endif +#if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 + case IRMP_RCCAR_PROTOCOL: +#endif #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 || IRSND_SUPPORT_MATSUSHITA_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_BANG_OLUFSEN_PROTOCOL == 1 || IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 { if (pulse_counter == 0) { @@ -1244,6 +1285,12 @@ irsnd_ISR (void) { if (repeat_counter < n_repeat_frames) { +#if IRSND_SUPPORT_FDC_PROTOCOL == 1 + if (irsnd_protocol == IRMP_FDC_PROTOCOL) + { + irsnd_buffer[2] |= 0x0F; + } +#endif repeat_counter++; irsnd_busy = TRUE; } diff --git a/irsndconfig.h b/irsndconfig.h index 05f27b2..56317bb 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.7 2010/06/10 21:24:50 fm Exp $ + * $Id: irsndconfig.h,v 1.8 2010/06/15 15:47:21 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -43,6 +43,8 @@ #define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL 1 // flag: support Bang&Olufsen uses ~250 bytes #define IRSND_SUPPORT_GRUNDIG_PROTOCOL 1 // flag: support Grundig uses ~300 bytes #define IRSND_SUPPORT_NOKIA_PROTOCOL 1 // flag: support Nokia uses ~400 bytes +#define IRSND_SUPPORT_FDC_PROTOCOL 1 // flag: support FDC infrared keyboard uses ~150 bytes +#define IRSND_SUPPORT_RCCAR_PROTOCOL 1 // flag: support RC CAR uses ~150 bytes /*--------------------------------------------------------------------------------------------------------------------------------------------------- * THE FOLLOWING ENCODERS WORK ONLY FOR F_INTERRUPTS > 14500! @@ -50,12 +52,8 @@ */ #if F_INTERRUPTS >= 14500 #define IRSND_SUPPORT_SIEMENS_PROTOCOL 1 // flag: support Siemens, e.g. Gigaset uses ~150 bytes -#define IRSND_SUPPORT_FDC1_PROTOCOL 1 // flag: support FDC1 infrared keyboard uses ~150 bytes -#define IRSND_SUPPORT_FDC2_PROTOCOL 1 // flag: support FDC2 infrared keyboard uses ~150 bytes #else #define IRSND_SUPPORT_SIEMENS_PROTOCOL 0 // DO NOT CHANGE! F_INTERRUPTS too low! -#define IRSND_SUPPORT_FDC1_PROTOCOL 0 // DO NOT CHANGE! F_INTERRUPTS too low! -#define IRSND_SUPPORT_FDC2_PROTOCOL 0 // DO NOT CHANGE! F_INTERRUPTS too low! #endif @@ -64,11 +62,11 @@ *--------------------------------------------------------------------------------------------------------------------------------------------------- */ #if defined (__AVR_ATmega32__) || defined (__AVR_ATmega644P__) -#define IRSND_PORT PORTD // port D -#define IRSND_DDR DDRD // ddr D -#define IRSND_BIT 7 // OC2A +#define IRSND_PORT PORTD // port D +#define IRSND_DDR DDRD // ddr D +#define IRSND_BIT 7 // OC2A #else -#define IRSND_PORT PORTB // port B -#define IRSND_DDR DDRB // ddr B -#define IRSND_BIT 3 // OC2A +#define IRSND_PORT PORTB // port B +#define IRSND_DDR DDRB // ddr B +#define IRSND_BIT 3 // OC2A #endif // __AVR... -- 2.39.2