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_TEENSY4() (defined(__IMXRT1062__)) // Teensy4 (no DAC)
19 #define IS_STM32() (defined(__arm__) && !IS_TEENSY3() && !IS_SAMD21() && !IS_TEENSY4() && !IS_RP2040()) // 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.
20 #define IS_ESP8266() (defined(ESP8266))
21 #define IS_ESP32() (defined(ESP32))
22 #define IS_RP2040() (defined(ARDUINO_ARCH_RP2040))
23 
24 #if !(IS_AVR() || IS_TEENSY3() || IS_TEENSY4() || IS_STM32() || IS_ESP8266() || IS_SAMD21() || IS_ESP32() || IS_RP2040())
25 #error Your hardware is not supported by Mozzi or not recognized. Edit hardware_defines.h to proceed.
26 #endif
27 
28 // Hardware detail defines
29 #if IS_STM32()
30 #define NUM_ANALOG_INPUTS 16 // probably wrong, but mostly needed to allocate an array of readings
31 #elif IS_ESP8266()
32 #define NUM_ANALOG_INPUTS 1
33 #endif
34 
35 #if IS_AVR()
36 #define AUDIO_RATE_PLATFORM_DEFAULT 16384
37 #else
38 #define AUDIO_RATE_PLATFORM_DEFAULT 32768
39 #endif
40 
41 #if IS_ESP8266()
42 #define CACHED_FUNCTION_ATTR ICACHE_RAM_ATTR
43 #elif IS_ESP32()
44 #define CACHED_FUNCTION_ATTR IRAM_ATTR
45 #else
46 #define CACHED_FUNCTION_ATTR
47 #endif
48 
49 #if IS_STM32()
50 // 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).
51 // Putting it here, instead, seem to work.
52 #include <STM32ADC.h>
53 #endif
54 
55 #endif /* HARDWARE_DEFINES_H_ */
#define IS_SAMD21()
#define IS_TEENSY4()
#define IS_STM32()
#define IS_AVR()
#define IS_TEENSY3()
#define IS_RP2040()
#define IS_ESP8266()
#define IS_ESP32()