67typedef enum : uintptr_t {
189 volatile uint32_t ipsr = 0U;
190 __asm__
volatile(
"mrs %0, ipsr" :
"=r"(ipsr));
197 if ((tcr & 1U) == 0U) {
200 if ((tenr & 1U) == 0U) {
250 k_ra8_itm_poll_limit = 1000U,
252 for (uint32_t i = 0U; i < k_ra8_itm_poll_limit; i++) {
304typedef enum : uint8_t {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_HW_REGISTER_ACCESS
Mark an MMIO accessor function (returns volatile register pointer).
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_rtos_mutex
Mutex API error (reserved for future use).
@ k_ra8_err_retry_limit
Retry budget exhausted – operation still failing after all attempts.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_crc_mismatch
CRC mismatch detected on received data.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_empty
Container empty – nothing to retrieve.
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_rtos_thread_create
Thread create failed (reserved for future use).
@ k_ra8_err_no_data
No application data available (e.g.
@ k_ra8_err_decomp_ratio
Compression ratio bound breached (ra8_decomp_limits_t).
@ k_ra8_err_would_block
Non-blocking operation would have blocked.
@ k_ra8_err_not_empty
Container still holds members – the operation requires it empty.
@ k_ra8_err_hw_unmapped
Peripheral register block is not mapped in this MCU variant.
@ k_ra8_err_spi_error
SPI transfer failed (bus fault, mode fault, overrun, ...).
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ k_ra8_fail
Generic unspecified failure.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_exists
Item already exists – cannot create again.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_err_decomp_output_cap
Decompression output cap breached (ra8_decomp_limits_t).
@ k_ra8_err_range_check_failed
Value outside range enforced by RA8_CHECK_RANGE / RA8_CHECK_RANGE_TAG.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_hw_not_ready
Hardware peripheral exists but not ready yet.
@ k_ra8_err_rtos_queue
Queue / message API error (reserved for future use).
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_rtos_error
Generic RTOS error (reserved for future use).
@ k_ra8_err_gpio_invalid_pin
GPIO pin index out of range within its port (valid: 0..15).
@ k_ra8_err_estop
Emergency stop active – operation forbidden until cleared.
@ k_ra8_err_access_denied
Operation refused because the target is protected against it.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_gpio_conflict
GPIO pin already owned by another peripheral or driver.
@ k_ra8_err_decomp_iterations
Decode-loop iteration budget exhausted (ra8_decomp_limits_t).
@ k_ra8_err_uart_error
UART / SCI error (framing, parity, overrun, break).
@ k_ra8_err_i2c_error
I2C / IIC error (arbitration lost, NACK, timeout, bus error).
@ k_ra8_err_timeout
Operation exceeded its time budget.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ k_ra8_err_comm_error
Generic communication error (use a more specific code when possible).
@ k_ra8_err_rtos_timer
Timer API error (reserved for future use).
@ k_ra8_err_cancelled
Operation cancelled before completion.
@ k_ra8_err_conflict
Conflict with concurrent access detected.
@ k_ra8_err_decomp_depth
Container nesting-depth cap breached (ra8_decomp_limits_t).
@ k_ra8_err_rtos_semaphore
Semaphore API error (reserved for future use).
@ k_ra8_err_nack
Peer responded with NACK (negative acknowledgement).
@ k_ra8_err_gpio_invalid_port
GPIO port index out of range for this MCU.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
@ k_ra8_err_decomp_entries
Archive entry-count cap breached (ra8_decomp_limits_t).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
static volatile uint32_t * internal_itm_tenr(void)
Get the ITM Trace Enable Register.
static void * s_byte_sink_ctx
Opaque cookie passed back to s_byte_sink on every byte.
static void internal_itm_puts(const char *s)
Emit a NUL-terminated string over ITM port 0.
ra8_log_u32_t
Emit an unsigned decimal integer over ITM port 0.
@ k_ra8_decimal_base
Decimal radix.
@ k_ra8_u32_max_digits
Max decimal digits in a uint32_t.
static bool internal_itm_ready(void)
Check whether ITM port 0 is enabled and ready to accept bytes.
void ra8_log_init(void)
Default log backend init – no-op for the ITM sink.
static const ra8_err_name_entry_t s_ra8_err_names[]
Lookup table backing ra8_err_to_str().
void ra8_log_set_byte_sink(ra8_log_byte_sink_fn_t fn, void *ctx)
Install (or clear) an optional byte sink for log output.
void ra8_log_emit_info(const char *tag, const char *message)
Emit an INFO-level log line with only a tag and a message.
static void internal_emit_line(const char *level, const char *tag, const char *msg)
Common tagged-line emit helper.
void ra8_log_emit_error(const char *tag, const char *message)
Emit an ERROR-level log line with only a tag and a message.
static void internal_emit_line_i(const char *level, const char *tag, const char *msg, int32_t value)
Common tagged-line-with-value emit helper (signed).
static volatile uint32_t * internal_itm_tcr(void)
Get the ITM Trace Control Register.
void ra8_log_emit_debug(const char *tag, const char *message)
Emit a DEBUG-level log line with only a tag and a message.
static void internal_itm_putc(uint8_t byte)
Blocking-but-bounded write of a single byte to ITM port 0.
static void internal_itm_put_i32(int32_t value)
Emit a signed decimal integer over ITM port 0.
static volatile uint32_t * internal_itm_stim0(void)
Get the ITM stimulus-port-0 register.
void ra8_log_emit_info_val(const char *tag, const char *message, uint32_t value)
INFO-level log emitter that also reports a uint32 value.
void ra8_log_emit_warn_val(const char *tag, const char *message, uint32_t value)
WARN-level log emitter that also reports a uint32 value.
static ra8_log_byte_sink_fn_t s_byte_sink
Active log byte sink, or nullptr to use the default ITM port.
@ k_ra8_itm_stim_base
ITM stimulus port 0 base.
@ k_ra8_itm_tcr_addr
ITM Trace Control Register.
@ k_ra8_itm_tenr_addr
ITM Trace Enable Register.
void ra8_log_emit_debug_val(const char *tag, const char *message, int32_t value)
DEBUG-level log emitter that also reports a signed int32 value.
void ra8_log_emit_error_val(const char *tag, const char *message, uint32_t value)
ERROR-level log emitter that also reports a uint32 value.
static void internal_itm_put_u32(uint32_t value)
const char * ra8_err_to_str(ra8_err_t err)
Implementation of ra8_err_to_str() – linear-scan lookup.
static void internal_emit_line_u(const char *level, const char *tag, const char *msg, uint32_t value)
Common tagged-line-with-value emit helper (unsigned).
void ra8_log_emit_warn(const char *tag, const char *message)
Emit a WARN-level log line with only a tag and a message.
static const uint32_t s_ra8_err_names_count
Number of entries in s_ra8_err_names.
Lightweight Logging Interface for ra8-firmware.
void(* ra8_log_byte_sink_fn_t)(void *ctx, uint8_t byte)
Optional per-byte sink for redirecting log output off ITM.
Cortex-M85 System Control Block: VTOR relocation + fault-status decode.
bool ra8_scb_trace_enabled(void)
Report whether DEMCR.TRCENA (trace subsystem enable) is set.
Single (code, name) pair in the ra8_err_to_str() lookup table.
const char * name
Short ASCII name for the code (no spaces).
ra8_err_t code
Error code value from ra8_err_t.