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