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