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