|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
GPT one-shot (saw-wave one-shot) HIL 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_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_os_demo_const_t : uint32_t { k_gpt_os_demo_period = 0x0000FFFFU , k_gpt_os_demo_rearm_delay_ms = 50U } |
| Demo tunables. More... | |
| enum | gpt_os_demo_chan_t : uint8_t { k_gpt_os_demo_channel = 0U } |
| GPT channel. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Park the core after an unrecoverable demo failure. | |
| static void | internal_setup_or_halt (void) |
| Initialize clocks, the delay service, and LED1. | |
| static ra8_err_t | internal_arm (void) |
| Init GPT0 in one-shot mode. | |
| static bool | internal_wait_ovf (void) |
| Poll GTST.TCFPO for one overflow + clear, bounded. | |
| void | main (void) |
| Repeatedly start and verify GPT0 one-shot intervals. | |
Variables | |
| volatile uint32_t | g_gpt_one_shot_match = 0U |
| HIL liveness counter – bumped on every IRQ-observed one-shot completion. | |
| volatile uint32_t | g_gpt_one_shot_mismatch = 0U |
| HIL failure counter – bumped when arm-or-start returns non-ok inside the loop. | |
GPT one-shot (saw-wave one-shot) HIL demo for EK-RA8D2.
Exercises the GPT in saw-wave one-shot mode (HUM Ch 25.2.1 GTCR.MD = 001b) – the counter counts up from 0 to period once, fires an overflow IRQ, then stops on its own. The demo arms + starts + waits for IRQ + re-arms in a loop so the bench can scrape g_gpt_one_shot_match and confirm each one-shot completes.
Bring-up sequence:
Definition in file main.c.
| enum gpt_os_demo_chan_t : uint8_t |
| enum gpt_os_demo_const_t : uint32_t |
|
staticnodiscard |
Init GPT0 in one-shot mode.
Programs channel zero for a PCLKD/4 saw-wave one-shot with manual start and the fixed demo period; no callback is required because completion is polled through the status register.
| k_ra8_ok | GPT0 accepted the one-shot configuration. |
| (other) | The HAL rejected or could not apply the configuration. |
Definition at line 144 of file main.c.
References k_gpt_os_demo_channel, k_gpt_os_demo_period, k_ra8_gpt_mode_saw_one_shot, k_ra8_gpt_ps_div_4, ra8_gpt_init(), and RA8_INTERNAL.
|
static |
Park the core after an unrecoverable demo failure.
Repeatedly executes WFI so a debugger can inspect the failed GPT or clock state without further peripheral accesses.
Definition at line 89 of file main.c.
References RA8_INTERNAL.
|
static |
Initialize clocks, the delay service, and LED1.
Brings dependencies up in order and parks immediately if any HAL operation fails, leaving GPT configuration to internal_arm.
Definition at line 109 of file main.c.
References internal_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().
|
static |
Poll GTST.TCFPO for one overflow + clear, bounded.
Samples channel-zero status up to the fixed poll budget, clears the overflow flag on first observation, and treats a HAL read failure the same as exhaustion so the caller records a mismatch.
| true | TCFPO set + cleared within budget. |
| false | poll budget elapsed. |
< Poll budget.
Definition at line 176 of file main.c.
References k_gpt_os_demo_channel, k_ra8_gpt_status_overflow, k_ra8_ok, ra8_gpt_clear_status(), ra8_gpt_get_status(), and RA8_INTERNAL.
Referenced by main().
| void main | ( | void | ) |
Repeatedly start and verify GPT0 one-shot intervals.
The application entry point Reset_Handler hands control to.
Initializes and arms GPT0 once, then starts, polls, records the exported pass/failure counters, toggles LED1 on completion, and delays before the next one-shot.
Definition at line 207 of file main.c.
References g_gpt_one_shot_match, g_gpt_one_shot_mismatch, internal_arm(), internal_panic_halt(), internal_setup_or_halt(), internal_wait_ovf(), k_gpt_os_demo_channel, k_gpt_os_demo_period, k_gpt_os_demo_rearm_delay_ms, k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), ra8_gpt_start_free_run(), and ra8_isr_globals_enable().
| volatile uint32_t g_gpt_one_shot_match = 0U |
HIL liveness counter – bumped on every IRQ-observed one-shot completion.
Read externally by hil_jlink_memprobe.sh.
If the GPT clock is gated, GTCR.MD is wrong, or the IRQ is masked, the overflow callback never fires and this counter stops advancing.
Definition at line 61 of file main.c.
Referenced by main().
| volatile uint32_t g_gpt_one_shot_mismatch = 0U |