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