|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Data Operation Circuit (DOC) hardware vs software check. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_doc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | doc_demo_const_t : uint32_t { k_doc_demo_period_ms = 1000U } |
| Demo tunables. More... | |
| enum | doc_demo_layout_t : uint8_t { k_doc_demo_table_len = 8U } |
| Operand-table layout. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Park the core after an unrecoverable DOC demo failure. | |
| static uint16_t | internal_sw_sum (void) |
| Software reference: sum every operand modulo 2^16. | |
| static ra8_err_t | internal_hw_sum (uint16_t *out_sum) |
| Hardware DOC sum: chain seven add16 calls into the accumulator. | |
| static void | internal_setup_or_halt (void) |
| Bring CGC, SysTick, both LEDs, and DOC up or halt. | |
| static ra8_err_t | internal_one_iter (uint8_t *out_match) |
| One iteration: HW sum + SW sum + compare. | |
| void | main (void) |
| Compare DOC and software sums continuously for HIL observation. | |
Variables | |
| static const uint16_t | s_doc_demo_operands [k_doc_demo_table_len] |
| Eight 16-bit operands chained through DOC.add. | |
| volatile uint32_t | g_doc_match = 0U |
| HIL liveness counter – incremented on every iteration where the hardware DOC sum matched the software reference sum. | |
| volatile uint32_t | g_doc_mismatch = 0U |
| HIL failure counter – incremented every time the hardware DOC sum disagreed with the software reference, or the DOC accumulator call returned a non-ok status. | |
Data Operation Circuit (DOC) hardware vs software check.
The on-chip Data Operation Circuit accepts 16-bit add / subtract / compare operations and stores the result in DODSR (HUM Ch "DOC"). This app sums an 8-entry constant table both via the hardware ra8_doc_add16 API (chained accumulator) and via a portable software reference, then compares the two checksums every second. LED1 toggles on a match; LED2 latches if the two ever diverge.
The HAL only exposes 16-bit add and sub (no XOR), so we exercise the add path – it is sufficient to prove DOC bring-up + register access + result readback. Bare EK-RA8D2; no expansion board.
Definition in file main.c.
| enum doc_demo_const_t : uint32_t |
| enum doc_demo_layout_t : uint8_t |
|
staticnodiscard |
Hardware DOC sum: chain seven add16 calls into the accumulator.
Seeds the accumulator from the first table item, applies each remaining operand through DOC add16, and publishes only the final complete result.
| [out] | out_sum | Receives the chained DOC sum. |
| k_ra8_ok | Every DOC addition succeeded and *out_sum was written. |
| (other) | The first DOC operation error, returned without publishing. |
Definition at line 163 of file main.c.
References k_doc_demo_table_len, k_ra8_ok, ra8_doc_add16(), RA8_INTERNAL, and s_doc_demo_operands.
Referenced by internal_one_iter().
|
staticnodiscard |
One iteration: HW sum + SW sum + compare.
Runs the hardware calculation first, computes the immutable software reference only after hardware success, and normalizes equality to a one-byte boolean result.
| [out] | out_match | Receives 1 if hw == sw, 0 otherwise. |
| k_ra8_ok | *out_match contains the normalized comparison result. |
| (other) | Hardware calculation failed and comparison was skipped. |
Definition at line 237 of file main.c.
References internal_hw_sum(), internal_sw_sum(), k_ra8_ok, and RA8_INTERNAL.
Referenced by main().
|
static |
Park the core after an unrecoverable DOC demo failure.
Repeatedly executes WFI, retaining DOC and clock state for debugging.
Definition at line 68 of file main.c.
References RA8_INTERNAL.
|
static |
Bring CGC, SysTick, both LEDs, and DOC up or halt.
Initializes dependencies in order and transfers to the panic helper on the first failed HAL operation.
Definition at line 189 of file main.c.
References internal_panic_halt(), k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_doc_init(), RA8_INTERNAL, and ra8_time_init().
|
static |
Software reference: sum every operand modulo 2^16.
Walks the immutable operand table in order with explicit 16-bit wraparound, providing the reference for the DOC accumulator.
| 0..UINT16_MAX | Deterministic modulo-2^16 table sum. |
Definition at line 130 of file main.c.
References k_doc_demo_table_len, RA8_INTERNAL, and s_doc_demo_operands.
Referenced by internal_one_iter().
| void main | ( | void | ) |
Compare DOC and software sums continuously for HIL observation.
The application entry point Reset_Handler hands control to.
Initializes the demo, executes one comparison per period, increments the exported match or mismatch counter, and toggles the matching LED.
Definition at line 260 of file main.c.
References g_doc_match, g_doc_mismatch, internal_one_iter(), internal_panic_halt(), internal_setup_or_halt(), k_doc_demo_period_ms, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
| volatile uint32_t g_doc_match = 0U |
HIL liveness counter – incremented on every iteration where the hardware DOC sum matched the software reference sum.
Read externally by scripts/hil/jlink_memprobe.sh via SWD. The probe asserts this counter advances by >= HIL_PROBE_MIN_ADVANCE over the sample window, proving the DOC peripheral actually computed the same chained-add result as the portable software reference (the alive-mode check could only prove the chip didn't crash, not that DOC arithmetic was correct).
Definition at line 91 of file main.c.
Referenced by main().
| volatile uint32_t g_doc_mismatch = 0U |
HIL failure counter – incremented every time the hardware DOC sum disagreed with the software reference, or the DOC accumulator call returned a non-ok status.
The memprobe asserts this stays at 0 (or below HIL_PROBE_MAX_FAILURE). Catches silent failure modes where DOC reports success but produces a wrong DODSR result, or where the driver returns an error code – both previously invisible because the chip kept iterating the main loop.
Definition at line 108 of file main.c.
Referenced by main().
|
static |
Eight 16-bit operands chained through DOC.add.
Definition at line 47 of file main.c.
Referenced by internal_hw_sum(), and internal_sw_sum().