]> cloudbase.mooo.com Git - irmp.git/blob - irmp.h
fd027b9d6b792965f61fef451e9081ce00b2259d
[irmp.git] / irmp.h
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.h
3 *
4 * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irmp.h,v 1.98 2015/11/10 08:39:27 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 (STELLARIS_ARM_CORTEX_M4)
67 # define _CONCAT(a,b) a##b
68 # define CONCAT(a,b) _CONCAT(a,b)
69 # define IRMP_PORT_PERIPH CONCAT(SYSCTL_PERIPH_GPIO, IRMP_PORT_LETTER)
70 # define IRMP_PORT_BASE CONCAT(GPIO_PORT, CONCAT(IRMP_PORT_LETTER, _BASE))
71 # define IRMP_PORT_PIN CONCAT(GPIO_PIN_, IRMP_BIT_NUMBER)
72 # define IRMP_PIN IRMP_PORT_PIN
73 # define input(x) ((uint8_t)(ROM_GPIOPinRead(IRMP_PORT_BASE, IRMP_PORT_PIN)))
74 # define sei() IntMasterEnable()
75
76 #elif defined(__SDCC_stm8)
77 # define _CONCAT(a,b) a##b
78 # define CONCAT(a,b) _CONCAT(a,b)
79 # define IRMP_GPIO_STRUCT CONCAT(GPIO, IRMP_PORT_LETTER)
80 # define IRMP_BIT IRMP_BIT_NUMBER
81 # define input(x) ((x) & (1 << IRMP_BIT))
82
83 #endif
84
85 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
86 # undef IRMP_SUPPORT_MATSUSHITA_PROTOCOL
87 # define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 1
88 #endif
89
90 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
91 # warning DENON protocol conflicts wih RUWIDO, please enable only one of both protocols
92 # warning RUWIDO protocol disabled
93 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
94 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
95 #endif
96
97 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_ACP24_PROTOCOL == 1
98 # warning DENON protocol conflicts wih ACP24, please enable only one of both protocols
99 # warning ACP24 protocol disabled
100 # undef IRMP_SUPPORT_ACP24_PROTOCOL
101 # define IRMP_SUPPORT_ACP24_PROTOCOL 0
102 #endif
103
104 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 && IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
105 # warning RC6 protocol conflicts wih ROOMBA, please enable only one of both protocols
106 # warning ROOMBA protocol disabled
107 # undef IRMP_SUPPORT_ROOMBA_PROTOCOL
108 # define IRMP_SUPPORT_ROOMBA_PROTOCOL 0
109 #endif
110
111 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
112 # warning RC5 protocol conflicts wih ORTEK, please enable only one of both protocols
113 # warning ORTEK protocol disabled
114 # undef IRMP_SUPPORT_ORTEK_PROTOCOL
115 # define IRMP_SUPPORT_ORTEK_PROTOCOL 0
116 #endif
117
118 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_S100_PROTOCOL == 1
119 # warning RC5 protocol conflicts wih S100, please enable only one of both protocols
120 # warning S100 protocol disabled
121 # undef IRMP_SUPPORT_S100_PROTOCOL
122 # define IRMP_SUPPORT_S100_PROTOCOL 0
123 #endif
124
125 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 && IRMP_SUPPORT_FAN_PROTOCOL == 1
126 # warning NUBERT protocol conflicts wih FAN, please enable only one of both protocols
127 # warning FAN protocol disabled
128 # undef IRMP_SUPPORT_FAN_PROTOCOL
129 # define IRMP_SUPPORT_FAN_PROTOCOL 0
130 #endif
131
132 #if IRMP_SUPPORT_FDC_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
133 # warning FDC protocol conflicts wih ORTEK, please enable only one of both protocols
134 # warning ORTEK protocol disabled
135 # undef IRMP_SUPPORT_ORTEK_PROTOCOL
136 # define IRMP_SUPPORT_ORTEK_PROTOCOL 0
137 #endif
138
139 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 && IRMP_SUPPORT_NETBOX_PROTOCOL == 1
140 # warning ORTEK protocol conflicts wih NETBOX, please enable only one of both protocols
141 # warning NETBOX protocol disabled
142 # undef IRMP_SUPPORT_NETBOX_PROTOCOL
143 # define IRMP_SUPPORT_NETBOX_PROTOCOL 0
144 #endif
145
146 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
147 # warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
148 # undef IRMP_SUPPORT_SIEMENS_PROTOCOL
149 # define IRMP_SUPPORT_SIEMENS_PROTOCOL 0
150 #endif
151
152 #if IRMP_SUPPORT_RUWIDO_PROTOCOL == 1 && F_INTERRUPTS < 15000
153 # warning F_INTERRUPTS too low, RUWIDO protocol disabled (should be at least 15000)
154 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
155 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
156 #endif
157
158 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
159 # warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
160 # undef IRMP_SUPPORT_RECS80_PROTOCOL
161 # define IRMP_SUPPORT_RECS80_PROTOCOL 0
162 #endif
163
164 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
165 # warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
166 # undef IRMP_SUPPORT_RECS80EXT_PROTOCOL
167 # define IRMP_SUPPORT_RECS80EXT_PROTOCOL 0
168 #endif
169
170 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
171 # warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
172 # undef IRMP_SUPPORT_LEGO_PROTOCOL
173 # define IRMP_SUPPORT_LEGO_PROTOCOL 0
174 #endif
175
176 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 0
177 # warning SAMSUNG48 protocol needs also SAMSUNG protocol, SAMSUNG protocol enabled
178 # undef IRMP_SUPPORT_SAMSUNG_PROTOCOL
179 # define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1
180 #endif
181
182 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
183 # warning JVC protocol needs also NEC protocol, NEC protocol enabled
184 # undef IRMP_SUPPORT_NEC_PROTOCOL
185 # define IRMP_SUPPORT_NEC_PROTOCOL 1
186 #endif
187
188 #if IRMP_SUPPORT_NEC16_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
189 # warning NEC16 protocol needs also NEC protocol, NEC protocol enabled
190 # undef IRMP_SUPPORT_NEC_PROTOCOL
191 # define IRMP_SUPPORT_NEC_PROTOCOL 1
192 #endif
193
194 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
195 # warning NEC42 protocol needs also NEC protocol, NEC protocol enabled
196 # undef IRMP_SUPPORT_NEC_PROTOCOL
197 # define IRMP_SUPPORT_NEC_PROTOCOL 1
198 #endif
199
200 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
201 # warning LGAIR protocol needs also NEC protocol, NEC protocol enabled
202 # undef IRMP_SUPPORT_NEC_PROTOCOL
203 # define IRMP_SUPPORT_NEC_PROTOCOL 1
204 #endif
205
206 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 && F_INTERRUPTS < 20000
207 # warning F_INTERRUPTS too low, RCMM protocol disabled (should be at least 20000)
208 # undef IRMP_SUPPORT_RCMM_PROTOCOL
209 # define IRMP_SUPPORT_RCMM_PROTOCOL 0
210 #endif
211
212 #if F_INTERRUPTS > 20000
213 #error F_INTERRUPTS too high (should be not greater than 20000)
214 #endif
215
216 #include "irmpprotocols.h"
217
218 #define IRMP_FLAG_REPETITION 0x01
219
220 extern void irmp_init (void);
221 extern uint_fast8_t irmp_get_data (IRMP_DATA *);
222 extern uint_fast8_t irmp_ISR (void);
223
224 #if IRMP_PROTOCOL_NAMES == 1
225 extern const char * const irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM;
226 #endif
227
228 #if IRMP_USE_CALLBACK == 1
229 extern void irmp_set_callback_ptr (void (*cb)(uint_fast8_t));
230 #endif // IRMP_USE_CALLBACK == 1
231
232 #endif /* _IRMP_H_ */