85 lines
1.7 KiB
C++
85 lines
1.7 KiB
C++
#include <stdlib.h>
|
|
#include <cstdint>
|
|
|
|
#define WEMOS_D1_MINI 1
|
|
#define NODE_MCU 2
|
|
|
|
|
|
// https://blog.anto.io/wp-content/uploads/2016/12/esp32.png
|
|
// https://i.pinimg.com/originals/c6/57/83/c657835e84aaf91832a770ea0d7d0767.jpg
|
|
#define WROOM32_DEVKIT 32
|
|
#define TTGO 33
|
|
|
|
#define TEENSY_41 41
|
|
|
|
#define DESKTOP 99
|
|
|
|
#define IS_ESP8266 (PLATFORM == WEMOS_D1_MINI) || (PLATFORM == NODE_MCU)
|
|
#define IS_ESP32 (PLATFORM == WROOM32_DEVKIT) || (PLATFORM == TTGO)
|
|
#define IS_TEENSY (PLATFORM == TEENSY_41)
|
|
#define IS_DESKTOP (PLATFORM == DESKTOP)
|
|
|
|
#ifndef PLATFORM
|
|
#error "PLATFORM compile time variable not defined"
|
|
#endif
|
|
|
|
#if (IS_ESP32)
|
|
|
|
//#pragma message "Using ESP32"
|
|
#define DELAY_US(us) ets_delay_us(us)
|
|
#define DELAY_MS(ms) vTaskDelay(ms / portTICK_PERIOD_MS);
|
|
#define IN_FLASH
|
|
|
|
#elif (IS_ESP8266)
|
|
|
|
//#pragma message "Using ESP8266"
|
|
#define DELAY_US(us) os_delay_us(us)
|
|
#define IN_FLASH ICACHE_FLASH_ATTR
|
|
|
|
#elif (IS_TEENSY)
|
|
|
|
//#pragma message "Using Teensy"
|
|
#define DELAY_MS(ms) delay(ms)
|
|
|
|
#elif (IS_DESKTOP)
|
|
|
|
//#pragma message "Using Desktop"
|
|
#define DELAY_MS(ms) delay(ms)
|
|
|
|
#else
|
|
|
|
#error "Platforms.h: unsupported platform";
|
|
|
|
#endif
|
|
|
|
//#define min(a,b) (a<b) ? (a) : (b)
|
|
//#define max(a,b) (a>b) ? (a) : (b)
|
|
|
|
//template <typename T> inline T min(const T a, const T b) {
|
|
// return (a<b) ? (a) : (b);
|
|
//}
|
|
|
|
//template <typename T> inline T max(const T a, const T b) {
|
|
// return (a>b) ? (a) : (b);
|
|
//}
|
|
|
|
#if IS_ESP8266
|
|
//#define sprintf os_sprintf
|
|
extern "C" {
|
|
// #include "ets_sys.h"
|
|
// #include "c_types.h"
|
|
// #include "osapi.h"
|
|
// #include "user_interface.h"
|
|
// #include "mem.h"
|
|
// #include "espconn.h"
|
|
#include "esp_system.h"
|
|
}
|
|
#elif IS_ESP32
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#endif
|
|
|
|
#if IS_TEENSY
|
|
#define IRAM_ATTR
|
|
#endif
|