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