This commit is contained in:
sagiferi
2026-05-20 21:48:13 +02:00
parent a907d8ba74
commit d3c13f997e
446 changed files with 70716 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
// HAL global variables
#include <Arduino.h>
// Must match the externs in HAL_FAST_TICKS.h exactly
uint32_t _halTicksPerSecond = 1000000UL;
uint32_t _halTicksPerMicro = 1;
Executable
+190
View File
@@ -0,0 +1,190 @@
/*
* Hardware Abstraction Layer (HAL) for OnStep
*
* Copyright (C) 2018 Khalid Baheyeldin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// null decoration for non-ESP processors
#ifndef IRAM_ATTR
#define IRAM_ATTR
#endif
#ifndef ICACHE_RAM_ATTR
#define ICACHE_RAM_ATTR
#endif
#ifndef FPSTR
#define FPSTR
#endif
#include "HAL_FAST_TICKS.h"
#if defined(__AVR_ATmega328P__)
#define MCU_STR "AtMega328"
#include "atmel/Mega328.h"
#elif defined(__AVR_ATmega1280__)
#define MCU_STR "Mega1280"
#include "atmel/Mega2560.h"
#elif defined(__AVR_ATmega2560__)
#define MCU_STR "Mega2560"
#include "atmel/Mega2560.h"
#elif defined(ARDUINO_UNOWIFIR4)
// Arduino UNO R4 WIFI
#define MCU_STR "RENESAS RA4M1 (Arduino UNO R4 WIFI)"
#include "esp32/ESP32UnoR4WiFi.h"
#elif defined(ARDUINO_ARCH_SAMD)
// ARDUINO M0
#define MCU_STR "ARDUINO M0"
#include "arduinoM0/ArduinoM0.h"
#elif defined(ESP32) && ESP_ARDUINO_VERSION >= 0x30000
// ESP32 w/libraries 3.x
#define MCU_STR "ESP32"
#include "esp/ESP32Libraries3.h"
#elif defined(ESP32) && ESP_ARDUINO_VERSION >= 0x20000
// ESP32 w/libraries 2.x
#define MCU_STR "ESP32"
#include "esp/ESP32Libraries2.h"
#elif defined(ESP8266)
// ESP8266
#define MCU_STR "ESP8266"
#include "esp/ESP8266.h"
#elif defined(STM32F103xB)
// STM32F103C8/CB: 72MHz, 128K flash, 64K RAM, ARM Cortex M3
#define MCU_STR "STM32F103"
#include "stm32/STM32F103.h"
#elif defined(STM32F303xC)
// RobotDyn BlackPill STM32F303, 256K flash, ARM Cortex M4 (STM32duino board manager)
#define MCU_STR "STM32F303"
#include "stm32/STM32F303.h"
#elif defined(STM32F401xC)
// Blackpill board with STM32F401CC
#define MCU_STR "STM32F401"
#include "stm32/STM32F4x1.h"
#elif defined(STM32F411xE)
// Blackpill board with STM32F411CE
#define MCU_STR "STM32F411"
#include "stm32/STM32F4x1.h"
#elif defined(STM32F407xx)
// BTT SKR PRO board with STM32F407
#define MCU_STR "STM32F407"
#include "stm32/STM32F407.h"
#elif defined(STM32F446xx)
// FYSETC S6 board with STM32F446
#define MCU_STR "STM32F446"
#include "stm32/STM32F446.h"
#elif defined(STM32H723xx)
#define MCU_STR "STM32H723"
#include "stm32/STM32H7xx.h"
#elif defined(STM32H743xx)
// WeAct Studio board with STM32H743
#define MCU_STR "STM32H743"
#include "stm32/STM32H7xx.h"
#elif defined(STM32H750xx)
// WeAct Studio board with STM32H750
#define MCU_STR "STM32H750"
#include "stm32/STM32H7xx.h"
#elif defined(_mk20dx128_h_) || defined(__MK20DX128__)
// Teensy 3.0
#define MCU_STR "Teensy3.0"
#include "teensy/Teensy3.2.h"
#elif defined(__MK20DX256__)
// Teensy 3.2
#define MCU_STR "Teensy3.2"
#include "teensy/Teensy3.2.h"
#elif defined(__MK64FX512__)
// Teensy 3.5
#define MCU_STR "Teensy3.5"
#include "teensy/Teensy3.5.h"
#elif defined(__MK66FX1M0__)
// Teensy 3.6
#define MCU_STR "Teensy3.6"
#include "teensy/Teensy3.6.h"
#elif defined(ARDUINO_TEENSY40)
// Teensy 4.0
#define MCU_STR "Teensy4.0"
#include "teensy/Teensy4.0.h"
#elif defined(ARDUINO_TEENSY41)
// Teensy 4.1
#define MCU_STR "Teensy4.1"
#include "teensy/Teensy4.1.h"
#elif defined(ARDUINO_TEENSY_MICROMOD)
// Teensy MicroMod
#define MCU_STR "TeensyMicroMod"
#include "teensy/Teensy4.1.h"
#elif defined(ARDUINO_ARCH_RP2040)
// Raspberry pi pico
#define MCU_STR "Raspberry Pi Pico"
#include "mbed/Rpi2040.h"
#elif defined(ARDUINO_ARCH_RP2350)
// Raspberry pi pico2
#define MCU_STR "Raspberry Pi Pico2"
#include "mbed/Rpi2350.h"
#else
// Generic
#warning "Unknown Platform! If this is a new platform, it would probably do best with a new HAL designed for it."
#define MCU_STR "Generic (Unknown)"
#include "default/Default.h"
#endif
#include "HAL_ANALOG.h"
#ifndef HAL_INIT
#define HAL_INIT() do { HAL_FAST_TICKS_INIT(); } while (0)
#endif
// baseline critical task timing
#ifdef HAL_FRACTIONAL_SEC
#define FRACTIONAL_SEC HAL_FRACTIONAL_SEC
#else
#define FRACTIONAL_SEC 100.0F
#endif
// progmem standin for platforms that don't have it
#ifndef CAT_ATTR
#define CAT_ATTR
#endif
// default I2C interface
#if defined(HAL_WIRE_CLOCK)
#define HAL_WIRE_SET_CLOCK() HAL_WIRE.setClock(HAL_WIRE_CLOCK)
#else
#define HAL_WIRE_SET_CLOCK()
#endif
+73
View File
@@ -0,0 +1,73 @@
// Analog HAL capabilities (defaults) ----------------------------------------------------------------
// Defaults: no per-pin control, no global reconfig (safe)
#pragma once
#ifndef HAL_HAS_PER_PIN_PWM_RESOLUTION
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#endif
#ifndef HAL_HAS_PER_PIN_PWM_FREQUENCY
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 0
#endif
#ifndef HAL_HAS_GLOBAL_PWM_RESOLUTION
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 0
#endif
#ifndef HAL_HAS_GLOBAL_PWM_FREQUENCY
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#endif
#ifndef HAL_HAS_PER_PIN_ADC_RESOLUTION
#define HAL_HAS_PER_PIN_ADC_RESOLUTION 0
#endif
#ifndef HAL_HAS_GLOBAL_ADC_RESOLUTION
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 0
#endif
#ifndef HAL_ALLOW_GLOBAL_PWM_RECONFIG
#define HAL_ALLOW_GLOBAL_PWM_RECONFIG 0
#endif
#ifndef HAL_ALLOW_GLOBAL_ADC_RECONFIG
#define HAL_ALLOW_GLOBAL_ADC_RECONFIG 0
#endif
// reasonable bounds (overridden per platform below)
#ifndef HAL_PWM_BITS_MIN
#define HAL_PWM_BITS_MIN 1
#endif
#ifndef HAL_PWM_BITS_MAX
#define HAL_PWM_BITS_MAX 16
#endif
#ifndef HAL_ADC_BITS_MIN
#define HAL_ADC_BITS_MIN 1
#endif
#ifndef HAL_ADC_BITS_MAX
#define HAL_ADC_BITS_MAX 12
#endif
#ifndef HAL_PWM_HZ_MIN
#define HAL_PWM_HZ_MIN 1U
#endif
#ifndef HAL_PWM_HZ_MAX
#define HAL_PWM_HZ_MAX 40000U
#endif
// some validation
#if HAL_PWM_BITS_MIN < 1 || HAL_PWM_BITS_MIN > 32
#error "Error: HAL_PWM_BITS_MIN outside of 1 to 32 range."
#endif
#if HAL_PWM_BITS_MAX < 1 || HAL_PWM_BITS_MAX > 32
#error "Error: HAL_PWM_BITS_MAX outside of 1 to 32 range."
#endif
#if HAL_ADC_BITS_MIN < 1 || HAL_ADC_BITS_MIN > 32
#error "Error: HAL_ADC_BITS_MIN outside of 1 to 32 range."
#endif
#if HAL_ADC_BITS_MAX < 1 || HAL_ADC_BITS_MAX > 32
#error "Error: HAL_ADC_BITS_MAX outside of 1 to 32 range."
#endif
// global default ranges
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023U // 2^n - 1
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255U // 2^n - 1
#endif
+248
View File
@@ -0,0 +1,248 @@
// -------------------------------------------------------------------------------------------------
// HAL_FAST_TICKS.h
//
// Fast ticks: 32-bit wrapping timestamp intended for ISRs / high-rate timing.
//
// Interface:
// HAL_FAST_TICKS_INIT() call once at startup (safe no-op where not needed)
// HAL_FAST_TICKS() returns uint32_t ticks (wrapping OK)
// HAL_TICKS_PER_SECOND() returns uint32_t tick frequency in Hz (cached)
// delayNanoseconds(ns) short busy-wait delay (NOT intended for ISR use)
// nanoseconds32() convenience conversion (NOT intended for ISR use)
//
// Policy (as requested):
// - Teensy 3.x/4.x: use DWT->CYCCNT (enable once).
// - ESP32 Xtensa (ESP32/S2/S3): use CCOUNT.
// - ESP8266: use ESP.getCycleCount().
// - STM32: most use micros(), STM32H723/H743/H750 use DWT->CYCCNT.
// - ESP32 RISC-V (C3/C6/H2): use micros().
// - Everything else: use micros().
//
// Notes:
// - Tick frequency is cached in _halTicksPerSecond/_halTicksPerMicro (defined in HAL.cpp).
// -------------------------------------------------------------------------------------------------
#pragma once
#include <stdint.h>
#include <Arduino.h>
// Make header self-contained (HAL.h may not have been included yet)
#ifndef IRAM_ATTR
#define IRAM_ATTR
#endif
// Must be defined once in HAL.cpp:
// uint32_t _halTicksPerSecond = 1000000UL;
// uint32_t _halTicksPerMicro = 1;
extern uint32_t _halTicksPerSecond;
extern uint32_t _halTicksPerMicro;
// ----------------------------------------
// Platform identification helpers
// ----------------------------------------
// Teensy (3.x/4.x) detection
#if defined(TEENSYDUINO) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || \
defined(ARDUINO_TEENSY_MICROMOD) || \
defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || \
defined(__IMXRT1062__)
#define HAL_IS_TEENSY 1
#else
#define HAL_IS_TEENSY 0
#endif
// STM32 H7 detection (STM32duino)
#if defined(ARDUINO_ARCH_STM32) && (defined(STM32H723xx) || defined(STM32H743xx) || defined(STM32H750xx))
#define HAL_IS_STM32_H7 1
#else
#define HAL_IS_STM32_H7 0
#endif
// ESP32 RISC-V detection (C3/C6/H2)
#if (defined(ARDUINO_ARCH_ESP32) || defined(ESP_PLATFORM)) && (defined(__riscv) || defined(__riscv__))
#define HAL_IS_ESP32_RISCV 1
#else
#define HAL_IS_ESP32_RISCV 0
#endif
// ESP32 Xtensa detection (ESP32/S2/S3)
#if (defined(ARDUINO_ARCH_ESP32) || defined(ESP_PLATFORM)) && (defined(__XTENSA__) || defined(__xtensa__))
#define HAL_IS_ESP32_XTENSA 1
#else
#define HAL_IS_ESP32_XTENSA 0
#endif
// ----------------------------------------
// Platform-specific fast tick source
// ----------------------------------------
// ---------- ESP32 Xtensa: CCOUNT ----------
#if HAL_IS_ESP32_XTENSA
static inline uint32_t IRAM_ATTR HAL_FAST_TICKS() {
uint32_t ccount;
__asm__ __volatile__("rsr %0, ccount" : "=a"(ccount));
return ccount;
}
static inline uint32_t HAL_TICKS_PER_SECOND() { return _halTicksPerSecond; }
static inline void HAL_FAST_TICKS_INIT() {
#if defined(F_CPU)
_halTicksPerSecond = (uint32_t)F_CPU;
#else
_halTicksPerSecond = (uint32_t)ESP.getCpuFreqMHz() * 1000000UL;
#endif
_halTicksPerMicro = _halTicksPerSecond / 1000000UL;
if (_halTicksPerMicro == 0) _halTicksPerMicro = 1;
}
// ---------- ESP8266: cycle count ----------
#elif defined(ESP8266)
static inline uint32_t IRAM_ATTR HAL_FAST_TICKS() {
return (uint32_t)ESP.getCycleCount();
}
static inline uint32_t HAL_TICKS_PER_SECOND() { return _halTicksPerSecond; }
static inline void HAL_FAST_TICKS_INIT() {
#if defined(F_CPU)
_halTicksPerSecond = (uint32_t)F_CPU; // typically 80 or 160 MHz
#else
_halTicksPerSecond = 80000000UL;
#endif
_halTicksPerMicro = _halTicksPerSecond / 1000000UL;
if (_halTicksPerMicro == 0) _halTicksPerMicro = 1;
}
// ---------- Teensy 3.x/4.x: DWT->CYCCNT ----------
#elif HAL_IS_TEENSY
static inline void HAL_FAST_TICKS_INIT() {
#if defined(DWT) && defined(CoreDebug) && defined(DWT_CTRL_CYCCNTENA_Msk)
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
if ((DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk) == 0) {
DWT->CYCCNT = 0; // optional but recommended
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
__DSB(); __ISB();
}
#if defined(F_CPU)
_halTicksPerSecond = (uint32_t)F_CPU;
#else
_halTicksPerSecond = 1000000UL;
#endif
#else
// fallback tick source is micros()
_halTicksPerSecond = 1000000UL;
#endif
_halTicksPerMicro = _halTicksPerSecond / 1000000UL;
if (_halTicksPerMicro == 0) _halTicksPerMicro = 1;
}
static inline uint32_t HAL_TICKS_PER_SECOND() { return _halTicksPerSecond; }
static inline uint32_t IRAM_ATTR HAL_FAST_TICKS() {
#if defined(DWT) && defined(DWT_CTRL_CYCCNTENA_Msk)
return (uint32_t)DWT->CYCCNT;
#else
return (uint32_t)micros();
#endif
}
// - STM32H7: use DWT->CYCCNT (enable once).
// - Other STM32: use micros().
#elif HAL_IS_STM32_H7
// Some STM32 cores expose these via CMSIS headers already included by Arduino.h.
// If not, you may need: #include "core_cm7.h"
static inline void HAL_FAST_TICKS_INIT() {
// Ensure SystemCoreClock is up to date (harmless if already correct).
#if defined(SystemCoreClockUpdate)
SystemCoreClockUpdate();
#endif
// Enable DWT CYCCNT
#if defined(DWT) && defined(CoreDebug) && defined(DWT_CTRL_CYCCNTENA_Msk) && defined(CoreDebug_DEMCR_TRCENA_Msk)
// Enable tracing (required to access DWT on Cortex-M)
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
#if defined(DWT_LAR)
// DWT->LAR = 0xC5ACCE55; // unlock (if implemented)
#endif
// Enable the cycle counter
if ((DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk) == 0) {
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
__DSB(); __ISB();
}
// Tick frequency is core clock
#if defined(F_CPU)
_halTicksPerSecond = (uint32_t)F_CPU;
#elif defined(SystemCoreClock)
_halTicksPerSecond = (uint32_t)SystemCoreClock;
#else
_halTicksPerSecond = 1000000UL; // last-resort fallback
#endif
#else
// If DWT isn't available for some reason, fall back to micros().
_halTicksPerSecond = 1000000UL;
#endif
_halTicksPerMicro = _halTicksPerSecond / 1000000UL;
if (_halTicksPerMicro == 0) _halTicksPerMicro = 1;
}
static inline uint32_t HAL_TICKS_PER_SECOND() { return _halTicksPerSecond; }
static inline uint32_t IRAM_ATTR HAL_FAST_TICKS() {
#if defined(DWT) && defined(CoreDebug) && defined(DWT_CTRL_CYCCNTENA_Msk) && defined(CoreDebug_DEMCR_TRCENA_Msk)
return (uint32_t)DWT->CYCCNT; // 32-bit wraps naturally
#else
return (uint32_t)micros(); // fallback
#endif
}
#else
static inline void HAL_FAST_TICKS_INIT() {
_halTicksPerSecond = 1000000UL;
_halTicksPerMicro = 1;
}
static inline uint32_t HAL_TICKS_PER_SECOND() { return _halTicksPerSecond; }
static inline uint32_t IRAM_ATTR HAL_FAST_TICKS() { return (uint32_t)micros(); }
#endif
// ----------------------------------------
// Helpers (non-ISR intent)
// ----------------------------------------
static inline uint32_t nanoseconds32() {
// rolls over ~4.29s when returning uint32_t
return (uint32_t)((uint64_t)HAL_FAST_TICKS() * 1000000000ULL / (uint64_t)HAL_TICKS_PER_SECOND());
}
static inline uint32_t halNsToTicks(uint32_t ns) {
// ticks = ns * (ticks/us) / 1000
return (uint32_t)(((uint64_t)ns * (uint64_t)_halTicksPerMicro + 999ULL) / 1000ULL);
}
#if !HAL_IS_TEENSY
static inline void delayNanoseconds(uint32_t ns) {
if (ns >= 20000UL) {
delayMicroseconds((ns + 999UL) / 1000UL);
return;
}
const uint32_t wait = halNsToTicks(ns);
if (wait == 0) return;
const uint32_t start = HAL_FAST_TICKS();
while ((uint32_t)(HAL_FAST_TICKS() - start) < wait) { }
}
#endif
+57
View File
@@ -0,0 +1,57 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __M0__
#include <avr/dtostrf.h>
// Base rate for critical task timing
#define HAL_FRACTIONAL_SEC 100.0F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 40
#define HAL_PULSE_WIDTH 900 // in ns, estimated
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
// Library FlashStorage defaults to 1024 bytes https://github.com/cmaglie/FlashStorage
#define E2END 1023
#undef NV_DRIVER
#define NV_DRIVER NV_M0
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//----------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
//-----------------------------------------------------------------------------------------------------
// Misc. includes and defines to support this processor's operation
+68
View File
@@ -0,0 +1,68 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
// __AVR__
// 1/100 second resolution
#define HAL_FRACTIONAL_SEC 100.0F
// This platform has 8 bit PWM
#ifndef HAL_VCC
#define HAL_VCC 5.0F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// This platform doesn't support true double precision math
#define HAL_NO_DOUBLE_PRECISION
// This is for ~16MHz AVR processors or similar.
#define HAL_SLOW_PROCESSOR
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 76.8
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
analogReference(DEFAULT); \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() mega2560restart();
#define HAL_RESET_FUNC void (*mega2560restart) (void) = 0;
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
#define strtof strtod // there is no strtof defined for the AVR platform
+63
View File
@@ -0,0 +1,63 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
// __AVR__
// 1/100 second resolution
#define HAL_FRACTIONAL_SEC 100.0F
// This platform has 8 bit PWM
#ifndef HAL_VCC
#define HAL_VCC 5.0F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// This platform doesn't support true double precision math
#define HAL_NO_DOUBLE_PRECISION
// This is for ~16MHz AVR processors or similar.
#define HAL_SLOW_PROCESSOR
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 76.8
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
analogReference(DEFAULT); \
HAL_FAST_TICKS_INIT(); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+55
View File
@@ -0,0 +1,55 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Platform_Name boards based on different lines are supported
// Base rate for critical task timing
#define HAL_FRACTIONAL_SEC 100.0F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#ifndef HAL_MAXRATE_LOWER_LIMIT
#define HAL_MAXRATE_LOWER_LIMIT 60
#endif
#ifndef HAL_PULSE_WIDTH
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
#endif
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+96
View File
@@ -0,0 +1,96 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// This is for fast processors with hardware FP
#define HAL_FAST_PROCESSOR
// Base rate for critical task timing (0.0095s = 0.14", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 105.2631579F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023 // always use 2^n - 1, within the platform's limits
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255 // always use 2^n - 1, within the platform's limits
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 0
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 1
#define HAL_PWM_HZ_MAX 200000U
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 1
#define HAL_PWM_BITS_MAX 16
#define HAL_ADC_BITS_MAX 12
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#if CAN_PLUS != OFF
#define HAL_MAXRATE_LOWER_LIMIT 60
#else
#define HAL_MAXRATE_LOWER_LIMIT 40
#endif
#define HAL_PULSE_WIDTH 300 // in ns, measured 12/5/25 (ESP32 v2.0.17)
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_ESP
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
// Correction for ESP32's internal temperture sensor
#ifndef INTERNAL_TEMP_CORRECTION
#define INTERNAL_TEMP_CORRECTION 0
#endif
#define HAL_TEMP() ( temperatureRead() + INTERNAL_TEMP_CORRECTION )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL, optionally also early init of SERIAL_SIP/PIP or SERIAL_BT
#ifndef SERIAL_BT_MODE
#define SERIAL_BT_MODE OFF
#endif
#if SERIAL_BT_MODE != OFF
#include <BluetoothSerial.h>
extern BluetoothSerial bluetoothSerial;
#define SERIAL_BT bluetoothSerial
#endif
#if SERIAL_BT_MODE == SLAVE
#ifdef SERIAL_BT_PASSKEY
#define SERIAL_BT_BEGIN() if (strlen(SERIAL_BT_PASSKEY) != 0) SERIAL_BT.setPin(SERIAL_BT_PASSKEY); SERIAL_BT.begin(SERIAL_BT_NAME)
#else
#define SERIAL_BT_BEGIN() SERIAL_BT.begin(SERIAL_BT_NAME)
#endif
#else
#define SERIAL_BT_BEGIN()
#endif
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
SERIAL_BT_BEGIN(); \
HAL_FAST_TICKS_INIT(); \
}
// MCU reset
#define HAL_RESET() ESP.restart()
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+98
View File
@@ -0,0 +1,98 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// This is for fast processors with hardware FP
#define HAL_FAST_PROCESSOR
// Base rate for critical task timing (0.0095s = 0.14", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 105.2631579F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 0
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 1
#define HAL_PWM_HZ_MAX 200000U
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 1
#define HAL_PWM_BITS_MAX 16
#define HAL_ADC_BITS_MAX 12
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#if CAN_PLUS != OFF
#define HAL_MAXRATE_LOWER_LIMIT 60
#else
#define HAL_MAXRATE_LOWER_LIMIT 40
#endif
#define HAL_PULSE_WIDTH 200 // in ns, measured 1/18/22 (ESP32 v2.0.0)
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_ESP
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
// Correction for ESP32's internal temperture sensor
#ifndef INTERNAL_TEMP_CORRECTION
#define INTERNAL_TEMP_CORRECTION 0
#endif
#define HAL_TEMP() ( temperatureRead() + INTERNAL_TEMP_CORRECTION )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL, optionally also early init of SERIAL_SIP/PIP or SERIAL_BT
#ifndef SERIAL_BT_MODE
#define SERIAL_BT_MODE OFF
#endif
#if SERIAL_BT_MODE != OFF
#include <BluetoothSerial.h>
extern BluetoothSerial bluetoothSerial;
#define SERIAL_BT bluetoothSerial
#endif
#if SERIAL_BT_MODE == SLAVE
#ifdef SERIAL_BT_PASSKEY
#define SERIAL_BT_BEGIN() if (strlen(SERIAL_BT_PASSKEY) != 0) SERIAL_BT.setPin(SERIAL_BT_PASSKEY, strlen(SERIAL_BT_PASSKEY)); SERIAL_BT.begin(SERIAL_BT_NAME)
#else
#define SERIAL_BT_BEGIN() SERIAL_BT.begin(SERIAL_BT_NAME)
#endif
#else
#define SERIAL_BT_BEGIN()
#endif
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
SERIAL_BT_BEGIN(); \
HAL_FAST_TICKS_INIT(); \
}
// MCU reset
#define HAL_RESET() ESP.restart()
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+56
View File
@@ -0,0 +1,56 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// This is for fast processors with hardware FP
#define HAL_FAST_PROCESSOR
// Base rate for critical task timing (0.0095s = 0.14", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 105.2631579F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 60
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#define E2END 2047
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
// MCU reset
#define HAL_RESET() ESP.restart()
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+51
View File
@@ -0,0 +1,51 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Platform_Name boards based on different lines are supported
// Base rate for critical task timing
#define HAL_FRACTIONAL_SEC 100.0F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 60
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#define E2END 1023
#undef NV_DRIVER
#define NV_DRIVER NV_ESP
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
//-----------------------------------------------------------------------------------------------------
// Misc. includes and defines to support this processor's operation
// MCU reset
#define HAL_RESET() ESP.restart()
+52
View File
@@ -0,0 +1,52 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// 1/100 second resolution
#define HAL_FRACTIONAL_SEC 100.0F
// This platform has 8 bit PWM
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 76.8
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_AT24C32
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
// MCU reset
#define HAL_RESET() (*((volatile uint32_t*)(PPB_BASE + 0x0ED0C))) = 0x5FA0004;
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+52
View File
@@ -0,0 +1,52 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// 1/100 second resolution
#define HAL_FRACTIONAL_SEC 100.0F
// This platform has 8 bit PWM
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255 // always use 2^n - 1, within the platform's limits
#else
#error "Configuration (Config.h): ANALOG_WRITE_RANGE can't be changed on this platform"
#endif
// Lower limit (fastest) step rate in us for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 76.8
#define HAL_PULSE_WIDTH 10000 // in ns, estimated
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_AT24C32
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
// MCU reset
#define HAL_RESET() (*((volatile uint32_t*)(PPB_BASE + 0x0ED0C))) = 0x5FA0004;
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+65
View File
@@ -0,0 +1,65 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
// Base rate for critical task timing (0.0095s = 0.14", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 105.2631579F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 34 // assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 900 // in ns, estimated
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#undef E2END
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_AT24C32
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+67
View File
@@ -0,0 +1,67 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
#define HAL_FAST_PROCESSOR
// Base rate for critical task timing (0.0057s = 0.09", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 175.4385965F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 20 // assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 450 // in ns, estimated
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#undef E2END
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_AT24C32
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+75
View File
@@ -0,0 +1,75 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
// Base rate for critical task timing (0.0038s = 0.06", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 263.1578947F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// STM32 Arduino cores (F4 + H7):
// assume global resolution functions exist; per-pin freq/res is not generic.
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 1
#define HAL_PWM_BITS_MAX 16
// F4 ADC is 12-bit; H7 can be higher, but core support varies.
// Default to 12 and let advanced HAL override to 16 for known-good H7 setup.
#define HAL_ADC_BITS_MAX 12
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_FAST_PROCESSOR
#define HAL_MAXRATE_LOWER_LIMIT 14 // assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 250 // in ns, estimated
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
// no HAL_WIRE_CLOCK, it breaks the STM32 library
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_AT24C32
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_WIRE.setSDA(PB7); \
HAL_WIRE.setSCL(PB6); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+86
View File
@@ -0,0 +1,86 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
// Base rate for critical task timing (0.0038s = 0.06", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 263.1578947F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// STM32 Arduino cores (F4 + H7):
// assume global resolution functions exist; per-pin freq/res is not generic.
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 1
#define HAL_PWM_BITS_MAX 16
// F4 ADC is 12-bit; H7 can be higher, but core support varies.
// Default to 12 and let advanced HAL override to 16 for known-good H7 setup.
#define HAL_ADC_BITS_MAX 12
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_FAST_PROCESSOR
#define HAL_MAXRATE_LOWER_LIMIT 14 // assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 250 // in ns, estimated
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#undef E2END
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#if PINMAP == FYSETC_S6_2
// The FYSETC S6 v2 has a 4096 byte EEPROM built-in
#define NV_DRIVER NV_2432
#elif PINMAP == FYSETC_S6
// The FYSETC S6 has a 2048 byte EEPROM built-in
#define NV_DRIVER NV_2416
#else
// Fallback to the EEPROM present on an ZS-042 module
#define NV_DRIVER NV_AT24C32
#endif
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+81
View File
@@ -0,0 +1,81 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
#define HAL_FAST_PROCESSOR
// Base rate for critical task timing (0.0057s = 0.09", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 175.4385965F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#ifdef STM32F401xC
#define HAL_MAXRATE_LOWER_LIMIT 20 // assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 300 // in ns, estimated
#elif STM32F411xE
#define HAL_MAXRATE_LOWER_LIMIT 20 // Lower limit (fastest) step rate in us (in SQW mode) assumes optimization set to Fastest (-O3)
#define HAL_PULSE_WIDTH 300 // in ns, estimated
#else
#define HAL_MAXRATE_LOWER_LIMIT 60
#define HAL_PULSE_WIDTH 900 // in ns, estimated
#endif
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#undef E2END
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#if PINMAP == MaxSTM3I
// The MaxPCB3I has an 8192 byte EEPROM built-in (rated for 5M write cycles)
#define NV_DRIVER NV_2464
#else
// fall back to the DS3231/AT24C32
#define NV_DRIVER NV_AT24C32
#endif
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+80
View File
@@ -0,0 +1,80 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more STM32 boards based on different lines are supported
#define __ARM_STM32__
// Base rate for critical task timing (0.0019s = 0.03", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 526.3157895F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#else
#error "Configuration (Config.h): ANALOG_READ_RANGE can't be changed on this platform"
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// STM32 Arduino cores (F4 + H7):
// assume global resolution functions exist; per-pin freq/res is not generic.
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_ADC_RESOLUTION 1
#define HAL_PWM_BITS_MAX 16
// F4 ADC is 12-bit; H7 can be higher, but core support varies.
// Default to 12 and let advanced HAL override to 16 for known-good H7 setup.
#ifndef HAL_ADC_BITS_MAX
#define HAL_ADC_BITS_MAX 12
#endif
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 1.5
#define HAL_PULSE_WIDTH 0 // effectively disable pulse mode
#define HAL_FAST_PROCESSOR
#define HAL_VFAST_PROCESSOR
#include <HardwareTimer.h>
// Interrupts
#define cli() noInterrupts()
#define sei() interrupts()
// New symbol for the default I2C port ---------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#undef E2END
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_24256
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( NAN )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
// always bring in the software serial library early as strange things happen otherwise
#include <SoftwareSerial.h>
// MCU reset
#define HAL_RESET() NVIC_SystemReset()
+82
View File
@@ -0,0 +1,82 @@
// Platform setup ------------------------------------------------------------------------------------
// Teensy3.0, 3.1, 3.2
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __TEENSYDUINO__
// This platform has digitalReadFast, digitalWriteFast, etc.
#define HAL_HAS_DIGITAL_FAST
// Base rate for critical task timing (0.0076s = 0.11", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 131.5789474F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 1
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#define HAL_PWM_BITS_MAX 16
#define HAL_PWM_HZ_MAX 200000U
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#if F_CPU >= 120000000
#define HAL_MAXRATE_LOWER_LIMIT 10
#define HAL_PULSE_WIDTH 400 // in ns, estimated
#elif F_CPU >= 96000000
#define HAL_MAXRATE_LOWER_LIMIT 12
#define HAL_PULSE_WIDTH 450 // in ns, estimated
#elif F_CPU >= 72000000
#define HAL_MAXRATE_LOWER_LIMIT 14
#define HAL_PULSE_WIDTH 500 // in ns, estimated
#else
#define HAL_MAXRATE_LOWER_LIMIT 28
#define HAL_PULSE_WIDTH 750 // in ns, estimated
#endif
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define _Tpin 38
#define HAL_TEMP() ( (-((analog.readV(_Tpin) - 0.719F)/0.001715F) + 25.0F ) )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() { \
SCB_AIRCR = 0x05FA0004; \
asm volatile ("dsb"); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+74
View File
@@ -0,0 +1,74 @@
// Platform setup ----------------------------------------------------------------------------------
// Teensy3.5
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __TEENSYDUINO__
// This platform has digitalReadFast, digitalWriteFast, etc.
#define HAL_HAS_DIGITAL_FAST
// Turn on support for using DACs to output digital signals using Arduino standard commands
#define HAL_DAC_AS_DIGITAL
// Base rate for critical task timing (0.0057s = 0.09", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 175.4385965F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 1
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#define HAL_PWM_BITS_MAX 16
#define HAL_PWM_HZ_MAX 200000U
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 12
#define HAL_PULSE_WIDTH 400 // in ns, measured 1/18/22
#define HAL_FAST_PROCESSOR
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire1
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ----------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define _Tpin 70
#define HAL_TEMP() ( (-(analog.readV(_Tpin)-0.719F)/0.001715F)+25.0F )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() { \
SCB_AIRCR = 0x05FA0004; \
asm volatile ("dsb"); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+82
View File
@@ -0,0 +1,82 @@
// Platform setup ------------------------------------------------------------------------------------
// Teensy3.6
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __TEENSYDUINO__
// This platform has digitalReadFast, digitalWriteFast, etc.
#define HAL_HAS_DIGITAL_FAST
// Turn on support for using DACs to output digital signals using Arduino standard commands
#define HAL_DAC_AS_DIGITAL
// Base rate for critical task timing (0.0038s = 0.06", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 263.1578947F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 1
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#define HAL_PWM_BITS_MAX 16
#define HAL_PWM_HZ_MAX 200000U
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#if F_CPU >= 240000000
#define HAL_MAXRATE_LOWER_LIMIT 2
#define HAL_PULSE_WIDTH 200 // in ns, estimated
#elif F_CPU >= 180000000
#define HAL_MAXRATE_LOWER_LIMIT 2.6
#define HAL_PULSE_WIDTH 300 // in ns, estimated
#else
#define HAL_MAXRATE_LOWER_LIMIT 4.8
#define HAL_PULSE_WIDTH 400 // in ns, estimated
#endif
#define HAL_FAST_PROCESSOR
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire1
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define _Tpin 70
#define HAL_TEMP() ( (-(analog.readV(_Tpin)-0.719F)/0.001715F)+25.0F )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() { \
SCB_AIRCR = 0x05FA0004; \
asm volatile ("dsb"); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
+77
View File
@@ -0,0 +1,77 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __TEENSYDUINO__
// This platform has digitalReadFast, digitalWriteFast, etc.
#define HAL_HAS_DIGITAL_FAST
// Base rate for critical task timing (0.0019s = 0.03", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 526.3157895F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 1
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#define HAL_PWM_BITS_MAX 16
#define HAL_PWM_HZ_MAX 200000U
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 1.5
#define HAL_PULSE_WIDTH 0 // effectively disable pulse mode
#define HAL_FAST_PROCESSOR
#define HAL_VFAST_PROCESSOR
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( tempmonGetTemp() )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() { \
SCB_AIRCR = 0x05FA0004; \
asm volatile ("dsb"); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
#ifdef EmptyStr
#undef EmptyStr
#endif
#define EmptyStr "\1"
#define CAT_ATTR PROGMEM
+77
View File
@@ -0,0 +1,77 @@
// Platform setup ------------------------------------------------------------------------------------
#pragma once
// We define a more generic symbol, in case more Teensy boards based on different lines are supported
#define __TEENSYDUINO__
// This platform has digitalReadFast, digitalWriteFast, etc.
#define HAL_HAS_DIGITAL_FAST
// Base rate for critical task timing (0.0019s = 0.03", 0.2 sec/day)
#define HAL_FRACTIONAL_SEC 526.3157895F
// Analog read and write
#ifndef HAL_VCC
#define HAL_VCC 3.3F
#endif
#ifndef ANALOG_READ_RANGE
#define ANALOG_READ_RANGE 1023
#endif
#ifndef ANALOG_WRITE_RANGE
#define ANALOG_WRITE_RANGE 255
#endif
// analog read/write capabilities
#define HAL_HAS_PER_PIN_PWM_RESOLUTION 0
#define HAL_HAS_PER_PIN_PWM_FREQUENCY 1
#define HAL_HAS_GLOBAL_PWM_RESOLUTION 1
#define HAL_HAS_GLOBAL_PWM_FREQUENCY 0
#define HAL_PWM_BITS_MAX 16
#define HAL_PWM_HZ_MAX 200000U
// Lower limit (fastest) step rate in uS for this platform (in SQW mode) and width of step pulse
#define HAL_MAXRATE_LOWER_LIMIT 1.5
#define HAL_PULSE_WIDTH 0 // effectively disable pulse mode
#define HAL_FAST_PROCESSOR
#define HAL_VFAST_PROCESSOR
// New symbol for the default I2C port -------------------------------------------------------------
#include <Wire.h>
#ifndef HAL_WIRE
#define HAL_WIRE Wire
#endif
#ifndef HAL_WIRE_CLOCK
#define HAL_WIRE_CLOCK 100000
#endif
// Non-volatile storage ------------------------------------------------------------------------------
#if NV_DRIVER == NV_DEFAULT
#undef NV_DRIVER
#define NV_DRIVER NV_EEPROM
#endif
//--------------------------------------------------------------------------------------------------
// Internal MCU temperature (in degrees C)
#define HAL_TEMP() ( tempmonGetTemp() )
//--------------------------------------------------------------------------------------------------
// General purpose initialize for HAL
#define HAL_INIT() { \
HAL_FAST_TICKS_INIT(); \
}
#define HAL_RESET() { \
SCB_AIRCR = 0x05FA0004; \
asm volatile ("dsb"); \
}
//---------------------------------------------------------------------------------------------------
// Misc. includes to support this processor's operation
#ifdef EmptyStr
#undef EmptyStr
#endif
#define EmptyStr "\1"
#define CAT_ATTR PROGMEM