]> cloudbase.mooo.com Git - irmp.git/blame - irmpsystem.h
Version 3.0.7 - added SAMSUNGAH protocol, improved some code for ESP8266
[irmp.git] / irmpsystem.h
CommitLineData
08f2dd9d 1/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
2 * irmpsystem.h - system specific includes and defines\r
3 *\r
7365350c 4 * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de\r
08f2dd9d 5 *\r
30d1689d 6 * $Id: irmpsystem.h,v 1.25 2016/12/19 09:01:41 fm Exp $\r
08f2dd9d 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
15#ifndef _IRMPSYSTEM_H_\r
16#define _IRMPSYSTEM_H_\r
17\r
18#if !defined(_IRMP_H_) && !defined(_IRSND_H_)\r
19# error please include only irmp.h or irsnd.h, not irmpsystem.h\r
20#endif\r
21\r
22#if defined(__18CXX) // Microchip PIC C18 compiler\r
23# define PIC_C18\r
4a7dc859 24#elif defined(__XC8) // PIC XC8 compiler\r
25# include <xc.h>\r
26# define PIC_C18\r
08f2dd9d 27#elif defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC compiler\r
28# define PIC_CCS\r
29#elif defined(STM32L1XX_MD) || defined(STM32L1XX_MDP) || defined(STM32L1XX_HD) // ARM STM32\r
30# include <stm32l1xx.h>\r
31# define ARM_STM32\r
32# define ARM_STM32L1XX\r
c4957479 33# define F_CPU (SysCtlClockGet())\r
08f2dd9d 34#elif defined(STM32F10X_LD) || defined(STM32F10X_LD_VL) \\r
35 || defined(STM32F10X_MD) || defined(STM32F10X_MD_VL) \\r
36 || defined(STM32F10X_HD) || defined(STM32F10X_HD_VL) \\r
37 || defined(STM32F10X_XL) || defined(STM32F10X_CL) // ARM STM32\r
38# include <stm32f10x.h>\r
39# define ARM_STM32\r
40# define ARM_STM32F10X\r
622f5f59 41# define F_CPU (SysCtlClockGet())\r
08f2dd9d 42#elif defined(STM32F4XX) // ARM STM32\r
43# include <stm32f4xx.h>\r
44# define ARM_STM32\r
45# define ARM_STM32F4XX\r
aa276d72 46#elif defined(__SDCC_stm8) // STM8\r
47# define SDCC_STM8\r
061e654c 48#elif defined(TARGET_IS_BLIZZARD_RA2) // TI Stellaris (tested on Stellaris Launchpad with Code Composer Studio)\r
afd1e690 49# define STELLARIS_ARM_CORTEX_M4\r
50# define F_CPU (SysCtlClockGet())\r
30d1689d 51#elif defined(__xtensa__) // ESP8266 (Arduino)\r
52# include "Arduino.h"\r
95b27043 53# include "ets_sys.h"\r
54# include "osapi.h"\r
55# include "gpio.h"\r
56# include "os_type.h"\r
30d1689d 57# include "c_types.h"\r
95b27043 58# define uint_fast8_t uint8_t\r
59# define uint_fast16_t uint16_t\r
60#elif defined(TEENSYDUINO) && (defined(__MK20DX256__) || defined(__MK20DX128__)) // Teensy 3.x (tested on Teensy 3.1 in Arduino 1.6.5 / Teensyduino 1.2.5)\r
61# include <core_pins.h>\r
62# define TEENSY_ARM_CORTEX_M4\r
cb93f9e9 63#elif defined(unix) || defined(WIN32) || defined(__APPLE__) // Unix/Linux or Windows or Apple\r
08f2dd9d 64# define UNIX_OR_WINDOWS\r
ea29682a 65#elif defined(__MBED__) // mbed platform\r
66// #include "mbed.h" // if mbed.h is used, source must be compiled as cpp\r
67#include "gpio_api.h"\r
08f2dd9d 68#else\r
69# define ATMEL_AVR // ATMEL AVR\r
70#endif\r
71\r
72#include <string.h>\r
73\r
74#ifdef UNIX_OR_WINDOWS // Analyze on Unix/Linux or Windows\r
75# include <stdio.h>\r
76# include <stdlib.h>\r
08f2dd9d 77# define F_CPU 8000000L\r
78# define ANALYZE\r
0684a302 79# ifdef unix\r
80# include <stdint.h>\r
81# else\r
82typedef unsigned char uint8_t;\r
83typedef unsigned short uint16_t;\r
84# endif\r
08f2dd9d 85#endif\r
86\r
0684a302 87\r
08f2dd9d 88#if defined(ATMEL_AVR)\r
89# include <stdint.h>\r
90# include <stdio.h>\r
91# include <avr/io.h>\r
92# include <util/delay.h>\r
93# include <avr/pgmspace.h>\r
94# include <avr/interrupt.h>\r
95# define IRSND_OC2 0 // OC2\r
96# define IRSND_OC2A 1 // OC2A\r
97# define IRSND_OC2B 2 // OC2B\r
98# define IRSND_OC0 3 // OC0\r
99# define IRSND_OC0A 4 // OC0A\r
100# define IRSND_OC0B 5 // OC0B\r
ad4d3d41 101\r
102# define IRSND_XMEGA_OC0A 0 // OC0A\r
103# define IRSND_XMEGA_OC0B 1 // OC0B\r
104# define IRSND_XMEGA_OC0C 2 // OC0C\r
105# define IRSND_XMEGA_OC0D 3 // OC0D\r
106# define IRSND_XMEGA_OC1A 4 // OC1A\r
107# define IRSND_XMEGA_OC1B 5 // OC1B\r
108\r
afd1e690 109#elif defined(STELLARIS_ARM_CORTEX_M4)\r
ad4d3d41 110\r
afd1e690 111# include "inc/hw_ints.h"\r
112# include "inc/hw_memmap.h"\r
113# include "inc/hw_types.h"\r
114# include "inc/hw_gpio.h"\r
115# include "driverlib/fpu.h"\r
116# include "driverlib/sysctl.h"\r
117# include "driverlib/interrupt.h"\r
118# include "driverlib/gpio.h"\r
119# include "driverlib/rom.h"\r
120# include "driverlib/systick.h"\r
121# include "driverlib/pin_map.h"\r
122# include "driverlib/timer.h"\r
ad4d3d41 123# define PROGMEM\r
124# define memcpy_P memcpy\r
afd1e690 125# define APP_SYSTICKS_PER_SEC 32\r
ad4d3d41 126\r
622f5f59 127#elif defined(ARM_STM32F10X)\r
ad4d3d41 128\r
622f5f59 129# include "stm32f10x_gpio.h"\r
130# include "stm32f10x_rcc.h"\r
131# include "stm32f10x_tim.h"\r
132# include "misc.h"\r
133# define PROGMEM\r
134# define memcpy_P memcpy\r
ad4d3d41 135\r
aa276d72 136#elif defined(SDCC_STM8)\r
137\r
138# include "stm8s.h"\r
139# define PROGMEM\r
140# define memcpy_P memcpy\r
141# define __attribute__(x)\r
142# define uint_fast8_t uint8_t\r
143# define uint_fast16_t uint16_t\r
144\r
95b27043 145#elif defined(TEENSY_ARM_CORTEX_M4)\r
146# define PROGMEM\r
147# define memcpy_P memcpy\r
ad4d3d41 148\r
30d1689d 149#elif defined(__xtensa__)\r
150# define PROGMEM\r
151# define memcpy_P memcpy\r
152\r
ea29682a 153#elif defined(__MBED__)\r
154# define PROGMEM\r
155# define memcpy_P memcpy\r
156\r
95b27043 157#else\r
08f2dd9d 158# define PROGMEM\r
159# define memcpy_P memcpy\r
ad4d3d41 160\r
08f2dd9d 161#endif\r
162\r
afd1e690 163#if defined(PIC_CCS) || defined(PIC_C18) || defined(ARM_STM32) || defined(STELLARIS_ARM_CORTEX_M4)\r
08f2dd9d 164typedef unsigned char uint8_t;\r
165typedef unsigned short uint16_t;\r
7365350c 166typedef unsigned char uint_fast8_t;\r
167typedef unsigned short uint_fast16_t;\r
08f2dd9d 168#endif\r
169\r
4a7dc859 170#if defined (PIC_C18) // PIC C18 or XC8 compiler\r
08f2dd9d 171# include <p18cxxx.h> // main PIC18 h file\r
7a844aff 172#ifndef __XC8\r
08f2dd9d 173# include <timers.h> // timer lib\r
174# include <pwm.h> // pwm lib\r
7a844aff 175#endif\r
08f2dd9d 176# define IRSND_PIC_CCP1 1 // PIC C18 RC2 = PWM1 module\r
177# define IRSND_PIC_CCP2 2 // PIC C18 RC1 = PWM2 module\r
178#endif\r
179\r
180#ifndef TRUE\r
181# define TRUE 1\r
182# define FALSE 0\r
183#endif\r
184\r
7365350c 185#if defined(PIC_C18)\r
186#define IRMP_PACKED_STRUCT\r
187#else\r
188#define IRMP_PACKED_STRUCT __attribute__ ((__packed__))\r
189#endif\r
190\r
191typedef struct IRMP_PACKED_STRUCT\r
08f2dd9d 192{\r
df24bb50 193 uint8_t protocol; // protocol, e.g. NEC_PROTOCOL\r
95b27043 194 uint16_t address; // address\r
195 uint16_t command; // command\r
196 uint8_t flags; // flags, e.g. repetition\r
08f2dd9d 197} IRMP_DATA;\r
198\r
199#endif // _IRMPSYSTEM_H_\r