-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathhardware_defines.h
More file actions
137 lines (115 loc) · 3.31 KB
/
hardware_defines.h
File metadata and controls
137 lines (115 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* hardware_defines.h
*
* This file is part of Mozzi.
*
* Copyright 2023-2024 Thomas Friedrichsmeier and the Mozzi Team
*
* Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
*
*/
#ifndef HARDWARE_DEFINES_H_
#define HARDWARE_DEFINES_H_
#include "Arduino.h"
/* Macros to tell apart the supported platforms. The advantages of using these are, rather than the underlying defines
- Easier to read and write
- Compiler protection against typos
- Easy to extend for new but compatible boards */
// "Classic" Arduino boards
#if (defined(__AVR__))
#define IS_AVR() 1
#else
#define IS_AVR() 0
#endif
// SAMD
#if (defined(ARDUINO_ARCH_SAMD))
#define IS_SAMD21() 1
#else
#define IS_SAMD21() 0
#endif
// 32bit arm-based Teensy
#if (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__))
#define IS_TEENSY3() 1
#else
#define IS_TEENSY3() 0
#endif
// Teensy4 (no DAC)
#if (defined(__IMXRT1062__))
#define IS_TEENSY4() 1
#else
#define IS_TEENSY4() 0
#endif
// RP2040 (Raspberry Pi Pico and friends)
#if (defined(ARDUINO_ARCH_RP2040))
#define IS_RP2040() 1
#else
#define IS_RP2040() 0
#endif
// STM32 boards (libmaple based)
// https://github.com/stevstrong/Arduino_STM32
#if (defined(__arm__) && !IS_TEENSY3() && !IS_TEENSY4() && __has_include("libmaple/libmaple.h"))
#define IS_STM32MAPLE() 1
#else
#define IS_STM32MAPLE() 0
#endif
// Mbed OS based boards
#if (defined(ARDUINO_ARCH_MBED))
#define IS_MBED() 1
#else
#define IS_MBED() 0
#endif
// Arduino Giga
#if (IS_MBED() && defined(ARDUINO_GIGA))
#define IS_GIGA() 1
#else
#define IS_GIGA() 0
#endif
// Arduino Uno R4 (Renesas arch)
#if (defined(ARDUINO_FSP))
#define IS_RENESAS() 1
#else
#define IS_RENESAS() 0
#endif
// CH32 Architecture (WCH RISC-V)
// Explicit check for CH32X035 is needed as ARDUINO_ARCH macros might not be defined by all cores/tools
#if (defined(ARDUINO_ARCH_CH32V) || defined(ARDUINO_ARCH_CH32) || defined(CH32X035))
#define IS_CH32() 1
#else
#define IS_CH32() 0
#endif
#if (defined(__arm__) && !IS_STM32MAPLE() && !IS_TEENSY3() && !IS_TEENSY4() && !IS_RP2040() && !IS_SAMD21() && !IS_MBED() && !IS_RENESAS())
#define IS_STM32DUINO() 1
#else
#define IS_STM32DUINO() 0
#endif
#if (defined(ESP8266))
#define IS_ESP8266() 1
#else
#define IS_ESP8266() 0
#endif
#if (defined(ESP32))
#define IS_ESP32() 1
#else
#define IS_ESP32() 0
#endif
#if !(IS_AVR() || IS_TEENSY3() || IS_TEENSY4() || IS_STM32MAPLE() || IS_STM32DUINO() || IS_ESP8266() || IS_SAMD21() || IS_ESP32() || IS_RP2040() || IS_MBED() || IS_RENESAS() || IS_CH32())
// TODO: add an exception for MOZZI_OUTPUT_EXTERNAL_CUSTOM
#error Your hardware is not supported by Mozzi or not recognized. Edit hardware_defines.h to proceed.
#endif
// Hardware detail defines
#if IS_STM32MAPLE()
#define NUM_ANALOG_INPUTS 16 // probably wrong, but mostly needed to allocate an array of readings
#elif IS_ESP8266()
#define NUM_ANALOG_INPUTS 1
#endif
#if IS_ESP8266() || IS_ESP32()
#define CACHED_FUNCTION_ATTR IRAM_ATTR
#else
#define CACHED_FUNCTION_ATTR
#endif
#if IS_STM32MAPLE()
// This is a little silly, but with Arduino 1.8.13, including this header inside MozziGuts.cpp does not work (fails to detect the proper include path).
// Putting it here, instead, seem to work.
#include <STM32ADC.h>
#endif
#endif /* HARDWARE_DEFINES_H_ */