3.1 KiB
STA Core library
Collection of useful stuff.
Modules
Assert
Assertion handling.
Configuration:
#define STA_ASSERT_ENABLE
: Enable module#define STA_ASSERT_DISABLE
: Forces module off when defined#define STA_HALT <func_name>
: Override function called after failed assertsDEBUG
: Automatically enables module when definedNDEBUG
: Forces module off when defined
Both sta::assert_failed
and sta::assert_halt
provide weak definitions and
can be overridden by the application. sta::assert_halt
is only called
via the STA_HALT macro which can also be provided by the application.
The default implementation of sta::assert_failed
uses STA_DEBUG_PRINT internally
and will not generate any output if the DEBUG_SERIAL module is disabled.
Debug Serial
Debug serial output macros.
Configuration:
#define STA_DEBUG_SERIAL_ENABLE
: Enable module#define STA_DEBUG_SERIAL_FORCE
: Ignore debug defines and always enable outputDEBUG
: Enables output when definedNDEBUG
: Disables output when defined (overrides DEBUG)
The sta::DebugSerial
instance must be provided.
Endian
Endian-ness conversion for multi-byte types.
Enum Flags
Type for using enum values as combinable flags.
Lang
Macros related to compiler features. Not actually part of the C/C++ language.
MCU
Defines specific to different MCUs. Include the appropriate header from sta/mcu
for the MCU used by the application in the <sta/config.hpp>
header.
Printf
Choose which printf
implementation is used by STA libraries.
Configuration:
#define STA_PRINTF_USE_STDLIB
: Use the stdlib implementation#define STA_PRINTF_USE_MPALAND
: Use the implementation by Marco Paland (thread safe & reentrant)
HAL Delay
HAL based delay functions.
Configuration:
#define STA_HAL_DELAY_ENABLE
: Enable module#define STA_HAL_DELAY_US_TIM <tim_handle>
: 1 MHz TIM instance used bysta::delayUs
TIM time base must be started before using sta::delayUs
by calling sta::initHAL
.
When using the startup system task this is handled automatically.
Interfaces
The intention of these interfaces is to provide an abstraction layer for commonly used resources. Libraries using these interfaces can be reused on different platforms by simply implementing the required interfaces for the selected platform.
Interfaces for the following resources are provided:
- GPIO pin
- Mutex
- Signal
- SPI
- UART
HAL implementations
Implementations using the HAL are provided for the following interfaces:
- GpioPin
- SpiInterface, SpiDevice
- UART
To enable these implementations follow the instructions from the individual headers.
Atomic implementations
Implementations using atomic variables are provided for the following interfaces:
- Mutex
- Signal
To enable these implementations define STA_ATOMIC_ENABLE
in <sta/config.hpp>
.