]> cloudbase.mooo.com Git - irmp.git/blob - irsnd.h
Version 2.3.0: some timer and variable name corrections
[irmp.git] / irsnd.h
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irsnd.h
3 *
4 * Copyright (c) 2010-2012 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irsnd.h,v 1.13 2012/06/05 12:00:46 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 IRSND_PIN TRISCbits.TRISC1 // RC1 = PWM2
57 # define SetDCPWM(x) SetDCPWM2(x)
58 # define ClosePWM ClosePWM2
59 # define OpenPWM(x) OpenPWM2(x)
60 # endif
61 # if IRSND_OCx == IRSND_PIC_CCP1
62 # define IRSND_PIN TRISCbits.TRISC2 // RC2 = PWM1
63 # define SetDCPWM(x) SetDCPWM1(x)
64 # define ClosePWM ClosePWM1
65 # define OpenPWM(x) OpenPWM1(x)
66 # endif
67 //Setup macro for OpenTimer with defined Pre_Scaler
68 # if Pre_Scaler == 1
69 # define OpenTimer OpenTimer2(TIMER_INT_OFF & T2_PS_1_1);
70 # elif Pre_Scaler == 4
71 # define OpenTimer OpenTimer2(TIMER_INT_OFF & T2_PS_1_4);
72 # elif Pre_Scaler == 16
73 # define OpenTimer OpenTimer2(TIMER_INT_OFF & T2_PS_1_16);
74 # else
75 # error Incorrect value for Pre_Scaler
76 # endif
77 #endif // ARM_STM32
78
79 #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000
80 # warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)
81 # undef IRSND_SUPPORT_SIEMENS_PROTOCOL
82 # define IRSND_SUPPORT_SIEMENS_PROTOCOL 0
83 #endif
84
85 #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 20000
86 # warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 20000)
87 # undef IRSND_SUPPORT_RECS80_PROTOCOL
88 # define IRSND_SUPPORT_RECS80_PROTOCOL 0
89 #endif
90
91 #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 20000
92 # warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 20000)
93 # undef IRSND_SUPPORT_RECS80EXT_PROTOCOL
94 # define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0
95 #endif
96
97 #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000
98 # warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)
99 # undef IRSND_SUPPORT_LEGO_PROTOCOL
100 # define IRSND_SUPPORT_LEGO_PROTOCOL 0
101 #endif
102
103 #include "irmpprotocols.h"
104
105 #define IRSND_NO_REPETITIONS 0 // no repetitions
106 #define IRSND_MAX_REPETITIONS 14 // max # of repetitions
107 #define IRSND_ENDLESS_REPETITION 15 // endless repetions
108 #define IRSND_REPETITION_MASK 0x0F // lower nibble of flags
109
110 extern void irsnd_init (void);
111 extern uint8_t irsnd_is_busy (void);
112 extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);
113 extern void irsnd_stop (void);
114 extern uint8_t irsnd_ISR (void);
115
116 #if IRSND_USE_CALLBACK == 1
117 extern void irsnd_set_callback_ptr (void (*cb)(uint8_t));
118 #endif // IRSND_USE_CALLBACK == 1
119
120 #endif /* _IRSND_H_ */