|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ADC_B self-diagnosis (modes 1/2/3) + on-die temperature demo. More...
#include <stddef.h>#include <stdint.h>#include "ra8_adc.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"#include "ra8_tsn.h"Go to the source code of this file.
Enumerations | |
| enum | adc_diag_const_t : uint32_t { k_adc_diag_baud = 115200U , k_adc_diag_period_ms = 500U } |
| Demo tunables. More... | |
| enum | adc_diag_fmt_t : uint8_t { k_adc_diag_num_modes = 3U , k_adc_diag_radix = 10U , k_adc_diag_dec_max = 10U , k_adc_diag_minus = '-' } |
| Formatting + iteration constants. More... | |
| enum | adc_diag_tsn_t : uint16_t { k_adc_diag_stab_us = 30U } |
| TSN factory-trim selection (Tj_max part). More... | |
Functions | |
| static void | adc_diag_panic_halt (void) |
| Park forever after a fatal init error. | |
| static void | adc_diag_write (const uint8_t *data, uint32_t len) |
| Write a byte span to the SCI8 console, discarding the status. | |
| static uint32_t | adc_diag_u32_to_dec (uint8_t *buf, uint32_t val) |
| Serialise an unsigned 32-bit value into decimal ASCII. | |
| static void | adc_diag_write_u32 (uint32_t val) |
| Log one unsigned 32-bit value as decimal ASCII. | |
| static void | adc_diag_write_i32 (int32_t val) |
| Log one signed 32-bit value (leading minus for negatives). | |
| static void | adc_diag_emit_mode (uint8_t mode_num, uint16_t code, bool pass) |
| Emit one diag: mode=N code=CCCCC PASS|FAIL line. | |
| static bool | adc_diag_run_cycle (void) |
| Run one self-test cycle: 3 self-diagnosis modes + temp + Vref. | |
| static void | adc_diag_setup_or_halt (void) |
| Core bring-up: CGC -> MSTP -> TIME -> console + LED. | |
| static ra8_err_t | adc_diag_arm (void) |
| Initialise the ADC16H and the temperature sensor. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const ra8_adc_selfdiag_mode_t | k_adc_diag_modes [k_adc_diag_num_modes] |
| Ordered list of self-diagnosis modes to sweep each cycle. | |
| static const uint8_t | k_adc_diag_mode_prefix [] = "diag: mode=" |
| static const uint8_t | k_adc_diag_code_sep [] = " code=" |
| static const uint8_t | k_adc_diag_pass_sfx [] = " PASS\r\n" |
| static const uint8_t | k_adc_diag_fail_sfx [] = " FAIL\r\n" |
| static const uint8_t | k_adc_diag_tsn_prefix [] = "tsn: die_mC=" |
| static const uint8_t | k_adc_diag_vref_prefix [] = "vref: raw=" |
| static const uint8_t | k_adc_diag_crlf [] = "\r\n" |
| static const uint8_t | k_adc_diag_verdict_pass [] = "diag: selftest PASS\r\n" |
| static const uint8_t | k_adc_diag_verdict_fail [] = "diag: selftest FAIL\r\n" |
ADC_B self-diagnosis (modes 1/2/3) + on-die temperature demo.
Exercises the two safety-relevant analog HAL entry points that ra8_emulator cannot model (the SAR self-test and the temperature-sensor path are not emulated), so this app is bench-only:
Bring-up sequence (CGC -> MSTP -> TIME -> peripheral):
Bare EK-RA8D2; no expansion board. Because the tolerance band in ra8_adc_self_diagnose is a gross-fault detector (see the driver's HUM Ch 69 note), the per-mode PASS/FAIL is logged verbatim so a bench operator can read the raw codes even if the verdict trips.
Definition in file main.c.
| enum adc_diag_const_t : uint32_t |
| enum adc_diag_fmt_t : uint8_t |
| enum adc_diag_tsn_t : uint16_t |
|
staticnodiscard |
Initialise the ADC16H and the temperature sensor.
ra8_adc_init powers the converter (14-bit, software trigger); the self-diagnosis + internal-channel paths force their own per-slot data format, so the legacy init is sufficient. ra8_tsn_init routes the sensor to the ADC mux and caches the 125 degC Tj_max trim – the raw calibration words are factory-programmed regardless, and the bench step confirms the trim matches the shipped part (HUM Ch 55.3.1).
| k_ra8_ok | ADC and TSN are ready. |
| Other | Forwarded from ra8_adc_init or ra8_tsn_init. |
Definition at line 330 of file main.c.
References k_adc_diag_stab_us, k_ra8_ok, k_ra8_tsn_cal_temp_high_125, k_ra8_tsn_cal_temp_low_n40, ra8_adc_init(), and ra8_tsn_init().
Referenced by main().
|
static |
Emit one diag: mode=N code=CCCCC PASS|FAIL line.
| [in] | mode_num | Human mode number (1/2/3). |
| [in] | code | Raw 16-bit self-diagnosis result code. |
| [in] | pass | Driver verdict for this mode. |
Definition at line 214 of file main.c.
References adc_diag_write(), adc_diag_write_u32(), k_adc_diag_code_sep, k_adc_diag_fail_sfx, k_adc_diag_mode_prefix, and k_adc_diag_pass_sfx.
Referenced by adc_diag_run_cycle().
|
static |
Park forever after a fatal init error.
Definition at line 105 of file main.c.
Referenced by adc_diag_setup_or_halt(), and main().
|
static |
Run one self-test cycle: 3 self-diagnosis modes + temp + Vref.
Definition at line 239 of file main.c.
References adc_diag_emit_mode(), adc_diag_write(), adc_diag_write_i32(), adc_diag_write_u32(), k_adc_diag_crlf, k_adc_diag_modes, k_adc_diag_num_modes, k_adc_diag_tsn_prefix, k_adc_diag_vref_prefix, k_ra8_adc_chan_int_ref_volt, k_ra8_ok, ra8_adc_read_internal_channel(), ra8_adc_self_diagnose(), and ra8_tsn_read_die_temp_milli_c().
Referenced by main().
|
static |
Core bring-up: CGC -> MSTP -> TIME -> console + LED.
Definition at line 286 of file main.c.
References adc_diag_panic_halt(), k_adc_diag_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().
Referenced by main().
|
static |
Serialise an unsigned 32-bit value into decimal ASCII.
| [out] | buf | Destination, at least k_adc_diag_dec_max bytes. |
| [in] | val | Value to serialise. |
Definition at line 142 of file main.c.
References k_adc_diag_dec_max, and k_adc_diag_radix.
Referenced by adc_diag_write_u32().
|
static |
Write a byte span to the SCI8 console, discarding the status.
| [in] | data | Non-NULL byte span to transmit. |
| [in] | len | Byte count (0 is a no-op). |
Definition at line 123 of file main.c.
References ra8_board_uart_console_write().
Referenced by adc_diag_emit_mode(), adc_diag_run_cycle(), adc_diag_write_i32(), adc_diag_write_u32(), and main().
|
static |
Log one signed 32-bit value (leading minus for negatives).
| [in] | val | Value to print (milli-degC range on this app). |
Definition at line 190 of file main.c.
References adc_diag_write(), adc_diag_write_u32(), and k_adc_diag_minus.
Referenced by adc_diag_run_cycle().
|
static |
Log one unsigned 32-bit value as decimal ASCII.
| [in] | val | Value to print. |
Definition at line 172 of file main.c.
References adc_diag_u32_to_dec(), adc_diag_write(), and k_adc_diag_dec_max.
Referenced by adc_diag_emit_mode(), adc_diag_run_cycle(), and adc_diag_write_i32().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
Definition at line 344 of file main.c.
References adc_diag_arm(), adc_diag_panic_halt(), adc_diag_run_cycle(), adc_diag_setup_or_halt(), adc_diag_write(), k_adc_diag_period_ms, k_adc_diag_verdict_fail, k_adc_diag_verdict_pass, k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
Definition at line 89 of file main.c.
Referenced by adc_diag_emit_mode().
|
static |
Definition at line 94 of file main.c.
Referenced by adc_diag_run_cycle().
|
static |
Definition at line 91 of file main.c.
Referenced by adc_diag_emit_mode().
|
static |
Definition at line 88 of file main.c.
Referenced by adc_diag_emit_mode().
|
static |
Ordered list of self-diagnosis modes to sweep each cycle.
Definition at line 80 of file main.c.
Referenced by adc_diag_run_cycle().
|
static |
Definition at line 90 of file main.c.
Referenced by adc_diag_emit_mode().
|
static |
Definition at line 92 of file main.c.
Referenced by adc_diag_run_cycle().
|
static |
|
static |
|
static |
Definition at line 93 of file main.c.
Referenced by adc_diag_run_cycle().