]> sigrok.org Git - libsigrokdecode.git/blame - irmp/irmp.h
lpc: improve performance, use proper .wait() condition
[libsigrokdecode.git] / irmp / irmp.h
CommitLineData
6ea75aa1
GS
1/*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.h
3 *
4 * Copyright (c) 2009-2019 Frank Meyer - frank(at)fli4l.de
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *---------------------------------------------------------------------------------------------------------------------------------------------------
11 */
12
13#ifndef _IRMP_H_
14#define _IRMP_H_
15
16#ifndef IRMP_USE_AS_LIB
17# define IRMPCONFIG_STAGE1_H
18# include "irmpconfig.h"
19# undef IRMPCONFIG_STAGE1_H
20#endif
21
22#include "irmpsystem.h"
23
24#ifndef IRMP_USE_AS_LIB
25# define IRMPCONFIG_STAGE2_H
26# include "irmpconfig.h"
27# undef IRMPCONFIG_STAGE2_H
28#endif
29
30#if defined (__AVR_XMEGA__)
31# define _CONCAT(a,b) a##b
32# define CONCAT(a,b) _CONCAT(a,b)
33# define IRMP_PORT_PRE CONCAT(PORT, IRMP_PORT_LETTER)
34# define IRMP_DDR_PRE CONCAT(PORT, IRMP_PORT_LETTER)
35# define IRMP_PIN_PRE CONCAT(PORT, IRMP_PORT_LETTER)
36# define IRMP_PORT IRMP_PORT_PRE.OUT
37# define IRMP_DDR IRMP_DDR_PRE.DIR
38# define IRMP_PIN IRMP_PIN_PRE.IN
39# define IRMP_BIT IRMP_BIT_NUMBER
40# define input(x) ((x) & (1 << IRMP_BIT))
41
42#elif defined (ATMEL_AVR)
43# define _CONCAT(a,b) a##b
44# define CONCAT(a,b) _CONCAT(a,b)
45# define IRMP_PORT CONCAT(PORT, IRMP_PORT_LETTER)
46# define IRMP_DDR CONCAT(DDR, IRMP_PORT_LETTER)
47# define IRMP_PIN CONCAT(PIN, IRMP_PORT_LETTER)
48# define IRMP_BIT IRMP_BIT_NUMBER
49# define input(x) ((x) & (1 << IRMP_BIT))
50
51#elif defined (PIC_C18) || defined (PIC_CCS)
52# define input(x) (x)
53
54#elif defined (ARM_STM32)
55# define _CONCAT(a,b) a##b
56# define CONCAT(a,b) _CONCAT(a,b)
57# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)
58# if defined (ARM_STM32L1XX)
59# define IRMP_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRMP_PORT_LETTER)
60# elif defined (ARM_STM32F10X)
61# define IRMP_PORT_RCC CONCAT(RCC_APB2Periph_GPIO, IRMP_PORT_LETTER)
62# elif defined (ARM_STM32F4XX)
63# define IRMP_PORT_RCC CONCAT(RCC_AHB1Periph_GPIO, IRMP_PORT_LETTER)
64# endif
65# define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)
66# define IRMP_PIN IRMP_PORT // for use with input(x) below
67# define input(x) (GPIO_ReadInputDataBit(x, IRMP_BIT))
68# ifndef USE_STDPERIPH_DRIVER
69# warning The STM32 port of IRMP uses the ST standard peripheral drivers which are not enabled in your build configuration.
70# endif
71
72#elif defined (ARM_STM32_HAL)
73# define IRMP_BIT IRMP_BIT_NUMBER
74# define IRMP_PIN IRMP_BIT_NUMBER // for use with input(x) below
75# define input(x) HAL_GPIO_ReadPin(IRMP_PORT_LETTER, x)
76
77#elif defined (STELLARIS_ARM_CORTEX_M4)
78# define _CONCAT(a,b) a##b
79# define CONCAT(a,b) _CONCAT(a,b)
80# define IRMP_PORT_PERIPH CONCAT(SYSCTL_PERIPH_GPIO, IRMP_PORT_LETTER)
81# define IRMP_PORT_BASE CONCAT(GPIO_PORT, CONCAT(IRMP_PORT_LETTER, _BASE))
82# define IRMP_PORT_PIN CONCAT(GPIO_PIN_, IRMP_BIT_NUMBER)
83# define IRMP_PIN IRMP_PORT_PIN
84# define input(x) ((uint8_t)(ROM_GPIOPinRead(IRMP_PORT_BASE, IRMP_PORT_PIN)))
85# define sei() IntMasterEnable()
86
87#elif defined(__SDCC_stm8)
88# define _CONCAT(a,b) a##b
89# define CONCAT(a,b) _CONCAT(a,b)
90# define IRMP_GPIO_STRUCT CONCAT(GPIO, IRMP_PORT_LETTER)
91# define IRMP_BIT IRMP_BIT_NUMBER
92# define input(x) ((x) & (1 << IRMP_BIT))
93
94#elif defined (TEENSY_ARM_CORTEX_M4)
95# define input(x) ((uint8_t)(digitalReadFast(x)))
96
97#elif defined(__xtensa__)
98# define IRMP_BIT IRMP_BIT_NUMBER
99# define input(x) GPIO_INPUT_GET(IRMP_BIT_NUMBER)
100
101#elif defined(_CHIBIOS_HAL_)
102# define input(x) palReadLine(x)
103
104#endif
105
106#if IRMP_USE_IDLE_CALL == 1
107void irmp_idle(void); // the user has to provide an implementation of the irmp_idle() function and link it
108#endif
109
110#if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
111# undef IRMP_SUPPORT_MATSUSHITA_PROTOCOL
112# define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 1
113#endif
114
115#if IRMP_32_BIT == 0 && IRMP_SUPPORT_MERLIN_PROTOCOL == 1
116# undef IRMP_SUPPORT_MERLIN_PROTOCOL
117# warning MERLIN protocol disabled, IRMP_32_BIT=1 needed
118#endif
119
120#if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
121# warning DENON protocol conflicts wih RUWIDO, please enable only one of both protocols
122# warning RUWIDO protocol disabled
123# undef IRMP_SUPPORT_RUWIDO_PROTOCOL
124# define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
125#endif
126
127#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 && IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
128# warning KASEIKYO protocol conflicts wih PANASONIC, please enable only one of both protocols
129# warning PANASONIC protocol disabled
130# undef IRMP_SUPPORT_PANASONIC_PROTOCOL
131# define IRMP_SUPPORT_PANASONIC_PROTOCOL 0
132#endif
133
134#if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_ACP24_PROTOCOL == 1
135# warning DENON protocol conflicts wih ACP24, please enable only one of both protocols
136# warning ACP24 protocol disabled
137# undef IRMP_SUPPORT_ACP24_PROTOCOL
138# define IRMP_SUPPORT_ACP24_PROTOCOL 0
139#endif
140
141#if IRMP_SUPPORT_RC6_PROTOCOL == 1 && IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
142# warning RC6 protocol conflicts wih ROOMBA, please enable only one of both protocols
143# warning ROOMBA protocol disabled
144# undef IRMP_SUPPORT_ROOMBA_PROTOCOL
145# define IRMP_SUPPORT_ROOMBA_PROTOCOL 0
146#endif
147
148#if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 && IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
149# warning PANASONIC protocol conflicts wih MITSU_HEAVY, please enable only one of both protocols
150# warning MITSU_HEAVY protocol disabled
151# undef IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL
152# define IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL 0
153#endif
154
155#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
156# warning RC5 protocol conflicts wih ORTEK, please enable only one of both protocols
157# warning ORTEK protocol disabled
158# undef IRMP_SUPPORT_ORTEK_PROTOCOL
159# define IRMP_SUPPORT_ORTEK_PROTOCOL 0
160#endif
161
162#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_S100_PROTOCOL == 1
163# warning RC5 protocol conflicts wih S100, please enable only one of both protocols
164# warning S100 protocol disabled
165# undef IRMP_SUPPORT_S100_PROTOCOL
166# define IRMP_SUPPORT_S100_PROTOCOL 0
167#endif
168
169#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 && IRMP_SUPPORT_FAN_PROTOCOL == 1
170# warning NUBERT protocol conflicts wih FAN, please enable only one of both protocols
171# warning FAN protocol disabled
172# undef IRMP_SUPPORT_FAN_PROTOCOL
173# define IRMP_SUPPORT_FAN_PROTOCOL 0
174#endif
175
176#if IRMP_SUPPORT_FDC_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
177# warning FDC protocol conflicts wih ORTEK, please enable only one of both protocols
178# warning ORTEK protocol disabled
179# undef IRMP_SUPPORT_ORTEK_PROTOCOL
180# define IRMP_SUPPORT_ORTEK_PROTOCOL 0
181#endif
182
183#if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 && IRMP_SUPPORT_NETBOX_PROTOCOL == 1
184# warning ORTEK protocol conflicts wih NETBOX, please enable only one of both protocols
185# warning NETBOX protocol disabled
186# undef IRMP_SUPPORT_NETBOX_PROTOCOL
187# define IRMP_SUPPORT_NETBOX_PROTOCOL 0
188#endif
189
190#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 && IRMP_SUPPORT_RCII_PROTOCOL == 1
191# warning GRUNDIG protocol conflicts wih RCII, please enable only one of both protocols
192# warning RCII protocol disabled
193# undef IRMP_SUPPORT_RCII_PROTOCOL
194# define IRMP_SUPPORT_RCII_PROTOCOL 0
195#endif
196
197#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1 && IRMP_SUPPORT_RCII_PROTOCOL == 1
198# warning NOKIA protocol conflicts wih RCII, please enable only one of both protocols
199# warning RCII protocol disabled
200# undef IRMP_SUPPORT_RCII_PROTOCOL
201# define IRMP_SUPPORT_RCII_PROTOCOL 0
202#endif
203
204#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
205# warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
206# undef IRMP_SUPPORT_SIEMENS_PROTOCOL
207# define IRMP_SUPPORT_SIEMENS_PROTOCOL 0
208#endif
209
210#if IRMP_SUPPORT_RUWIDO_PROTOCOL == 1 && F_INTERRUPTS < 15000
211# warning F_INTERRUPTS too low, RUWIDO protocol disabled (should be at least 15000)
212# undef IRMP_SUPPORT_RUWIDO_PROTOCOL
213# define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
214#endif
215
216#if IRMP_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
217# warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
218# undef IRMP_SUPPORT_RECS80_PROTOCOL
219# define IRMP_SUPPORT_RECS80_PROTOCOL 0
220#endif
221
222#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
223# warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
224# undef IRMP_SUPPORT_RECS80EXT_PROTOCOL
225# define IRMP_SUPPORT_RECS80EXT_PROTOCOL 0
226#endif
227
228#if IRMP_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
229# warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
230# undef IRMP_SUPPORT_LEGO_PROTOCOL
231# define IRMP_SUPPORT_LEGO_PROTOCOL 0
232#endif
233
234#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 0
235# warning SAMSUNG48 protocol needs also SAMSUNG protocol, SAMSUNG protocol enabled
236# undef IRMP_SUPPORT_SAMSUNG_PROTOCOL
237# define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1
238#endif
239
240#if IRMP_SUPPORT_JVC_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
241# warning JVC protocol needs also NEC protocol, NEC protocol enabled
242# undef IRMP_SUPPORT_NEC_PROTOCOL
243# define IRMP_SUPPORT_NEC_PROTOCOL 1
244#endif
245
246#if IRMP_SUPPORT_NEC16_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
247# warning NEC16 protocol needs also NEC protocol, NEC protocol enabled
248# undef IRMP_SUPPORT_NEC_PROTOCOL
249# define IRMP_SUPPORT_NEC_PROTOCOL 1
250#endif
251
252#if IRMP_SUPPORT_NEC42_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
253# warning NEC42 protocol needs also NEC protocol, NEC protocol enabled
254# undef IRMP_SUPPORT_NEC_PROTOCOL
255# define IRMP_SUPPORT_NEC_PROTOCOL 1
256#endif
257
258#if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
259# warning LGAIR protocol needs also NEC protocol, NEC protocol enabled
260# undef IRMP_SUPPORT_NEC_PROTOCOL
261# define IRMP_SUPPORT_NEC_PROTOCOL 1
262#endif
263
264#if IRMP_SUPPORT_RCMM_PROTOCOL == 1 && F_INTERRUPTS < 20000
265# warning F_INTERRUPTS too low, RCMM protocol disabled (should be at least 20000)
266# undef IRMP_SUPPORT_RCMM_PROTOCOL
267# define IRMP_SUPPORT_RCMM_PROTOCOL 0
268#endif
269
270#if IRMP_SUPPORT_PENTAX_PROTOCOL == 1 && F_INTERRUPTS > 16000
271# warning F_INTERRUPTS too high, PENTAX protocol disabled (should be max 16000)
272# undef IRMP_SUPPORT_PENTAX_PROTOCOL
273# define IRMP_SUPPORT_PENTAX_PROTOCOL 0
274#endif
275
276#if IRMP_SUPPORT_GREE_PROTOCOL == 1 && F_INTERRUPTS > 16000
277# warning F_INTERRUPTS too high, GREE protocol disabled (should be max 16000)
278# undef IRMP_SUPPORT_GREE_PROTOCOL
279# define IRMP_SUPPORT_GREE_PROTOCOL 0
280#endif
281
282#if F_INTERRUPTS > 20000
283#error F_INTERRUPTS too high (should be not greater than 20000)
284#endif
285
286#include "irmpprotocols.h"
287
288#define IRMP_FLAG_REPETITION 0x01
289
290#ifdef __cplusplus
291extern "C"
292{
293#endif
294
295extern void irmp_init (void);
296extern uint_fast8_t irmp_get_data (IRMP_DATA *);
297extern uint_fast8_t irmp_ISR (void);
298
299#if IRMP_PROTOCOL_NAMES == 1
300extern const char * const irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM;
301#endif
302
303#if IRMP_USE_CALLBACK == 1
304extern void irmp_set_callback_ptr (void (*cb)(uint_fast8_t));
305#endif // IRMP_USE_CALLBACK == 1
306
307#ifdef __cplusplus
308}
309#endif
310
311#endif /* _IRMP_H_ */