63typedef enum : uint32_t {
76typedef enum : uint64_t {
81typedef enum : uint32_t {
89typedef enum : uint8_t {
123 __asm__
volatile(
"wfi");
176 buf[0] = (uint8_t)
'0';
181 tmp[n] = (uint8_t)(
'0' + (uint8_t)(v % (uint64_t)
k_gptp_radix));
185 for (uint32_t i = 0U; i < n; i++) {
186 buf[i] = tmp[n - 1U - i];
272 uint32_t version = 0U;
280 return version != 0U;
308 if (elapsed_ms == 0U) {
311 const uint64_t expected_ns = (uint64_t)elapsed_ms * (uint64_t)
k_gptp_ns_per_ms;
312 const uint64_t band_ns =
314 if (advance_ns > (expected_ns + band_ns)) {
317 return advance_ns >= (expected_ns - band_ns);
358 const uint64_t advance_ns = (ns1 > ns0) ? (ns1 - ns0) : 0ULL;
421 uint32_t cpuclk0_hz = 0U;
467 uint32_t eswclk_hz = 0U;
void main(void)
Secure fallback main entry point.
static const uint8_t k_gptp_sys_prefix[]
static const uint8_t k_gptp_ipv_prefix[]
static void gptp_write(const uint8_t *data, uint32_t len)
Write a byte span to the SCI8 console, discarding the status.
gptp_fmt_t
Formatting and arithmetic constants.
@ k_gptp_dec_u64_max
Max decimal digits for a uint64_t.
@ k_gptp_ns_per_sec
Nanoseconds in one second.
@ k_gptp_ns_per_ms
Nanoseconds in one millisecond.
@ k_gptp_radix
Decimal serialiser radix.
static const uint8_t k_gptp_verdict_fail[]
static bool gptp_probe_presence(void)
Read the IP-version word and require it to be nonzero.
static const uint8_t k_gptp_adv_prefix[]
static const uint8_t k_gptp_time_dot[]
static const uint8_t k_gptp_time_prefix[]
static void gptp_write_u64(uint64_t val)
Log one unsigned 64-bit value as decimal ASCII.
static const uint8_t k_gptp_crlf[]
static const uint8_t k_gptp_verdict_pass[]
static bool gptp_advance_ok(uint64_t advance_ns, uint32_t elapsed_ms)
Decide whether a measured advance matches the SysTick window.
static bool gptp_measure(void)
Sample the counter twice around a SysTick-timed window.
static uint64_t gptp_flatten_ns(uint64_t sec, uint32_t nsec)
Flatten a GPTP sample to nanoseconds.
static void gptp_log_time(uint64_t sec, uint32_t nsec)
Log one gptp: t= line – seconds, a dot, then nanoseconds.
static void gptp_setup_or_halt(void)
Core bring-up: CGC -> ESWCLK -> MSTP -> TIME -> console + LED.
static bool gptp_run_cycle(void)
Run one cycle: presence probe plus one advance measurement.
gptp_const_t
Demo tunables.
@ k_gptp_base_sec
Epoch seconds loaded into the offset.
@ k_gptp_period_ms
Idle time between measurement cycles.
@ k_gptp_window_ms
Measurement window, timed on SysTick.
@ k_gptp_baud
SCI8 console baud.
gptp_flatten_limit_t
Largest seconds value that can be flattened to nanoseconds.
@ k_gptp_sec_flatten_max
floor(2^64 - 1 / 1e9).
static void gptp_panic_halt(void)
Park forever after a fatal init error.
static ra8_err_t gptp_arm(void)
Programme the GPTP timer from the live ESWCLK and start it.
gptp_band_t
Accuracy band the measured advance must fall inside.
@ k_gptp_pct_full
Denominator for the percentage above.
@ k_gptp_tolerance_pct
Allowed drift vs SysTick, in percent.
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_eswclk_hz(uint32_t *out_hz)
Query the current ESWCLK (Ethernet Switch clock) frequency.
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.
ra8_err_t ra8_cgc_eswclk_init(void)
Bring up the Ethernet Switch Module (ESWM / RMAC) clock.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Ethernet Generic PTP Timer (GPTP) driver – HUM Ch 35.
ra8_err_t ra8_eth_gptp_ip_version(uint32_t *out_version)
Read the read-only PTPIPV IP-version word.
ra8_err_t ra8_eth_gptp_timer_enable(ra8_gptp_timer_idx_t timer)
Start one timer unit (PTPTMEC.TEq).
ra8_err_t ra8_eth_gptp_get_time(ra8_gptp_timer_idx_t timer, uint64_t *out_sec, uint32_t *out_nsec)
Read one timer unit's 78-bit GPTP time.
ra8_err_t ra8_eth_gptp_set_offset(ra8_gptp_timer_idx_t timer, uint64_t sec, uint32_t nsec)
Load one timer unit's additive 78-bit offset.
ra8_err_t ra8_eth_gptp_init(const ra8_eth_gptp_cfg_t *cfg)
Power up the GPTP block and programme both timers' increment.
@ k_ra8_gptp_timer_0
Timer unit 0 (registers at +0x0020).
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
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.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
uint32_t ra8_time_ms(void)
Get the current 1 kHz tick count.
Static configuration for ra8_eth_gptp_init.