ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
31
32#include <stdint.h>
33
34#include "ra8_agt.h"
35#include "ra8_attributes.h"
36#include "ra8_board_ek_ra8d2.h"
37#include "ra8_boot_entry.h"
38#include "ra8_cgc.h"
39#include "ra8_err.h"
40#include "ra8_isr.h"
41#include "ra8_time.h"
42
44typedef enum : uint32_t {
48
50typedef enum : uint16_t {
52 /* Reload tuned for the fake -- on real silicon AGT prescaler
53 * setup happens inside ra8_agt_start_free_run. */
56
58typedef enum : uint8_t {
61
63static const uint8_t s_agt_periodic_log_msg[] = "agt: tick OK\r\n";
64
82{
83 while (1) {
84 __asm__ volatile("wfi");
85 }
86}
87
124
152
153void main(void)
154{
157
160 }
161
162 while (1) {
163 uint8_t status = 0U;
164 if (ra8_agt_get_status((uint8_t)k_agt_periodic_channel, &status) != k_ra8_ok) {
165 break;
166 }
167 if ((status & (uint8_t)k_agt_periodic_undf_bit) != 0U) {
169 break;
170 }
172 (size_t)(sizeof(s_agt_periodic_log_msg) - 1U)) != k_ra8_ok) {
173 break;
174 }
175 /* Re-arm: stop + start clears AGTCR.TUNDF on real silicon. */
177 break;
178 }
180 break;
181 }
182 }
184 }
186}
void main(void)
Secure fallback main entry point.
Definition main.c:37
agt_periodic_timer_t
AGT channel + reload (16-bit, ~1 Hz at PCLKB / 8192 div).
Definition main.c:50
@ k_agt_periodic_channel
AGT periodic channel.
Definition main.c:51
@ k_agt_periodic_reload
AGT periodic reload.
Definition main.c:54
static void internal_agt_periodic_panic_halt(void)
Park the processor after an unrecoverable AGT demo failure.
Definition main.c:81
static void internal_agt_periodic_setup_or_halt(void)
Initialize clocks, timing, console, and the AGT status LED.
Definition main.c:105
static const uint8_t s_agt_periodic_log_msg[]
UART diagnostic emitted for every observed AGT underflow.
Definition main.c:63
agt_periodic_status_t
AGTCR underflow status bit (HUM Ch 24, AGTCR.TUNDF).
Definition main.c:58
@ k_agt_periodic_undf_bit
AGT periodic undf bit.
Definition main.c:59
agt_periodic_const_t
Demo tunables.
Definition main.c:44
@ k_agt_periodic_baud
AGT periodic baud.
Definition main.c:45
@ k_agt_periodic_poll_ms
AGT periodic poll ms.
Definition main.c:46
static ra8_err_t internal_agt_periodic_arm(void)
Arm AGT0 in free-running mode.
Definition main.c:148
Asynchronous General-Purpose Timer (AGT) driver header.
ra8_err_t ra8_agt_start_free_run(uint8_t channel, uint16_t reload)
Start an AGT channel in free-running mode.
Definition ra8_agt.c:151
ra8_err_t ra8_agt_get_status(uint8_t channel, uint8_t *out_mask)
Read the AGTCR status register.
Definition ra8_agt.c:289
ra8_err_t ra8_agt_stop(uint8_t channel)
Stop an AGT channel.
Definition ra8_agt.c:177
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
Definition ra8_cgc.h:70
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
Definition ra8_time.c:59
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Definition ra8_time.c:129