-/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ /*---------------------------------------------------------------------------------------------------------------------------------------------------\r
* irsnd.h\r
*\r
- * Copyright (c) 2010-2011 Frank Meyer - frank(at)fli4l.de\r
+ * Copyright (c) 2010-2014 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irsnd.h,v 1.4 2011/04/11 12:54:25 fm Exp $\r
- *\r
- * ATMEGA88 @ 8 MHz\r
+ * $Id: irsnd.h,v 1.20 2014/09/15 10:27:38 fm Exp $\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
*---------------------------------------------------------------------------------------------------------------------------------------------------\r
*/\r
\r
-#ifndef _WC_IRSND_H_\r
-#define _WC_IRSND_H_\r
+#ifndef _IRSND_H_\r
+#define _IRSND_H_\r
\r
-/**\r
- * Initialize ISND encoder\r
- * @details Configures ISDN output pin\r
- */\r
-extern void irsnd_init (void);\r
+#include "irmpsystem.h"\r
+#ifndef IRSND_USE_AS_LIB\r
+# include "irsndconfig.h"\r
+#endif\r
\r
-/**\r
- * Check if sender is busy\r
- * @details checks if sender is busy\r
- * @return TRUE: sender is busy, FALSE: sender is not busy\r
- */\r
-extern uint8_t irsnd_is_busy (void);\r
+#if defined (ARM_STM32) // STM32\r
+# define _CONCAT(a,b) a##b\r
+# define CONCAT(a,b) _CONCAT(a,b)\r
+# define IRSND_PORT CONCAT(GPIO, IRSND_PORT_LETTER)\r
+# if defined (ARM_STM32L1XX)\r
+# define IRSND_PORT_RCC CONCAT(RCC_AHBPeriph_GPIO, IRSND_PORT_LETTER)\r
+# define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)\r
+# elif defined (ARM_STM32F10X)\r
+# define IRSND_PORT_RCC CONCAT(RCC_APB2Periph_GPIO, IRSND_PORT_LETTER)\r
+# elif defined (ARM_STM32F4XX)\r
+# define IRSND_PORT_RCC CONCAT(RCC_AHB1Periph_GPIO, IRSND_PORT_LETTER)\r
+# define IRSND_GPIO_AF CONCAT(GPIO_AF_TIM, IRSND_TIMER_NUMBER)\r
+# endif\r
+# define IRSND_BIT CONCAT(GPIO_Pin_, IRSND_BIT_NUMBER)\r
+# define IRSND_TIMER CONCAT(TIM, IRSND_TIMER_NUMBER)\r
+# define IRSND_TIMER_CHANNEL CONCAT(TIM_Channel_, IRSND_TIMER_CHANNEL_NUMBER)\r
+# if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14))\r
+# define IRSND_TIMER_RCC CONCAT(RCC_APB1Periph_TIM, IRSND_TIMER_NUMBER)\r
+# elif (IRSND_TIMER_NUMBER == 1) || ((IRSND_TIMER_NUMBER >= 8) && (IRSND_TIMER_NUMBER <= 11))\r
+# define IRSND_TIMER_RCC CONCAT(RCC_APB2Periph_TIM, IRSND_TIMER_NUMBER)\r
+# else\r
+# error IRSND_TIMER_NUMBER not valid.\r
+# endif\r
+# ifndef USE_STDPERIPH_DRIVER\r
+# warning The STM32 port of IRSND uses the ST standard peripheral drivers which are not enabled in your build configuration.\r
+# endif\r
\r
-/**\r
- * Send IRMP data\r
- * @details sends IRMP data\r
- * @param pointer to IRMP data structure\r
- * @return TRUE: successful, FALSE: failed\r
- */\r
-extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);\r
+#elif defined(PIC_C18)\r
\r
-/**\r
- * ISR routine\r
- * @details ISR routine, called 10000 times per second\r
- */\r
-extern uint8_t irsnd_ISR (void);\r
+# if defined(__12F1840)\r
+ // Do not change lines below unless you have a different HW. This example is for 12F1840\r
+ // setup macro for PWM used PWM module\r
+ \r
+ //~ # define PWMon() TMR2=0,IRSND_PIN=1\r
+ //~ # define PWMoff() CCP1CON &=(~0b1100)\r
+ //~ # define PWMon() TMR2ON=1\r
+ //~ # define PWMoff() TMR2ON=0\r
+ #if defined(IRSND_DEBUG) \r
+ #define PWMon() LATA0=1\r
+ #define PWMoff() LATA0=0\r
+ #define IRSND_PIN LATA0\r
+ #else\r
+ # define PWMon() TMR2=0,CCP1CON |=0b1100\r
+ # define PWMoff() CCP1CON &=(~0b1100)\r
+ # define IRSND_PIN RA2\r
+ #endif\r
+\r
+#else\r
+ // Do not change lines below until you have a different HW. Example is for 18F2550/18F4550\r
+ // setup macro for PWM used PWM module\r
+ # if IRSND_OCx == IRSND_PIC_CCP2 \r
+ # define PWMon() TMR2=0,CCP2CON |=0b1100\r
+ # define PWMoff() CCP2CON &=(~0b1100)\r
+ # define IRSND_PIN TRISCbits.TRISC1 // RC1 = PWM2\r
+ # define SetDCPWM(x) SetDCPWM2(x) \r
+ # define ClosePWM ClosePWM2\r
+ # define OpenPWM(x) OpenPWM2(x) \r
+ # endif\r
+ # if IRSND_OCx == IRSND_PIC_CCP1 \r
+ # define PWMon() TMR2=0,CCP1CON |=0b1100\r
+ # define PWMoff() CCP1CON &=(~0b1100)\r
+ # define IRSND_PIN TRISCbits.TRISC2 // RC2 = PWM1\r
+ # define SetDCPWM(x) SetDCPWM1(x)\r
+ # define ClosePWM ClosePWM1\r
+ # define OpenPWM(x) OpenPWM1(x)\r
+ # endif \r
+# endif\r
+# endif // PIC_C18\r
+\r
+#if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 && F_INTERRUPTS < 15000\r
+# warning F_INTERRUPTS too low, SIEMENS protocol disabled (should be at least 15000)\r
+# undef IRSND_SUPPORT_SIEMENS_PROTOCOL\r
+# define IRSND_SUPPORT_SIEMENS_PROTOCOL 0\r
+#endif\r
+\r
+#if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 && F_INTERRUPTS < 15000\r
+# warning F_INTERRUPTS too low, A1TVBOX protocol disabled (should be at least 15000)\r
+# undef IRSND_SUPPORT_A1TVBOX_PROTOCOL\r
+# define IRSND_SUPPORT_A1TVBOX_PROTOCOL 0\r
+#endif\r
+\r
+#if IRSND_SUPPORT_RECS80_PROTOCOL == 1 && F_INTERRUPTS < 15000\r
+# warning F_INTERRUPTS too low, RECS80 protocol disabled (should be at least 15000)\r
+# undef IRSND_SUPPORT_RECS80_PROTOCOL\r
+# define IRSND_SUPPORT_RECS80_PROTOCOL 0\r
+#endif\r
+\r
+#if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 && F_INTERRUPTS < 15000\r
+# warning F_INTERRUPTS too low, RECS80EXT protocol disabled (should be at least 15000)\r
+# undef IRSND_SUPPORT_RECS80EXT_PROTOCOL\r
+# define IRSND_SUPPORT_RECS80EXT_PROTOCOL 0\r
+#endif\r
+\r
+#if IRSND_SUPPORT_LEGO_PROTOCOL == 1 && F_INTERRUPTS < 20000\r
+# warning F_INTERRUPTS too low, LEGO protocol disabled (should be at least 20000)\r
+# undef IRSND_SUPPORT_LEGO_PROTOCOL\r
+# define IRSND_SUPPORT_LEGO_PROTOCOL 0\r
+#endif\r
+\r
+#include "irmpprotocols.h"\r
+\r
+#define IRSND_NO_REPETITIONS 0 // no repetitions\r
+#define IRSND_MAX_REPETITIONS 14 // max # of repetitions\r
+#define IRSND_ENDLESS_REPETITION 15 // endless repetions\r
+#define IRSND_REPETITION_MASK 0x0F // lower nibble of flags\r
+\r
+extern void irsnd_init (void);\r
+extern uint8_t irsnd_is_busy (void);\r
+extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t);\r
+extern void irsnd_stop (void);\r
+extern uint8_t irsnd_ISR (void);\r
\r
#if IRSND_USE_CALLBACK == 1\r
-extern void irsnd_set_callback_ptr (void (*cb)(uint8_t));\r
+extern void irsnd_set_callback_ptr (void (*cb)(uint8_t));\r
#endif // IRSND_USE_CALLBACK == 1\r
\r
-#endif /* _WC_IRSND_H_ */\r
+#endif /* _IRSND_H_ */\r