]> cloudbase.mooo.com Git - irmp.git/blob - irmp.h
b529b0647f9701abcb546fcf42b46e9d7406e8a1
[irmp.git] / irmp.h
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.h
3 *
4 * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irmp.h,v 1.82 2013/04/09 11:55:39 fm Exp $
7 *
8 * ATMEGA88 @ 8 MHz
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *---------------------------------------------------------------------------------------------------------------------------------------------------
15 */
16
17 #ifndef _IRMP_H_
18 #define _IRMP_H_
19
20 #include "irmpsystem.h"
21
22 #ifndef IRMP_USE_AS_LIB
23 # include "irmpconfig.h"
24 #endif
25
26 #if defined (ATMEL_AVR)
27 # define _CONCAT(a,b) a##b
28 # define CONCAT(a,b) _CONCAT(a,b)
29 # define IRMP_PORT CONCAT(PORT, IRMP_PORT_LETTER)
30 # define IRMP_DDR CONCAT(DDR, IRMP_PORT_LETTER)
31 # define IRMP_PIN CONCAT(PIN, IRMP_PORT_LETTER)
32 # define IRMP_BIT IRMP_BIT_NUMBER
33 # define input(x) ((x) & (1 << IRMP_BIT))
34 #elif defined (PIC_C18)
35 # define input(x) (x)
36 #elif defined (PIC_CCS)
37 # define input(x) (x)
38 #elif defined (ARM_STM32)
39 # define _CONCAT(a,b) a##b
40 # define CONCAT(a,b) _CONCAT(a,b)
41 # define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)
42 # if defined (ARM_STM32L1XX)
43 # define IRMP_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRMP_PORT_LETTER)
44 # elif defined (ARM_STM32F10X)
45 # define IRMP_PORT_RCC CONCAT(RCC_APB2Periph_GPIO, IRMP_PORT_LETTER)
46 # elif defined (ARM_STM32F4XX)
47 # define IRMP_PORT_RCC CONCAT(RCC_AHB1Periph_GPIO, IRMP_PORT_LETTER)
48 # endif
49 # define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)
50 # define IRMP_PIN IRMP_PORT // for use with input(x) below
51 # define input(x) (GPIO_ReadInputDataBit(x, IRMP_BIT))
52 # ifndef USE_STDPERIPH_DRIVER
53 # warning The STM32 port of IRMP uses the ST standard peripheral drivers which are not enabled in your build configuration.
54 # endif
55 #elif defined (STELLARIS_ARM_CORTEX_M4)
56 # define _CONCAT(a,b) a##b
57 # define CONCAT(a,b) _CONCAT(a,b)
58 # define IRMP_PORT_PERIPH CONCAT(SYSCTL_PERIPH_GPIO, IRMP_PORT_LETTER)
59 # define IRMP_PORT_BASE CONCAT(GPIO_PORT, CONCAT(IRMP_PORT_LETTER, _BASE))
60 # define IRMP_PORT_PIN CONCAT(GPIO_PIN_, IRMP_BIT_NUMBER)
61 # define IRMP_PIN IRMP_PORT_PIN
62 # define input(x) ((uint8_t)(ROM_GPIOPinRead(IRMP_PORT_BASE, IRMP_PORT_PIN)))
63 # define sei() IntMasterEnable()
64 #endif
65
66 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
67 # warning DENON protocol conflicts wih RUWIDO, please enable only one of both protocols
68 # warning RUWIDO protocol disabled
69 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
70 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
71 #endif
72
73 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 && IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
74 # warning RC6 protocol conflicts wih ROOMBA, please enable only one of both protocols
75 # warning ROOMBA protocol disabled
76 # undef IRMP_SUPPORT_ROOMBA_PROTOCOL
77 # define IRMP_SUPPORT_ROOMBA_PROTOCOL 0
78 #endif
79
80 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
81 # warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
82 # undef IRMP_SUPPORT_SIEMENS_PROTOCOL
83 # define IRMP_SUPPORT_SIEMENS_PROTOCOL 0
84 #endif
85
86 #if IRMP_SUPPORT_RUWIDO_PROTOCOL == 1 && F_INTERRUPTS < 15000
87 # warning F_INTERRUPTS too low, RUWIDO protocol disabled (should be at least 15000)
88 # undef IRMP_SUPPORT_RUWIDO_PROTOCOL
89 # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0
90 #endif
91
92 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
93 # warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
94 # undef IRMP_SUPPORT_RECS80_PROTOCOL
95 # define IRMP_SUPPORT_RECS80_PROTOCOL 0
96 #endif
97
98 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
99 # warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
100 # undef IRMP_SUPPORT_RECS80EXT_PROTOCOL
101 # define IRMP_SUPPORT_RECS80EXT_PROTOCOL 0
102 #endif
103
104 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
105 # warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
106 # undef IRMP_SUPPORT_LEGO_PROTOCOL
107 # define IRMP_SUPPORT_LEGO_PROTOCOL 0
108 #endif
109
110 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
111 # warning JVC protocol needs also NEC protocol, NEC protocol enabled
112 # undef IRMP_SUPPORT_NEC_PROTOCOL
113 # define IRMP_SUPPORT_NEC_PROTOCOL 1
114 #endif
115
116 #if IRMP_SUPPORT_NEC16_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
117 # warning NEC16 protocol needs also NEC protocol, NEC protocol enabled
118 # undef IRMP_SUPPORT_NEC_PROTOCOL
119 # define IRMP_SUPPORT_NEC_PROTOCOL 1
120 #endif
121
122 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0
123 # warning NEC42 protocol needs also NEC protocol, NEC protocol enabled
124 # undef IRMP_SUPPORT_NEC_PROTOCOL
125 # define IRMP_SUPPORT_NEC_PROTOCOL 1
126 #endif
127
128 #if F_INTERRUPTS > 20000
129 #error F_INTERRUPTS too high (should be not greater than 20000)
130 #endif
131
132 #include "irmpprotocols.h"
133
134 #define IRMP_FLAG_REPETITION 0x01
135
136 extern void irmp_init (void);
137 extern uint8_t irmp_get_data (IRMP_DATA *);
138 extern uint8_t irmp_is_busy (void);
139 extern uint8_t irmp_ISR (void);
140
141 #if IRMP_PROTOCOL_NAMES == 1
142 extern char * irmp_protocol_names[IRMP_N_PROTOCOLS + 1];
143 #endif
144
145 #if IRMP_USE_CALLBACK == 1
146 extern void irmp_set_callback_ptr (void (*cb)(uint8_t));
147 #endif // IRMP_USE_CALLBACK == 1
148
149 #endif /* _IRMP_H_ */