83typedef enum : uint32_t {
93typedef enum : uint8_t {
101typedef enum : uint32_t {
113typedef enum : uint64_t {
118typedef enum : uint8_t {
126typedef enum : uint8_t {
152 __asm__
volatile(
"wfi");
189 buf[0] = (uint8_t)
'0';
196 tmp[n] = (uint8_t)(
'0' + (uint8_t)(v % (uint32_t)
k_tsn_radix));
200 for (uint32_t i = 0U; i < n; i++) {
201 buf[i] = tmp[n - 1U - i];
248 buf[0] = (uint8_t)
'0';
253 tmp[n] = (uint8_t)(
'0' + (uint8_t)(v % (uint64_t)
k_tsn_radix));
257 for (uint32_t i = 0U; i < n; i++) {
258 buf[i] = tmp[n - 1U - i];
334 const uint64_t advance_ns = (ns1 > ns0) ? (ns1 - ns0) : 0ULL;
335 const uint64_t expected_ns = (uint64_t)elapsed_ms * (uint64_t)
k_tsn_ns_per_ms;
344 if (elapsed_ms == 0U) {
347 if (advance_ns > (expected_ns + band_ns)) {
350 if (advance_ns < (expected_ns - band_ns)) {
475 uint8_t enabled = 0U;
476 uint8_t gate_open = 0U;
557 uint32_t cpuclk0_hz = 0U;
603 uint32_t eswclk_hz = 0U;
void main(void)
Secure fallback main entry point.
static uint64_t tsn_flatten_ns(uint64_t sec, uint32_t nsec)
Flatten a GPTP sample to nanoseconds.
static void tsn_write_u64(uint64_t val)
Log one unsigned 64-bit value as decimal ASCII.
static bool tsn_log_status(void)
Read + log the ETHA port-0 status (TAS cycle-time monitor).
static void tsn_panic_halt(void)
Park forever after a fatal init error.
static void tsn_write(const uint8_t *data, uint32_t len)
Write a byte span to the SCI8 console, discarding the status.
tsn_gate_t
EATASIGSC initial gate-state bitmap: bit q is queue q's gate.
@ k_tsn_gate_ptp_only
Only queue 7 (PTP / control) starts open.
static void tsn_setup_or_halt(void)
Core bring-up: CGC -> MSTP -> TIME -> console + LED.
static const uint8_t k_tsn_verdict_fail[]
static bool tsn_program_tas(void)
Program + arm the 802.1Qbv time-aware shaper on port 0.
tsn_band_t
Accuracy band the gPTP advance must fall inside.
@ k_tsn_pct_full
Denominator for the percentage above.
@ k_tsn_tolerance_pct
Allowed drift vs SysTick, in percent.
static const uint8_t k_tsn_crlf[]
static const uint8_t k_tsn_verdict_pass[]
static bool tsn_program_cbs(void)
Configure the 802.1Qav credit-based shaper on traffic class 2.
tsn_fmt_t
Formatting + iteration constants.
@ k_tsn_gate_entries
Gate-control-list entry count.
@ k_tsn_dec_u32_max
Max decimal digits for a uint32_t.
@ k_tsn_radix
Decimal serialiser radix.
@ k_tsn_dec_u64_max
Max decimal digits for a uint64_t.
static const uint8_t k_tsn_base_sep[]
static ra8_err_t tsn_arm(void)
Bring up the gPTP time base and ETHA port 0 in CONFIG mode.
static void tsn_write_u32(uint32_t val)
Log one unsigned 32-bit value as decimal ASCII.
static ra8_err_t tsn_arm_time_base(void)
Start the gPTP time base the TAS scheduler references.
static bool tsn_run_cycle(void)
Run one cycle: check the time base, program TAS + CBS, read status.
static const uint8_t k_tsn_cbs_gate_sep[]
static uint32_t tsn_u32_to_dec(uint8_t *buf, uint32_t val)
Serialise an unsigned 32-bit value into decimal ASCII.
static const uint8_t k_tsn_base_prefix[]
static bool tsn_tas_entry_matches(uint8_t index, const ra8_etha_tas_entry_t *want)
Read one TAS RAM entry back and compare it with what was programmed.
static const uint8_t k_tsn_cyc_prefix[]
tsn_const_t
Demo tunables (illustrative shaper values).
@ k_tsn_baud
SCI8 console baud.
@ k_tsn_win_units
Per-window gate time, nanoseconds.
@ k_tsn_period_ms
Delay between cycles.
@ k_tsn_cbs_increment
CBS credit increment (20-bit field).
@ k_tsn_cbs_upper_lim
CBS upper credit limit (31-bit field).
@ k_tsn_cycle_units
Full GCL cycle = 2 windows, ns.
static bool tsn_check_time_base(void)
Verify the gPTP time base the TAS scheduler references is running.
static const uint8_t k_tsn_cbs_prefix[]
tsn_flatten_limit_t
Largest seconds value that can be flattened to nanoseconds.
@ k_tsn_sec_flatten_max
floor(2^64 - 1 / 1e9).
tsn_gptp_const_t
gPTP time-base check parameters.
@ k_tsn_ns_per_ms
Nanoseconds in one millisecond.
@ k_tsn_gptp_window_ms
SysTick-timed measurement window.
@ k_tsn_ns_per_sec
Nanoseconds in one second.
static const uint8_t k_tsn_tas_prefix[]
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_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_init(const ra8_eth_gptp_cfg_t *cfg)
Power up the GPTP block and programme both timers' increment.
Per-port Ethernet Agent (ETHA) driver – HUM Ch 32 (p 1627-1702).
ra8_err_t ra8_etha_get_status(ra8_etha_port_t port, ra8_etha_status_t *out)
Read a port's status snapshot (mode + 3x error IRQ status + TAS).
ra8_err_t ra8_etha_init(ra8_etha_port_t port, const ra8_etha_config_t *cfg)
Initialise an ETHA port (MSTP gate + reset registers + initial mode).
@ k_ra8_etha_port_0
ETHA port 0 (base 0x403C_A000).
@ k_ra8_etha_tc_7
Highest priority / control / PTP.
@ k_ra8_etha_tc_count
Number of traffic classes per port.
@ k_ra8_etha_tc_2
AVB class A.
@ k_ra8_etha_opc_config
Enter CONFIG mode.
ra8_err_t ra8_etha_enable_tas(ra8_etha_port_t port, uint8_t enable)
Enable or disable the TAS scheduler (main switch).
ra8_err_t ra8_etha_tas_ram_reset(ra8_etha_port_t port)
Reset the TAS RAM and wait for it to report ready.
ra8_err_t ra8_etha_configure_cbs(ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t enable, const ra8_etha_cbs_param_t *param)
Configure the credit-based shaper (CBS) for one traffic class.
ra8_err_t ra8_etha_get_cbs_state(ra8_etha_port_t port, ra8_etha_tc_t tc, uint8_t *enabled, uint8_t *gate_open, ra8_etha_cbs_param_t *oper_param)
Read the operational CBS gate-state vector + per-class oper params.
ra8_err_t ra8_etha_set_tas_schedule(ra8_etha_port_t port, const ra8_etha_tas_queue_t *queues, uint8_t initial_gate_states, uint32_t cycle_time_ns, uint64_t start_time)
Programme the time-aware shaper (TAS / 802.1Qbv) gate lists.
ra8_err_t ra8_etha_read_tas_entry(ra8_etha_port_t port, uint8_t address, ra8_etha_tas_entry_t *out)
Read one TAS RAM entry back out of hardware.
@ 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.
Credit-based shaper parameters per traffic class.
Per-port ETHA configuration knobs.
Snapshot of an ETHA port's runtime state.
uint32_t tas_cycle
EATASCTM TAS cycle-time monitor.
One TAS (802.1Qbv) RAM entry, exactly as HUM Table 32.6 defines it.
bool gate_open
TAS.GS – true opens this queue's gate.
uint32_t gate_time_ns
TAS.GT – entry duration in ns, 28 bits.
The gate-control list of one descriptor queue.
const ra8_etha_tas_entry_t * entries
Gate list, or nullptr when count is 0.
uint16_t count
Entries for this queue (EATASENCi).