| Mozzi version v1.1.0 sound synthesis library for Arduino |

hardware_defines.h
1 #ifndef HARDWARE_DEFINES_H_
2 #define HARDWARE_DEFINES_H_
3
4 #if ARDUINO >= 100
5 #include "Arduino.h"
6 #else
7 #include "WProgram.h"
8 #endif
9
10 /* Macros to tell apart the supported platforms. The advantages of using these are, rather than the underlying defines
11 - Easier to read and write
12 - Compiler protection against typos
13 - Easy to extend for new but compatible boards */
14
15 #define IS_AVR() (defined(__AVR__)) // "Classic" Arduino boards
16 #define IS_SAMD21() (defined(ARDUINO_ARCH_SAMD))
17 #define IS_TEENSY3() (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__MKL26Z64__) ) // 32bit arm-based Teensy
18 #define IS_STM32() (defined(__arm__) && !IS_TEENSY3() && !IS_SAMD21()) // STM32 boards (note that only the maple based core is supported at this time. If another cores is to be supported in the future, this define should be split.
19 #define IS_ESP8266() (defined(ESP8266))
20 #define IS_ESP32() (defined(ESP32))
21
22 #if !(IS_AVR() || IS_TEENSY3() || IS_STM32() || IS_ESP8266() || IS_SAMD21() || IS_ESP32())
23 #error Your hardware is not supported by Mozzi or not recognized. Edit hardware_defines.h to proceed.
24 #endif
25
26 // Hardware detail defines
27 #if IS_STM32()
28 #define NUM_ANALOG_INPUTS 16 // probably wrong, but mostly needed to allocate an array of readings
29 #elif IS_ESP8266()
30 #define NUM_ANALOG_INPUTS 1
31 #endif
32
33 #if IS_AVR()
34 #define AUDIO_RATE_PLATFORM_DEFAULT 16384
35 #else
36 #define AUDIO_RATE_PLATFORM_DEFAULT 32768
37 #endif
38
39 #if IS_ESP8266()
40 #define CACHED_FUNCTION_ATTR ICACHE_RAM_ATTR
41 #elif IS_ESP32()
42 #define CACHED_FUNCTION_ATTR IRAM_ATTR
43 #else
44 #define CACHED_FUNCTION_ATTR
45 #endif
46
47 #if IS_STM32()
48 // 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).
49 // Putting it here, instead, seem to work.
50 #include <STM32ADC.h>
51 #endif
52
53 #endif /* HARDWARE_DEFINES_H_ */
IS_SAMD21
#define IS_SAMD21()
Definition: hardware_defines.h:16
IS_STM32
#define IS_STM32()
Definition: hardware_defines.h:18
IS_AVR
#define IS_AVR()
Definition: hardware_defines.h:15
IS_TEENSY3
#define IS_TEENSY3()
Definition: hardware_defines.h:17
IS_ESP8266
#define IS_ESP8266()
Definition: hardware_defines.h:19
IS_ESP32
#define IS_ESP32()
Definition: hardware_defines.h:20