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