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