|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
GPT0 overflow interrupt -> NVIC -> ISR demo for 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_elc.h"#include "ra8_err.h"#include "ra8_gpt.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | gpt_irq_demo_const_t : uint32_t { k_gpt_irq_demo_period = 0x0000FFFFU , k_gpt_irq_demo_loop_ms = 100U , k_gpt_irq_demo_priority = 3U } |
| Demo tunables. More... | |
| enum | gpt_irq_demo_event_t : uint16_t { k_gpt_irq_demo_channel = 0U , k_gpt_irq_demo_ovf_event = 0x0C1U } |
| GPT channel and its counter-overflow ELC event (FSP ra8d2 0x0C1). More... | |
Functions | |
| static void | internal_gpt_irq_demo_panic_halt (void) |
| Park the processor after an unrecoverable demo failure. | |
| static void | internal_gpt_irq_demo_isr (void *ctx) |
| GPT0 counter-overflow interrupt service routine. | |
| static void | internal_gpt_irq_demo_setup_or_halt (void) |
| Initialize the clocks, timebase, and observable LED fixture. | |
| static ra8_err_t | internal_gpt_irq_demo_arm (void) |
| Link the GPT0 overflow event to the NVIC and arm GPT0. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| volatile uint32_t | g_gpt_irq_count = 0U |
| Count of GPT0 overflow interrupts actually serviced by the ISR. | |
GPT0 overflow interrupt -> NVIC -> ISR demo for EK-RA8D2.
Proves the full real interrupt path – a peripheral event linked through the ICU IELSR table, pended on the NVIC, and taken as a Cortex-M exception that runs an application ISR. Unlike the poll-based timer demos (agt_periodic, gpt_one_shot_demo), this app does NOT poll a status flag: it registers a handler for the GPT0 counter-overflow event with ra8_isr_register (which writes IELSR and enables the NVIC line), starts GPT0 in saw-wave PWM mode, and then sleeps. Every overflow fires internal_gpt_irq_demo_isr in handler mode, which increments g_gpt_irq_count and toggles board LED1. The main loop itself never touches the LED, so any LED transition is proof the real ISR ran.
Sequence:
Definition in file main.c.
| enum gpt_irq_demo_const_t : uint32_t |
| enum gpt_irq_demo_event_t : uint16_t |
|
staticnodiscard |
Link the GPT0 overflow event to the NVIC and arm GPT0.
Definition at line 154 of file main.c.
References internal_gpt_irq_demo_isr(), k_gpt_irq_demo_channel, k_gpt_irq_demo_ovf_event, k_gpt_irq_demo_period, k_gpt_irq_demo_priority, k_ra8_gpt_mode_saw_pwm, k_ra8_gpt_ps_div_1, k_ra8_ok, ra8_gpt_init(), ra8_gpt_start_free_run(), RA8_INTERNAL, ra8_isr_init(), and ra8_isr_register().
Referenced by main().
|
static |
GPT0 counter-overflow interrupt service routine.
Runs in NVIC handler mode, reached via the real path: GPT0 overflow -> IELSR event link -> NVIC pend -> vector 16 + IRQ -> ra8_isr_dispatch -> here. Bumps the liveness counter and toggles LED1 so the effect is observable both on hardware (LED + memprobe) and in the emulator (LED transition + IRQ count).
| [in] | ctx | Unused registration context. |
ctx is the unused registration context supplied by this application. Definition at line 108 of file main.c.
References g_gpt_irq_count, k_ra8_board_led1, ra8_board_led_toggle(), and RA8_INTERNAL.
Referenced by internal_gpt_irq_demo_arm().
|
static |
Park the processor after an unrecoverable demo failure.
Enters a permanent wait-for-interrupt loop so the failing state and liveness counter remain available to a debugger or HIL probe.
Definition at line 81 of file main.c.
References RA8_INTERNAL.
Referenced by internal_gpt_irq_demo_setup_or_halt(), and main().
|
static |
Initialize the clocks, timebase, and observable LED fixture.
Brings dependencies up in order and treats any failure as terminal, leaving interrupt routing disabled until the separate arm step.
Definition at line 126 of file main.c.
References internal_gpt_irq_demo_panic_halt(), k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
Referenced by main().
| 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 183 of file main.c.
References internal_gpt_irq_demo_arm(), internal_gpt_irq_demo_panic_halt(), internal_gpt_irq_demo_setup_or_halt(), k_gpt_irq_demo_loop_ms, k_ra8_ok, ra8_delay_ms(), and ra8_isr_globals_enable().
| volatile uint32_t g_gpt_irq_count = 0U |
Count of GPT0 overflow interrupts actually serviced by the ISR.
Incremented only inside internal_gpt_irq_demo_isr. If the ICU event link, the NVIC enable, or the vector dispatch were broken this would never advance – so a non-zero value is direct evidence the real NVIC interrupt path ran. Read externally by J-Link (HIL) and by tools/ra8_emulator (emulator).
Definition at line 68 of file main.c.
Referenced by internal_gpt_irq_demo_isr().