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(). |
| 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). |
| HardwareSerial & | diagSerial () Access DiagSerial directly for multi-field formatted output. |
| 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 | 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. Call once per loop() iteration. |
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 ()
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 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.
function diagSerial
Access DiagSerial directly for multi-field formatted output.
HardwareSerial & STM32Board::diagSerial ()
Guard with isDebug() to avoid formatting overhead when debug is off.
Returns:
Reference to the USART1 HardwareSerial instance.
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).
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 INT8_MIN if the internal channels are unavailable on this variant.
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.
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.
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.
function tick
Drive LED animations. Call once per loop() iteration.
void STM32Board::tick ()
Advances blink state using millis(). Fully non-blocking.
The documentation for this class was generated from the following file Firmware/Libraries/STM32Board/STM32Board.cpp