]> cloudbase.mooo.com Git - irmp.git/blob - irsnd.h
Version 2.9.7: added port to to ESP8266 and TEENSY, added PANASONIC protocol, added...
[irmp.git] / irsnd.h
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irsnd.h
3 *
4 * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irsnd.h,v 1.23 2015/11/18 08:27:50 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 _IRSND_H_
16 #define _IRSND_H_
17
18 #include "irmpsystem.h"
19 #ifndef IRSND_USE_AS_LIB
20 # include "irsndconfig.h"
21 #endif
22
23 #if defined (ARM_STM32) // STM32
24 # define _CONCAT(a,b) a##b
25 # define CONCAT(a,b) _CONCAT(a,b)
26 # define IRSND_PORT CONCAT(GPIO, IRSND_PORT_LETTER)
27 # if defined (ARM_STM32L1XX)
28 # define IRSND_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRSND_PORT_LETTER)
29 # define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)
30 # elif defined (ARM_STM32F10X)
31 # define IRSND_PORT_RCC CONCAT(RCC_APB2Periph_GPIO, IRSND_PORT_LETTER)
32 # elif defined (ARM_STM32F4XX)
33 # define IRSND_PORT_RCC CONCAT(RCC_AHB1Periph_GPIO, IRSND_PORT_LETTER)
34 # define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)
35 # endif
36 # define IRSND_BIT CONCAT(GPIO_Pin_, IRSND_BIT_NUMBER)
37 # define IRSND_TIMER CONCAT(TIM, IRSND_TIMER_NUMBER)
38 # define IRSND_TIMER_CHANNEL CONCAT(TIM_Channel_, IRSND_TIMER_CHANNEL_NUMBER)
39 # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))
40 # define IRSND_TIMER_RCC CONCAT(RCC_APB1Periph_TIM, IRSND_TIMER_NUMBER)
41 # elif (IRSND_TIMER_NUMBER == 1) || ((IRSND_TIMER_NUMBER >= 8) && (IRSND_TIMER_NUMBER <= 11))
42 # define IRSND_TIMER_RCC CONCAT(RCC_APB2Periph_TIM, IRSND_TIMER_NUMBER)
43 # else
44 # error IRSND_TIMER_NUMBER not valid.
45 # endif
46 # ifndef USE_STDPERIPH_DRIVER
47 # warning The STM32 port of IRSND uses the ST standard peripheral drivers which are not enabled in your build configuration.
48 # endif
49
50 #elif defined(PIC_C18)
51
52 # if defined(__12F1840)
53 // Do not change lines below unless you have a different HW. This example is for 12F1840
54 // setup macro for PWM used PWM module
55
56 //~ # define PWMon() TMR2=0,IRSND_PIN=1
57 //~ # define PWMoff() CCP1CON &=(~0b1100)
58 //~ # define PWMon() TMR2ON=1
59 //~ # define PWMoff() TMR2ON=0
60 #if defined(IRSND_DEBUG)
61 #define PWMon() LATA0=1
62 #define PWMoff() LATA0=0
63 #define IRSND_PIN LATA0
64 #else
65 # define PWMon() TMR2=0,CCP1CON |=0b1100
66 # define PWMoff() CCP1CON &=(~0b1100)
67 # define IRSND_PIN RA2
68 #endif
69
70 #else
71 // Do not change lines below until you have a different HW. Example is for 18F2550/18F4550
72 // setup macro for PWM used PWM module
73 # if IRSND_OCx == IRSND_PIC_CCP2
74 # define PWMon() TMR2=0,CCP2CON |=0b1100
75 # define PWMoff() CCP2CON &=(~0b1100)
76 # define IRSND_PIN TRISCbits.TRISC1 // RC1 = PWM2
77 # define SetDCPWM(x) SetDCPWM2(x)
78 # define ClosePWM ClosePWM2
79 # define OpenPWM(x) OpenPWM2(x)
80 # endif
81 # if IRSND_OCx == IRSND_PIC_CCP1
82 # define PWMon() TMR2=0,CCP1CON |=0b1100
83 # define PWMoff() CCP1CON &=(~0b1100)
84 # define IRSND_PIN TRISCbits.TRISC2 // RC2 = PWM1
85 # define SetDCPWM(x) SetDCPWM1(x)
86 # define ClosePWM ClosePWM1
87 # define OpenPWM(x) OpenPWM1(x)
88 # endif
89 # endif
90 # endif // PIC_C18
91
92 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
93 # warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
94 # undef IRSND_SUPPORT_SIEMENS_PROTOCOL
95 # define IRSND_SUPPORT_SIEMENS_PROTOCOL 0
96 #endif
97
98 #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 && F_INTERRUPTS < 15000
99 # warning F_INTERRUPTS too low, A1TVBOX protocol disabled (should be at least 15000)
100 # undef IRSND_SUPPORT_A1TVBOX_PROTOCOL
101 # define IRSND_SUPPORT_A1TVBOX_PROTOCOL 0
102 #endif
103
104 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000
105 # warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)
106 # undef IRSND_SUPPORT_RECS80_PROTOCOL
107 # define IRSND_SUPPORT_RECS80_PROTOCOL 0
108 #endif
109
110 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000
111 # warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)
112 # undef IRSND_SUPPORT_RECS80EXT_PROTOCOL
113 # define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0
114 #endif
115
116 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
117 # warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
118 # undef IRSND_SUPPORT_LEGO_PROTOCOL
119 # define IRSND_SUPPORT_LEGO_PROTOCOL 0
120 #endif
121
122 #include "irmpprotocols.h"
123
124 #define IRSND_NO_REPETITIONS 0 // no repetitions
125 #define IRSND_MAX_REPETITIONS 14 // max # of repetitions
126 #define IRSND_ENDLESS_REPETITION 15 // endless repetions
127 #define IRSND_REPETITION_MASK 0x0F // lower nibble of flags
128
129 #ifdef __cplusplus
130 extern "C"
131 {
132 #endif
133
134 extern void irsnd_init (void);
135 extern uint8_t irsnd_is_busy (void);
136 extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);
137 extern void irsnd_stop (void);
138 extern uint8_t irsnd_ISR (void);
139
140 #if IRSND_USE_CALLBACK == 1
141 extern void irsnd_set_callback_ptr (void (*cb)(uint8_t));
142 #endif // IRSND_USE_CALLBACK == 1
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif /* _IRSND_H_ */