|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Sleep-mode wake-count demo for the bare EK-RA8D2. 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_err.h"#include "ra8_isr.h"#include "ra8_lpm.h"#include "ra8_lpm_regs.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | lpm_demo_config_t : uint32_t { k_lpm_demo_baud = 115200U , k_lpm_demo_period_ms = 100U } |
| Compile-time settings. More... | |
| enum | lpm_demo_byte_t : uint8_t { k_lpm_demo_nibble_mask = 0x0FU , k_lpm_demo_nibble_shift = 4U , k_lpm_demo_alpha_thresh = 10U , k_lpm_demo_hex_per_word = 8U } |
| Single-byte constants. More... | |
Functions | |
| static void | internal_lpm_demo_panic_halt (void) |
| Park the processor after a fatal setup or sleep-cycle failure. | |
| static uint8_t | internal_lpm_demo_nibble_to_hex (uint8_t nibble) |
| Convert the low nibble of a byte to an ASCII hex character. | |
| static void | internal_lpm_demo_word_to_hex (uint32_t v, uint8_t *dst) |
| Render a 32-bit value as 8 ASCII hex chars (big-endian). | |
| static void | internal_lpm_demo_setup_or_halt (void) |
| Bring CGC, SysTick, SCI8, LED1, and the LPM block up. | |
| static ra8_err_t | internal_lpm_demo_one_wake (void) |
| Sleep + wake + emit one wake-count line. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_lpm_demo_prefix [] = "lpm: wake_count=" |
| Output line tags. | |
| static const uint8_t | s_lpm_demo_eol [] = "\r\n" |
| static uint32_t | s_wake_count |
| Cumulative wake count incremented after every sleep+wake cycle. | |
Sleep-mode wake-count demo for the bare EK-RA8D2.
Brings up CGC + SysTick + SCI8 + LED1 + the LPM block, then loops:
Sleep mode is the safest LPM mode for a HIL test demo because SysTick keeps running, no external wake source is required, and the JLink debug probe stays attached. Software-Standby / Deep-Standby would require an IRQ pin or RTC alarm wired up, which the bare EVM does not provide without a shield.
Bare EK-RA8D2 only – no shields or external transceivers.
Definition in file main.c.
| enum lpm_demo_byte_t : uint8_t |
| enum lpm_demo_config_t : uint32_t |
|
static |
Convert the low nibble of a byte to an ASCII hex character.
Masks the input to four bits and maps it to a decimal digit or a lowercase hexadecimal letter.
| [in] | nibble | Lower 4 bits used. |
| 0x30..0x39 | Decimal ASCII digit for nibble values zero through nine. |
| 0x61..0x66 | Lowercase ASCII letter for nibble values ten through fifteen. |
Definition at line 105 of file main.c.
References k_lpm_demo_alpha_thresh, k_lpm_demo_nibble_mask, and RA8_INTERNAL.
Referenced by internal_lpm_demo_word_to_hex().
|
staticnodiscard |
Sleep + wake + emit one wake-count line.
Enters normal sleep until SysTick wakes the core, accumulates the configured idle period, increments the counter, and emits fixed-width hex.
| k_ra8_ok | The sleep cycle completed and the count line was emitted. |
| k_ra8_err_hw_error | The low-power entry primitive rejected the request. |
Definition at line 213 of file main.c.
References internal_lpm_demo_word_to_hex(), k_lpm_demo_hex_per_word, k_lpm_demo_period_ms, k_ra8_err_hw_error, k_ra8_ok, k_ra8_sleep_mode_sleep, ra8_board_uart_console_write(), ra8_delay_ms(), RA8_INTERNAL, ra8_lpm_enter_sleep(), s_lpm_demo_eol, s_lpm_demo_prefix, and s_wake_count.
Referenced by main().
|
static |
Park the processor after a fatal setup or sleep-cycle failure.
Executes wait-for-interrupt indefinitely so the demo cannot report wake counts after a prerequisite or low-power transition has failed.
Definition at line 80 of file main.c.
References RA8_INTERNAL.
Referenced by internal_lpm_demo_setup_or_halt(), and main().
|
static |
Bring CGC, SysTick, SCI8, LED1, and the LPM block up.
Initializes each prerequisite in dependency order and transfers to internal_lpm_demo_panic_halt on the first error.
Definition at line 153 of file main.c.
References internal_lpm_demo_panic_halt(), k_lpm_demo_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_lpm_dcssmode_128us, k_ra8_lpm_ss2lp_default, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_lpm_init(), and ra8_time_init().
Referenced by main().
|
static |
Render a 32-bit value as 8 ASCII hex chars (big-endian).
Extracts nibbles from most significant to least significant and writes exactly eight lowercase hexadecimal characters without a terminator.
| [in] | v | Value to render. |
| [out] | dst | 8-byte buffer that receives the hex characters. |
Definition at line 130 of file main.c.
References internal_lpm_demo_nibble_to_hex(), k_lpm_demo_hex_per_word, k_lpm_demo_nibble_mask, k_lpm_demo_nibble_shift, and RA8_INTERNAL.
Referenced by internal_lpm_demo_one_wake().
| 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.
Definition at line 232 of file main.c.
References internal_lpm_demo_one_wake(), internal_lpm_demo_panic_halt(), internal_lpm_demo_setup_or_halt(), k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), and ra8_isr_globals_enable().
|
static |
Definition at line 62 of file main.c.
Referenced by internal_lpm_demo_one_wake().
|
static |
|
static |
Cumulative wake count incremented after every sleep+wake cycle.
Definition at line 65 of file main.c.
Referenced by internal_lpm_demo_one_wake().