AN672
5. Base Component
COMPONENT: si32BaseComponent
REQUIRES: none
PROVIDES: none
This component provides facilities for logging, error handling, memory allocation, and control flow.
5.1. Build Options
si32Base.h provides benign defaults for all available build options. To change a build option for an application,
enable or disable that option as appropriate in the application's myBuildOptions.h.
si32BuildOption_enable_assertions: Enables si32Assert(). Default is off.
si32BuildOption_enable_logging: Enables logging. Logging must be enabled to use any si32LogXXX()
routine. Default is off.
si32BuildOption_log_flow: Enables si32LogPrologue(), si32LogSelf(), si32LogArg(), si32LogAttr(),
si32LogVar, si32LogEpilogue(). Default is off.
si32BuildOption_log_ref_counts: Enables logging of reference counts if _log_flow is also enabled.
Default is off.
si32BuildOption_tally_allocations: Dynamic allocations encode size information for leak checking.
Default is off.
si32BuildOption_retention_zone_size: Retention allocation zone reserve (for MCUs with retention
RAM). Default is 1.
si32BuildOption_incremental_zone_size: Incremental allocation zone reserve. Default is 1.
si32BuildOption_addressable_labels: Enable use of computed labels instead of switch abuse for local
continuations. Default is off; switch/case is used.
si32BuildOption_logPath: Workstation platforms can log to a file. Default is "/dev/stdout".
5.2. Logging
si32BaseLogger.h defines a number of macros for logging waypoints during program execution. These depend
on the si32HAL and require use of si32HAL/CPU/retarget_<chain>.c to redirect printf/scanf primitives to ITM, a
UART, or some other device.
void si32StartLogging(void): Configures the logging subsystem and initiates logging. For simulation
builds on workstations this opens the log file.
void si32StopLogging(void): Terminates logging. For simulation builds on workstations this closes the log
file.
void si32LogBeSilent(bool yn): Used to temporarily change the state of the logger without disabling it, or
recompiling to turn it off. When silent the log does not send data to ITM etc.
bool si32LogIsSilent(void): Queries whether the log is silent, or verbose.
void si32LogBeIndented(bool yn): Controls whether the log is indented. When YES, si32LogPrologue()
indents the log, and si32LogEpilogue() outdents the log, in addition to logging the entry/exit of a function,
respectively. The default is YES, indent the log.
bool si32LogIsIndented(void): Queries whether the log is indented, or flat.
int si32LogPrint(char* fmt, ...): Prints to the log, with parameters similar to printf. Does not indent, even
when preceded by si32LogBeIndented(YES). Does not append a newline. For io retargeting, it essentially
just wraps printf.
int si32LogTrace(char* fmt, ...): Prints to the log, with parameters similar to printf. It indents per
si32LogBeIndented(yn) and appends a newline.
int si32LogWarning(char* fmt, ...): Prints to the log, with parameters similar to printf. It indents per
si32LogBeIndented(yn). Prepends "WARNING: " and appends a newline.
int si32LogError(char* fmt, ...): Prints to the log, with parameters similar to printf. It indents per
Rev. 0.1
5