X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/deba2a0ab6d1a615fc84bf9d04e39cd832020a2c..7644ac04e209441d89d900125995b2d398cfd4b4:/irmp.h diff --git a/irmp.h b/irmp.h index e9f06ef..7504907 100644 --- a/irmp.h +++ b/irmp.h @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp.h * - * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.h,v 1.54 2011/02/23 15:03:27 fm Exp $ + * $Id: irmp.h,v 1.65 2011/09/08 13:22:16 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -17,11 +17,6 @@ #ifndef _WC_IRMP_H_ #define _WC_IRMP_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - /*--------------------------------------------------------------------------------------------------------------------------------------------------- * timing constants: *--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -67,14 +62,22 @@ typedef uint8_t PAUSE_LEN; #define IRMP_SIEMENS_PROTOCOL 17 // Siemens, e.g. Gigaset #define IRMP_FDC_PROTOCOL 18 // FDC keyboard #define IRMP_RCCAR_PROTOCOL 19 // RC Car -#define IRMP_JVC_PROTOCOL 20 // JVC +#define IRMP_JVC_PROTOCOL 20 // JVC (NEC with 16 bits) #define IRMP_RC6A_PROTOCOL 21 // RC6A, e.g. Kathrein, XBOX #define IRMP_NIKON_PROTOCOL 22 // Nikon #define IRMP_RUWIDO_PROTOCOL 23 // Ruwido, e.g. T-Home Mediareceiver #define IRMP_IR60_PROTOCOL 24 // IR60 (SAB2008) #define IRMP_KATHREIN_PROTOCOL 25 // Kathrein #define IRMP_NETBOX_PROTOCOL 26 // Netbox keyboard (bitserial) -#define IRMP_IMON_PROTOCOL 27 // Imon (bitserial) +#define IRMP_NEC16_PROTOCOL 27 // NEC with 16 bits (incl. sync) +#define IRMP_NEC42_PROTOCOL 28 // NEC with 42 bits +#define IRMP_LEGO_PROTOCOL 29 // LEGO Power Functions RC +#define IRMP_THOMSON_PROTOCOL 30 // Thomson +#define IRMP_MERLIN_PROTOCOL 31 // Pollin Merlin keyboard (bitserial) + +#define IRMP_N_PROTOCOLS 31 // number of supported protocols + +#define IRMP_IMON_PROTOCOL 99 // Imon (bitserial) PROTOTYPE! // some flags of struct IRMP_PARAMETER: #define IRMP_PARAM_FLAG_IS_MANCHESTER 0x01 @@ -115,12 +118,24 @@ typedef uint8_t PAUSE_LEN; #define NEC_LSB 1 // LSB...MSB #define NEC_FLAGS 0 // flags +#define NEC42_ADDRESS_OFFSET 0 // skip 0 bits +#define NEC42_ADDRESS_LEN 13 // read 13 address bits +#define NEC42_COMMAND_OFFSET 26 // skip 26 bits (2 x 13 address bits) +#define NEC42_COMMAND_LEN 8 // read 8 command bits +#define NEC42_COMPLETE_DATA_LEN 42 // complete length (2 x 13 + 2 x 8) + +#define NEC16_ADDRESS_OFFSET 0 // skip 0 bits +#define NEC16_ADDRESS_LEN 8 // read 8 address bits +#define NEC16_COMMAND_OFFSET 8 // skip 8 bits (8 address) +#define NEC16_COMMAND_LEN 8 // read 8 bits (8 command) +#define NEC16_COMPLETE_DATA_LEN 16 // complete length + #define SAMSUNG_START_BIT_PULSE_TIME 4500.0e-6 // 4500 usec pulse #define SAMSUNG_START_BIT_PAUSE_TIME 4500.0e-6 // 4500 usec pause #define SAMSUNG_PULSE_TIME 550.0e-6 // 550 usec pulse #define SAMSUNG_1_PAUSE_TIME 1450.0e-6 // 1450 usec pause #define SAMSUNG_0_PAUSE_TIME 450.0e-6 // 450 usec pause -#define SAMSUNG_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms +#define SAMSUNG_FRAME_REPEAT_PAUSE_TIME 25.0e-3 // frame repeat after 25ms #define SAMSUNG_ADDRESS_OFFSET 0 // skip 0 bits #define SAMSUNG_ADDRESS_LEN 16 // read 16 address bits #define SAMSUNG_ID_OFFSET 17 // skip 16 + 1 sync bit @@ -177,11 +192,11 @@ typedef uint8_t PAUSE_LEN; #define RECS80_1_PAUSE_TIME 7432.0e-6 // 7432 usec pause #define RECS80_0_PAUSE_TIME 4902.0e-6 // 4902 usec pause #define RECS80_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms -#define RECS80_ADDRESS_OFFSET 2 // skip 2 bits (2nd start + 1 toggle) +#define RECS80_ADDRESS_OFFSET 1 // skip 1 bit (toggle bit) #define RECS80_ADDRESS_LEN 3 // read 3 address bits -#define RECS80_COMMAND_OFFSET 5 // skip 5 bits (2nd start + 1 toggle + 3 address) +#define RECS80_COMMAND_OFFSET 4 // skip 4 bits (1 toggle + 3 address) #define RECS80_COMMAND_LEN 6 // read 6 command bits -#define RECS80_COMPLETE_DATA_LEN 11 // complete length +#define RECS80_COMPLETE_DATA_LEN 10 // complete length #define RECS80_STOP_BIT 1 // has stop bit #define RECS80_LSB 0 // MSB...LSB #define RECS80_FLAGS 0 // flags @@ -189,8 +204,8 @@ typedef uint8_t PAUSE_LEN; #define RC5_BIT_TIME 889.0e-6 // 889 usec pulse/pause #define RC5_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms -#define RC5_ADDRESS_OFFSET 2 // skip 2 bits (2nd start + 1 toggle) -#define RC5_ADDRESS_LEN 5 // read 5 address bits +#define RC5_ADDRESS_OFFSET 1 // skip 1 bit (2nd start) +#define RC5_ADDRESS_LEN 6 // read 1 toggle bit (for key repetition detection) + 5 address bits #define RC5_COMMAND_OFFSET 7 // skip 5 bits (2nd start + 1 toggle + 5 address) #define RC5_COMMAND_LEN 6 // read 6 command bits #define RC5_COMPLETE_DATA_LEN 13 // complete length @@ -235,7 +250,7 @@ typedef uint8_t PAUSE_LEN; #define RECS80EXT_0_PAUSE_TIME 4902.0e-6 // 4902 usec pause #define RECS80EXT_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms #define RECS80EXT_ADDRESS_OFFSET 2 // skip 2 bits (2nd start + 1 toggle) -#define RECS80EXT_ADDRESS_LEN 4 // read 3 address bits +#define RECS80EXT_ADDRESS_LEN 4 // read 4 address bits #define RECS80EXT_COMMAND_OFFSET 6 // skip 6 bits (2nd start + 1 toggle + 4 address) #define RECS80EXT_COMMAND_LEN 6 // read 6 command bits #define RECS80EXT_COMPLETE_DATA_LEN 12 // complete length @@ -384,7 +399,7 @@ typedef uint8_t PAUSE_LEN; #define NIKON_START_BIT_PULSE_TIME 2200.0e-6 // 2200 usec pulse #define NIKON_START_BIT_PAUSE_TIME 27100.0e-6 // 27100 usec pause -#define NIKON_PULSE_TIME 500.0e-6 // 520 usec pulse +#define NIKON_PULSE_TIME 500.0e-6 // 500 usec pulse #define NIKON_1_PAUSE_TIME 3500.0e-6 // 3500 usec pause #define NIKON_0_PAUSE_TIME 1500.0e-6 // 1500 usec pause #define NIKON_FRAME_REPEAT_PAUSE_TIME 60.0e-3 // frame repeat after 60ms @@ -416,10 +431,10 @@ typedef uint8_t PAUSE_LEN; #define KATHREIN_LSB 0 // MSB #define KATHREIN_FLAGS 0 // flags -#define NETBOX_START_BIT_PULSE_TIME 2500.0e-6 // 2500 usec pulse -#define NETBOX_START_BIT_PAUSE_TIME 833.0e-6 // 833 usec pause -#define NETBOX_PULSE_TIME 833.0e-6 // 833 usec pulse -#define NETBOX_PAUSE_TIME 833.0e-6 // 833 usec pause +#define NETBOX_START_BIT_PULSE_TIME 2400.0e-6 // 2400 usec pulse +#define NETBOX_START_BIT_PAUSE_TIME 800.0e-6 // 800 usec pause +#define NETBOX_PULSE_TIME 800.0e-6 // 800 usec pulse +#define NETBOX_PAUSE_TIME 800.0e-6 // 800 usec pause #define NETBOX_FRAMES 1 // Netbox sends 1 frame #define NETBOX_AUTO_REPETITION_PAUSE_TIME 35.0e-3 // auto repetition after 35ms #define NETBOX_FRAME_REPEAT_PAUSE_TIME 35.0e-3 // frame repeat after 35ms @@ -427,11 +442,57 @@ typedef uint8_t PAUSE_LEN; #define NETBOX_ADDRESS_LEN 3 // read 3 address bits #define NETBOX_COMMAND_OFFSET 3 // skip 3 bits #define NETBOX_COMMAND_LEN 13 // read 13 bits -#define NETBOX_COMPLETE_DATA_LEN 16 // complete length, last is stop bit +#define NETBOX_COMPLETE_DATA_LEN 16 // complete length #define NETBOX_STOP_BIT 0 // has no stop bit #define NETBOX_LSB 1 // LSB #define NETBOX_FLAGS IRMP_PARAM_FLAG_IS_SERIAL // flags +#define MERLIN_START_BIT_PULSE_TIME 340.0e-6 // 340 usec pulse +#define MERLIN_START_BIT_PAUSE_TIME 300.0e-6 // 300 usec pause +#define MERLIN_PULSE_TIME 380.0e-6 // 380 usec pulse +#define MERLIN_PAUSE_TIME 310.0e-6 // 310 usec pause +#define MERLIN_FRAMES 1 // Merlin sends 1 frame +#define MERLIN_AUTO_REPETITION_PAUSE_TIME 35.0e-3 // auto repetition after 35ms +#define MERLIN_FRAME_REPEAT_PAUSE_TIME 35.0e-3 // frame repeat after 35ms +#define MERLIN_ADDRESS_OFFSET 0 // skip 0 bits +#define MERLIN_ADDRESS_LEN 9 // read 16 address bits +#define MERLIN_COMMAND_OFFSET 9 // skip 16 bits +#define MERLIN_COMMAND_LEN 16 // read 9 bits +#define MERLIN_COMPLETE_DATA_LEN 25 // complete length +#define MERLIN_STOP_BIT 0 // has no stop bit +#define MERLIN_LSB 1 // LSB +#define MERLIN_FLAGS IRMP_PARAM_FLAG_IS_SERIAL // flags + +#define LEGO_START_BIT_PULSE_TIME 158.0e-6 // 158 usec pulse ( 6 x 1/38kHz) +#define LEGO_START_BIT_PAUSE_TIME 1026.0e-6 // 1026 usec pause (39 x 1/38kHz) +#define LEGO_PULSE_TIME 158.0e-6 // 158 usec pulse ( 6 x 1/38kHz) +#define LEGO_1_PAUSE_TIME 553.0e-6 // 553 usec pause (21 x 1/38kHz) +#define LEGO_0_PAUSE_TIME 263.0e-6 // 263 usec pause (10 x 1/38kHz) +#define LEGO_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40ms +#define LEGO_ADDRESS_OFFSET 0 // skip 0 bits +#define LEGO_ADDRESS_LEN 0 // read 0 address bits +#define LEGO_COMMAND_OFFSET 0 // skip 0 bits +#define LEGO_COMMAND_LEN 16 // read 16 bits (12 command + 4 CRC) +#define LEGO_COMPLETE_DATA_LEN 16 // complete length +#define LEGO_STOP_BIT 1 // has stop bit +#define LEGO_LSB 0 // MSB...LSB +#define LEGO_FLAGS 0 // flags + +#define THOMSON_PULSE_TIME 550.0e-6 // 550 usec pulse +#define THOMSON_1_PAUSE_TIME 4500.0e-6 // 4500 usec pause +#define THOMSON_0_PAUSE_TIME 2000.0e-6 // 2000 usec pause +#define THOMSON_FRAMES 1 // THOMSON sends 1 frame +#define THOMSON_AUTO_REPETITION_PAUSE_TIME 65.0e-3 // repetition after 65ms +#define THOMSON_FRAME_REPEAT_PAUSE_TIME 65.0e-3 // frame repeat after 65ms +#define THOMSON_ADDRESS_OFFSET 0 // skip 0 bits +#define THOMSON_ADDRESS_LEN 4 // read 4 address bits +#define THOMSON_COMMAND_OFFSET 5 // skip 4 address bits + 1 toggle bit +#define THOMSON_COMMAND_LEN 7 // read 7 command bits +#define THOMSON_COMPLETE_DATA_LEN 12 // complete length +#define THOMSON_STOP_BIT 1 // has stop bit +#define THOMSON_LSB 0 // MSB...LSB +#define THOMSON_FLAGS 0 // flags + #define IMON_START_BIT_PULSE_TIME 1333.0e-6 // 1333 usec pulse #define IMON_START_BIT_PAUSE_TIME 1172.0e-6 // 1333 usec pause #define IMON_PULSE_TIME 500.0e-6 // 500 usec pulse @@ -464,29 +525,17 @@ typedef struct uint8_t flags; // flags, e.g. repetition } IRMP_DATA; +extern void irmp_init (void); +extern uint8_t irmp_get_data (IRMP_DATA *); +extern uint8_t irmp_is_busy (void); +extern uint8_t irmp_ISR (void); -/** - * Initialize IRMP decoder - * @details Configures IRMP input pin - */ -extern void irmp_init (void); - -/** - * Get IRMP data - * @details gets decoded IRMP data - * @param pointer in order to store IRMP data - * @return TRUE: successful, FALSE: failed - */ -extern uint8_t irmp_get_data (IRMP_DATA *); - -/** - * ISR routine - * @details ISR routine, called 10000 times per second - */ -extern uint8_t irmp_ISR (void); - -#ifdef __cplusplus -} +#if IRMP_PROTOCOL_NAMES == 1 +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_ */