]> cloudbase.mooo.com Git - irmp.git/blob - irmp.h
Version 2.8.2: corrections of AVR XMEGA port
[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.94 2015/05/07 06:51:10 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 #endif
77
78 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
79 # warning DENON protocol conflicts wih RUWIDO, please enable only one of both protocols
80 # warning RUWIDO protocol disabled
81 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
82 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
83 #endif
84
85 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 && IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
86 # warning RC6 protocol conflicts wih ROOMBA, please enable only one of both protocols
87 # warning ROOMBA protocol disabled
88 # undef IRMP_SUPPORT_ROOMBA_PROTOCOL
89 # define IRMP_SUPPORT_ROOMBA_PROTOCOL 0
90 #endif
91
92 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
93 # warning RC5 protocol conflicts wih ORTEK, please enable only one of both protocols
94 # warning ORTEK protocol disabled
95 # undef IRMP_SUPPORT_ORTEK_PROTOCOL
96 # define IRMP_SUPPORT_ORTEK_PROTOCOL 0
97 #endif
98
99 #if IRMP_SUPPORT_FDC_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
100 # warning FDC protocol conflicts wih ORTEK, please enable only one of both protocols
101 # warning ORTEK protocol disabled
102 # undef IRMP_SUPPORT_ORTEK_PROTOCOL
103 # define IRMP_SUPPORT_ORTEK_PROTOCOL 0
104 #endif
105
106 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 && IRMP_SUPPORT_NETBOX_PROTOCOL == 1
107 # warning ORTEK protocol conflicts wih NETBOX, please enable only one of both protocols
108 # warning NETBOX protocol disabled
109 # undef IRMP_SUPPORT_NETBOX_PROTOCOL
110 # define IRMP_SUPPORT_NETBOX_PROTOCOL 0
111 #endif
112
113 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
114 # warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
115 # undef IRMP_SUPPORT_SIEMENS_PROTOCOL
116 # define IRMP_SUPPORT_SIEMENS_PROTOCOL 0
117 #endif
118
119 #if IRMP_SUPPORT_RUWIDO_PROTOCOL == 1 && F_INTERRUPTS < 15000
120 # warning F_INTERRUPTS too low, RUWIDO protocol disabled (should be at least 15000)
121 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
122 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
123 #endif
124
125 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
126 # warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
127 # undef IRMP_SUPPORT_RECS80_PROTOCOL
128 # define IRMP_SUPPORT_RECS80_PROTOCOL 0
129 #endif
130
131 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
132 # warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
133 # undef IRMP_SUPPORT_RECS80EXT_PROTOCOL
134 # define IRMP_SUPPORT_RECS80EXT_PROTOCOL 0
135 #endif
136
137 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
138 # warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
139 # undef IRMP_SUPPORT_LEGO_PROTOCOL
140 # define IRMP_SUPPORT_LEGO_PROTOCOL 0
141 #endif
142
143 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 0
144 # warning SAMSUNG48 protocol needs also SAMSUNG protocol, SAMSUNG protocol enabled
145 # undef IRMP_SUPPORT_SAMSUNG_PROTOCOL
146 # define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1
147 #endif
148
149 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
150 # warning JVC protocol needs also NEC protocol, NEC protocol enabled
151 # undef IRMP_SUPPORT_NEC_PROTOCOL
152 # define IRMP_SUPPORT_NEC_PROTOCOL 1
153 #endif
154
155 #if IRMP_SUPPORT_NEC16_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
156 # warning NEC16 protocol needs also NEC protocol, NEC protocol enabled
157 # undef IRMP_SUPPORT_NEC_PROTOCOL
158 # define IRMP_SUPPORT_NEC_PROTOCOL 1
159 #endif
160
161 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
162 # warning NEC42 protocol needs also NEC protocol, NEC protocol enabled
163 # undef IRMP_SUPPORT_NEC_PROTOCOL
164 # define IRMP_SUPPORT_NEC_PROTOCOL 1
165 #endif
166
167 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
168 # warning LGAIR protocol needs also NEC protocol, NEC protocol enabled
169 # undef IRMP_SUPPORT_NEC_PROTOCOL
170 # define IRMP_SUPPORT_NEC_PROTOCOL 1
171 #endif
172
173 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 && F_INTERRUPTS < 20000
174 # warning F_INTERRUPTS too low, RCMM protocol disabled (should be at least 20000)
175 # undef IRMP_SUPPORT_RCMM_PROTOCOL
176 # define IRMP_SUPPORT_RCMM_PROTOCOL 0
177 #endif
178
179 #if F_INTERRUPTS > 20000
180 #error F_INTERRUPTS too high (should be not greater than 20000)
181 #endif
182
183 #include "irmpprotocols.h"
184
185 #define IRMP_FLAG_REPETITION 0x01
186
187 extern void irmp_init (void);
188 extern uint_fast8_t irmp_get_data (IRMP_DATA *);
189 extern uint_fast8_t irmp_ISR (void);
190
191 #if IRMP_PROTOCOL_NAMES == 1
192 extern const char * const irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM;
193 #endif
194
195 #if IRMP_USE_CALLBACK == 1
196 extern void irmp_set_callback_ptr (void (*cb)(uint_fast8_t));
197 #endif // IRMP_USE_CALLBACK == 1
198
199 #endif /* _IRMP_H_ */