*\r
* Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irmp.c,v 1.110 2011/09/22 10:19:44 fm Exp $\r
+ * $Id: irmp.c,v 1.112 2012/02/13 10:59:07 fm Exp $\r
*\r
* ATMEGA88 @ 8 MHz\r
*\r
#endif\r
#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
static uint8_t xor_check[6]; // check kaseikyo "parity" bits\r
+static uint8_t genre2; // save genre2 bits here, later copied to MSB in flags\r
#endif\r
\r
/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
#endif\r
\r
#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
- else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit >= 20 && irmp_bit < 24)\r
+ else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)\r
{\r
- irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits in upper nibble with LSB first\r
- }\r
-\r
- if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
- {\r
- if (value)\r
+ if (irmp_bit >= 20 && irmp_bit < 24)\r
{\r
- xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
+ irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first\r
}\r
- else\r
+ else if (irmp_bit >= 24 && irmp_bit < 28)\r
{\r
- xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
+ genre2 |= (((uint8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first\r
}\r
- }\r
\r
+ if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)\r
+ {\r
+ if (value)\r
+ {\r
+ xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);\r
+ }\r
+ else\r
+ {\r
+ xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));\r
+ }\r
+ }\r
+ }\r
#endif\r
\r
irmp_bit++;\r
#ifdef ANALYZE\r
if (! irmp_pulse_time)\r
{\r
- ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter);\r
+ ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);\r
}\r
#endif\r
irmp_pulse_time++; // increment counter\r
wait_for_space = 0;\r
irmp_tmp_command = 0;\r
irmp_tmp_address = 0;\r
+#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
+ genre2 = 0;\r
+#endif\r
\r
#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1\r
irmp_tmp_command2 = 0;\r
else\r
#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1\r
{\r
- ANALYZE_PRINTF ("%8d error 1: pause after start bit pulse %d too long: %d\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
}\r
// irmp_busy_flag = FALSE;\r
irmp_param2.protocol = 0;\r
#endif\r
\r
- ANALYZE_PRINTF ("%8d [start-bit: pulse = %2d, pause = %2d]\n", time_counter, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);\r
\r
#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&\r
{\r
if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)\r
{\r
- ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
ANALYZE_NEWLINE ();\r
irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);\r
}\r
else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
{\r
- ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
ANALYZE_NEWLINE ();\r
#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
{\r
- ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)\r
{ // pause timings correct for "1"?\r
#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1\r
if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)\r
{\r
- ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)\r
{ // pause timings correct for "1"?\r
// 0123456789ABC0123456789ABC0123456701234567\r
// NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc\r
// NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc\r
- irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 12;\r
+ irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13\r
irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);\r
}\r
#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
\r
if (got_light)\r
{\r
- ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+ ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
#if IRMP_SUPPORT_MANCHESTER == 1\r
if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester\r
#endif\r
\r
{\r
- ANALYZE_PRINTF ("%8d code detected, length = %d\n", time_counter, irmp_bit);\r
+ ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);\r
irmp_ir_detected = TRUE;\r
\r
#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);\r
irmp_ir_detected = FALSE;\r
}\r
+\r
+ irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte\r
}\r
#endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1\r
\r
\r
if (verbose)\r
{\r
- printf ("%8d ", time_counter);\r
+ printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);\r
}\r
\r
if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r
* ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284\r
* ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P\r
*\r
- * $Id: irsnd.c,v 1.41 2011/09/20 10:45:28 fm Exp $\r
+ * $Id: irsnd.c,v 1.45 2012/02/13 11:02:29 fm Exp $\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
|| defined (__AVR_ATmega324__) \\r
|| defined (__AVR_ATmega644__) \\r
|| defined (__AVR_ATmega644P__) \\r
- || defined (__AVR_ATmega1284__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4\r
+ || defined (__AVR_ATmega1284__) \\r
+ || defined (__AVR_ATmega1284P__) // ATmega164|324|644|644P|1284 uses OC2A = PD7 or OC2B = PD6 or OC0A = PB3 or OC0B = PB4\r
#if IRSND_OCx == IRSND_OC2A // OC2A\r
#define IRSND_PORT PORTD // port D\r
#define IRSND_DDR DDRD // ddr D\r
#else\r
#error Wrong value for IRSND_OCx, choose IRSND_OC2A, IRSND_OC2B, IRSND_OC0A, or IRSND_OC0B in irsndconfig.h\r
#endif // IRSND_OCx\r
+#elif defined (__AVR_ATmega8515__) \r
+#if IRSND_OCx == IRSND_OC0 \r
+#define IRSND_PORT PORTB // port B\r
+#define IRSND_DDR DDRB // ddr B\r
+#define IRSND_BIT 0 // OC0\r
+#elif IRSND_OCx == IRSND_OC1A \r
+#define IRSND_PORT PORTD // port D\r
+#define IRSND_DDR DDRD // ddr D\r
+#define IRSND_BIT 5 // OC1A\r
+#elif IRSND_OCx == IRSND_OC1B \r
+#define IRSND_PORT PORTE // port E\r
+#define IRSND_DDR DDRE // ddr E\r
+#define IRSND_BIT 2 // OC1E\r
+#error Wrong value for IRSND_OCx, choose IRSND_OC0, IRSND_OC1A, or IRSND_OC1B in irsndconfig.h\r
+#endif // IRSND_OCx\r
\r
#else\r
#if !defined (unix) && !defined (WIN32)\r
case IRMP_KASEIKYO_PROTOCOL:\r
{\r
uint8_t xor;\r
+ uint16_t genre2;\r
\r
address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN);\r
command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4);\r
+ genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4);\r
\r
xor = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F;\r
\r
irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA\r
irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA\r
irsnd_buffer[2] = xor << 4 | (command & 0x000F); // XXXXCCCC\r
- irsnd_buffer[3] = 0 | (command & 0xF000) >> 12; // 0000CCCC\r
+ irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC\r
irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC\r
\r
xor = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4];\r
uint8_t\r
irsnd_ISR (void)\r
{\r
+ static uint8_t send_trailer;\r
static uint8_t current_bit = 0xFF;\r
static uint8_t pulse_counter;\r
static IRSND_PAUSE_LEN pause_counter;\r
}\r
else\r
{\r
+ if (send_trailer)\r
+ {\r
+ irsnd_busy = FALSE;\r
+ return irsnd_busy;\r
+ }\r
+\r
n_repeat_frames = irsnd_repeat;\r
\r
if (n_repeat_frames == IRSND_ENDLESS_REPETITION)\r
}\r
else\r
{\r
+ irsnd_busy = TRUE;\r
+ send_trailer = TRUE;\r
n_repeat_frames = 0;\r
repeat_counter = 0;\r
}\r
int\r
main (int argc, char ** argv)\r
{\r
- int idx;\r
int protocol;\r
int address;\r
int command;\r
irsnd_ISR ();\r
}\r
\r
- for (idx = 0; idx < 20; idx++)\r
- {\r
- irsnd_ISR ();\r
- }\r
-\r
putchar ('\n');\r
}\r
else\r