Speeduino
Loading...
Searching...
No Matches
board_definition.h
Go to the documentation of this file.
1#pragma once
2
10#include <stdint.h>
11#include <Arduino.h>
13#include "src/stdlib/limits.h"
14#include "storage_api.h"
15
16// Forward declarations
17struct pinNumbers_t;
18
26void initBoard(uint32_t baudRate);
27
33void boardInitPins(uint8_t boardID, pinNumbers_t &pins);
34
36uint16_t freeRam(void);
37
39void doSystemReset(void);
40
43
45uint8_t getSystemTemp(void);
46
49
52
54// Shared building blocks for the board headers
55#define _ANALOG_PINS_A0_A8 A0, A1, A2, A3, A4, A5, A6, A7, A8
56#define _ANALOG_PINS_A0_A14 _ANALOG_PINS_A0_A8, A9, A10, A11, A12, A13, A14
58
59// Include a specific header for a board.
60#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
61 #include "board_avr2560.h"
62#elif defined(CORE_TEENSY)
63 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
64 #include "board_teensy35.h"
65 #elif defined(__IMXRT1062__)
66 #include "board_teensy41.h"
67 #endif
68#elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(STM32)
69 #include "board_stm32_official.h"
70#elif defined(__SAME51J19A__)
71 #include "board_same51.h"
72// Allow external injection of the board definition via compiler flags
73#elif defined(EXTERNAL_BOARD_H)
74 #include EXTERNAL_BOARD_H
75#else
76 #error Incorrect board selected. Please select the correct board (Usually Mega 2560) and upload again
77#endif
78
79#if defined(RTC_ENABLED)
81void boardInitRTC(void);
82#endif
83
84// It is important that we cast this to the actual overflow limit of the timer.
85// The compare variables type can be wider than the timer overflow.
86#define SET_COMPARE(compare, value) (compare) = (COMPARE_TYPE)(value)
87
90
91#if !defined(NOT_A_PIN)
92constexpr uint8_t NOT_A_PIN = UINT8_MAX; // Note that zero is a valid pin number, so we can't use that to indicate an unused pin
93#endif
static constexpr uint32_t ticksToMicros(COMPARE_TYPE ticks)
Convert timer ticks to µS.
Definition board_avr2560.h:48
uint8_t getSystemTemp(void)
Get the board temp for display in TunerStudio (optional)
constexpr uint32_t MAX_TIMER_PERIOD
The longest period of time (in uS) that the timer can permit.
Definition board_definition.h:89
void boardInitPins(uint8_t boardID, pinNumbers_t &pins)
Pin specific initialisation (optional - can be empty)
storage_api_t getBoardStorageApi(void)
Get the storage API for the board.
uint8_t getPwmTimerResolution(void)
Get the PWM timer resolution in uS.
constexpr uint8_t NOT_A_PIN
Definition board_definition.h:92
void jumpToBootloader(void)
Trigger the boot loader (optional)
void initBoard(uint32_t baudRate)
Initialise the board, including USB comms.
void doSystemReset(void)
Reset the board (optional)
uint16_t freeRam(void)
Calculate free RAM for display in TunerStudio.
Minimal polyfill for the standard library type traits, since it isn't available with avr-gcc.
static fastOutputPin_t pins[_countof(coil_pins_t::_elements)]
Definition scheduledIO_direct_ign.cpp:10
Defines the required external storage API plus some convenience functions built around that API.
Definition limits.h:12
Store the pin assignments, as defined by the board.
Definition pinNumbers_t.h:40
The external storage API. This must be supported by any storage system. E.g. EEPROM,...
Definition storage_api.h:20
Minimal polyfill for the standard library type traits, since it isn't available with avr-gcc.