Namespace STM32Board
Public Static Attributes
| Type | Name |
|---|---|
| constexpr uint8_t | PIN_LED_GREEN = PB15Green LED pin — same on all STM32 boards. |
| constexpr uint8_t | PIN_LED_RED = PB14Red LED pin — same on all STM32 boards. |
Public Functions
| Type | Name |
|---|---|
| void | begin () Initialise all shared hardware. Call once at the top of setup(). |
| uint8_t | bootloaderVersion () The installed bootloader's protocol version, or 0 when there is none (#365). |
| CAN_HandleTypeDef * | canHandle () Access the HAL CAN handle. |
| bool | clockFault () True if SystemClock_Config could not lock the intended 72 MHz HSE tree and fell back to internal RC (issue #245). |
| Uart & | diagSerial () Access DiagSerial directly for multi-field formatted output. |
| void | enterBootloader (uint8_t via) Reset into the bootloader, which then stays for an update (#365). Never returns when a bootloader is installed that can be reached over via ; otherwise returns, doing nothing. |
| bool | isDebug () Returns true when debug output is enabled. |
| void | log (const char * msg) Print a line to DiagSerial if debug is enabled; no-op otherwise. |
| void | logNodeFaultEdge (const char * tag, NodeFaultCode fault, const char * detail) Edge-log a node's fault transition to DiagSerial (#163). |
| void | markBootHealthy () Tell the bootloader this boot made it — clears its crash-loop counter (#364). |
| void | onCanStatus (CanStatus status) CAN bus status event handler — maps CanStatus to LED state. |
| int8_t | readDieTempC () Read the MCU's built-in internal temperature sensor (ADC ch16). |
| uint16_t | readVddMv () Estimate MCU Vdd from the internal reference (Vrefint, ADC ch17). |
| void | setDebug (bool on) Enable or disable DiagSerial output. |
| void | setLinkActive (bool active) Signal that application data is actively flowing → CONNECTED (green solid). |
| void | setWarning (bool on=true) Raise or clear the WARNING condition — red/green alternating at 500 ms. |
| void | tick () Drive LED animations. Called once per loop() iteration by the node library. |
Public Static Functions
| Type | Name |
|---|---|
| volatile uint32_t * | backupRegister (uint8_t n) |
Public Static Attributes Documentation
variable PIN_LED_GREEN
Green LED pin — same on all STM32 boards.
constexpr uint8_t STM32Board::PIN_LED_GREEN;
variable PIN_LED_RED
Red LED pin — same on all STM32 boards.
constexpr uint8_t STM32Board::PIN_LED_RED;
Public Functions Documentation
function begin
Initialise all shared hardware. Call once at the top of setup().
void STM32Board::begin ()
Releases JTAG and keeps SWD (#299), so PA15 / PB3 / PB4 are ordinary GPIO from here on. Configures PB14 (Red) and PB15 (Green) as outputs, enters BOOTING LED state. Starts DiagSerial (USART1 PA9/PA10, 115200 baud) — silent until setDebug(true). Configures the CAN peripheral at 500 kbps on PA11/PA12 but does NOT start it — call CANProtocol::start() after filter setup.
function bootloaderVersion
The installed bootloader's protocol version, or 0 when there is none (#365).
uint8_t STM32Board::bootloaderVersion ()
Read from the bootloader's info block (BootProtocol.h INFO_ADDRESS) — only when this app runs behind the bootloader (VTOR at the app offset), so an image linked at 0x08000000 always reads 0. Reported in READY_n byte 3 and the bridge's own _NODE_STATUS row.
function canHandle
Access the HAL CAN handle.
CAN_HandleTypeDef * STM32Board::canHandle ()
Note:
Internal — used by CANProtocol only. Do not call from sketches.
Returns:
Pointer to the internal CAN_HandleTypeDef.
function clockFault
True if SystemClock_Config could not lock the intended 72 MHz HSE tree and fell back to internal RC (issue #245).
bool STM32Board::clockFault ()
When set, the CAN bit timing (tuned for 36 MHz APB1) is wrong for the actual clock, so callers MUST NOT drive the bus — a faulted node transmitting at the wrong rate corrupts every other frame. CANProtocol::start() consults this and comes up in listen-only (silent) mode instead. Latched once at boot; read-only.
Note:
Library-internal: read by CANProtocol for node health. Not sketch API — not covered by the compatibility policy (#295).
function diagSerial
Access DiagSerial directly for multi-field formatted output.
Uart & STM32Board::diagSerial ()
Guard with isDebug() to avoid formatting overhead when debug is off.
Returns:
Reference to the USART1 Uart instance.
function enterBootloader
Reset into the bootloader, which then stays for an update (#365). Never returns when a bootloader is installed that can be reached over via ; otherwise returns, doing nothing.
void STM32Board::enterBootloader (
uint8_t via
)
Sets the bootloader's one-shot entry flag (backup register DR1) and resets. Called by CANProtocol for a CONNECT on this node's BOOT_CMD_n (via TRANSPORT_CAN), and by PanelBridge for the host's BRIDGE_ENTER_EXPORT_ADDRESS (via TRANSPORT_SERIAL, #367).
Parameters:
viaBootProtocol.h TRANSPORT_CAN or TRANSPORT_SERIAL — the way the request came in.
function isDebug
Returns true when debug output is enabled.
bool STM32Board::isDebug ()
Guard multi-field formatted print blocks with this to skip string formatting overhead when debug is off.
function log
Print a line to DiagSerial if debug is enabled; no-op otherwise.
void STM32Board::log (
const char * msg
)
Parameters:
msgNull-terminated string to print.
function logNodeFaultEdge
Edge-log a node's fault transition to DiagSerial (#163).
void STM32Board::logNodeFaultEdge (
const char * tag,
NodeFaultCode fault,
const char * detail
)
Prints [<tag>] degraded: <detail> (fault N) on entering or changing a fault, and [<tag>] recovered on clearing — only on a change, and only when isDebug() (no formatting cost otherwise). Shared by every node's health-TX loop (PanelGroup, PanelBridge, future PDU).
Holds its own static prev-fault state. A firmware binary has exactly ONE node identity (a build is either a PanelGroup node or the bridge), so a single static is correct — the node's aggregated fault, not per-source. Detail strings stay local — never on the CAN wire.
Parameters:
tagShort node tag for the log line, e.g. "NODE" or "BRIDGE".faultThe node's current aggregated NodeFaultCode (from OpenSkyhawk::aggregateFaults()).detailThat fault's faultDetail() (non-null; ignored when fault == NONE).
Note:
Library-internal: used by the node-status service. Not sketch API — not covered by the compatibility policy (#295).
function markBootHealthy
Tell the bootloader this boot made it — clears its crash-loop counter (#364).
void STM32Board::markBootHealthy ()
The bootloader counts every jump to the app in a backup register and stays in charge (APP_UNSTABLE) once the count reaches BootProtocol's ATTEMPT_LIMIT. Call once the node has finished booting: PanelGroup / PduNode after READY, PanelBridge at the end of setup(). Harmless on a board without the bootloader.
Note:
Library-internal: the node libraries call it. Not sketch API — not covered by the compatibility policy (#295).
function onCanStatus
CAN bus status event handler — maps CanStatus to LED state.
void STM32Board::onCanStatus (
CanStatus status
)
Register with CANProtocol::onStatusChange(STM32Board::onCanStatus) in setup(). Never call directly from sketch code.
Parameters:
statusNew CAN bus status reported by CANProtocol.
function readDieTempC
Read the MCU's built-in internal temperature sensor (ADC ch16).
int8_t STM32Board::readDieTempC ()
Free per-node thermal telemetry — no external parts, no PCB change. Reads ATEMP and AVREF (Vrefint) and converts with STM32F103 datasheet typicals (V25 = 1.43 V, Avg_Slope = 4.3 mV/°C), referencing Vsense to the measured Vdd.
Note:
UNCALIBRATED: no factory trim → ~±few °C absolute; measures DIE temperature (not ambient) with a self-heat offset. Use for relative trend / overheat flagging, not precise ambient measurement.
Returns:
Die temperature in whole °C, or DIE_TEMP_UNAVAILABLE (NodeStatus.h) if the internal channels are unavailable on this variant.
Note:
Library-internal: read by CANProtocol for HEALTH_n. Not sketch API — not covered by the compatibility policy (#295).
function readVddMv
Estimate MCU Vdd from the internal reference (Vrefint, ADC ch17).
uint16_t STM32Board::readVddMv ()
Note:
Uses the STM32F103 typical Vrefint of 1.20 V (the F103 has no VREFINT_CAL factory value), so absolute accuracy is limited; good for relative trend.
Returns:
Vdd in millivolts, or 0 if the internal reference is unavailable.
Note:
Library-internal: a diagnostic for the node libraries. Not sketch API — not covered by the compatibility policy (#295).
function setDebug
Enable or disable DiagSerial output.
void STM32Board::setDebug (
bool on
)
DiagSerial is always initialised by begin(); this flag gates all log() calls.
Parameters:
onTrue to emit output on USART1; false for silence (default).
function setLinkActive
Signal that application data is actively flowing → CONNECTED (green solid).
void STM32Board::setLinkActive (
bool active
)
Call setLinkActive(true) on each unit of inbound data (PanelBridge: a DCS-BIOS export seen; PanelGroup: a CTRL_BCAST received). The link auto-decays back to NORMAL after ~500 ms with no further calls. CONNECTED is only shown while the CAN bus is healthy; a CAN fault masks it and it re-engages automatically on recovery if data is still flowing.
Parameters:
activeTrue to (re)assert the data-flowing link; false to drop it immediately.
Note:
Library-internal: driven by PanelGroup and PanelBridge. Not sketch API — not covered by the compatibility policy (#295).
function setWarning
Raise or clear the WARNING condition — red/green alternating at 500 ms.
void STM32Board::setWarning (
bool on=true
)
Call when a degraded condition is detected that is not represented by CanStatus (e.g. SYNC timeout, dead PanelGroup node, lost master heartbeat). WARNING outranks CONNECTED/NORMAL but is masked by any CAN fault (CAN_ERROR/BUS_OFF). Clear it with setWarning(false) once the condition recovers.
Parameters:
onTrue to raise WARNING (default); false to clear it.
Note:
Library-internal: raised by CANProtocol and PanelBridge. Not sketch API — not covered by the compatibility policy (#295).
function tick
Drive LED animations. Called once per loop() iteration by the node library.
void STM32Board::tick ()
Advances blink state using millis(). Fully non-blocking.
Note:
Library-internal: PanelGroup / PanelBridge / PduNode call it from their loop(). Not sketch API — not covered by the compatibility policy (#295).
Public Static Functions Documentation
function backupRegister
static volatile uint32_t * STM32Board::backupRegister (
uint8_t n
)
The documentation for this class was generated from the following file Firmware/Libraries/STM32Board/STM32Board.cpp