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