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
37
38#include <stdint.h>
39
40#include "ra8_attributes.h"
41#include "ra8_board_ek_ra8d2.h"
42#include "ra8_boot_entry.h"
43#include "ra8_cgc.h"
44#include "ra8_err.h"
45#include "ra8_etha.h"
46#include "ra8_isr.h"
47#include "ra8_mstp.h"
48#include "ra8_time.h"
49
51typedef enum : uint32_t {
55
62
64static const uint8_t s_eth_loopback_log_msg[] = "etha: loopback ok\r\n";
65static const uint8_t s_eth_loopback_boot_msg[] = "etha: boot\r\n";
66
84{
85 while (1) {
86 __asm__ volatile("wfi");
87 }
88}
89
108{
109 uint32_t cpuclk0_hz = 0U;
110 if (ra8_cgc_init() != k_ra8_ok) {
112 }
115 }
116 if (ra8_mstp_init() != k_ra8_ok) {
118 }
119 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
121 }
124 }
125}
126
154[[nodiscard]] RA8_INTERNAL static ra8_err_t
156{
157 const ra8_etha_config_t cfg = {
158 .initial_mode = k_ra8_etha_opc_config,
159 .eaeie0_mask = 0U,
160 .eaeie1_mask = 0U,
161 .eaeie2_mask = 0U,
162 };
164 if (err != k_ra8_ok) {
165 return err;
166 }
168 (uint16_t)k_eth_loopback_ring_tx,
169 (uint16_t)k_eth_loopback_ring_rx,
171 if (err != k_ra8_ok) {
172 return err;
173 }
175 if (err != k_ra8_ok) {
176 return err;
177 }
178 for (uint8_t i = 0U; i < (uint8_t)k_eth_loopback_burst_count; i++) {
179 err = ra8_etha_account_traffic(k_ra8_etha_port_0, 1U, 0U, 1U, 0U, 0U);
180 if (err != k_ra8_ok) {
181 return err;
182 }
183 }
185}
186
187void main(void)
188{
191
192 /* Boot banner -- emit before the loopback runs so the HIL host can
193 * confirm the firmware booted even when the ETHA loopback fails for
194 * board-specific reasons (PHY not negotiated, missing pull-ups, etc.). */
196 (size_t)(sizeof(s_eth_loopback_boot_msg) - 1U));
197
198 ra8_etha_port_stats_t stats = {};
201 }
203 (size_t)(sizeof(s_eth_loopback_log_msg) - 1U)) != k_ra8_ok) {
205 }
207
208 while (1) {
209 __asm__ volatile("wfi");
210 }
211}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static const uint8_t s_eth_loopback_boot_msg[]
Definition main.c:65
eth_loopback_const_t
Demo tunables.
Definition main.c:51
@ k_eth_loopback_baud
Ethernet loopback baud.
Definition main.c:52
@ k_eth_loopback_burst_count
Ethernet loopback burst count.
Definition main.c:53
static ra8_err_t internal_eth_loopback_run_once(ra8_etha_port_stats_t *out)
Bring port 0 through the ETHA loopback bring-up sequence.
Definition main.c:155
static const uint8_t s_eth_loopback_log_msg[]
Fixed UART diagnostics for boot and successful ETHA loopback.
Definition main.c:64
eth_loopback_ring_t
Descriptor-ring sizing.
Definition main.c:57
@ k_eth_loopback_buffer_size
Ethernet loopback buffer size.
Definition main.c:60
@ k_eth_loopback_ring_rx
Ethernet loopback ring RX.
Definition main.c:59
@ k_eth_loopback_ring_tx
Ethernet loopback ring TX.
Definition main.c:58
static void internal_eth_loopback_setup_or_halt(void)
Initialize clocks, module-stop control, timekeeping, and console.
Definition main.c:107
static void internal_eth_loopback_panic_halt(void)
Park the processor after an unrecoverable ETHA demo failure.
Definition main.c:83
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_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
Per-port Ethernet Agent (ETHA) driver – HUM Ch 32 (p 1627-1702).
ra8_err_t ra8_etha_deinit(ra8_etha_port_t port)
Tear down an ETHA port (drop into RESET, mask all IRQs).
Definition ra8_etha.c:203
ra8_err_t ra8_etha_set_mode(ra8_etha_port_t port, ra8_etha_opc_t mode)
Issue an explicit EAMC mode-change command.
Definition ra8_etha.c:494
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).
Definition ra8_etha.c:167
@ k_ra8_etha_port_0
ETHA port 0 (base 0x403C_A000).
@ k_ra8_etha_opc_operation
Enter OPERATION mode.
@ k_ra8_etha_opc_config
Enter CONFIG mode.
ra8_err_t ra8_etha_account_traffic(ra8_etha_port_t channel, uint32_t tx_ok, uint32_t tx_err, uint32_t rx_ok, uint32_t rx_err, uint32_t rx_drop)
Increment the per-port TX OK / TX err / RX OK / RX err / drop counters.
ra8_err_t ra8_etha_descriptor_ring_init(ra8_etha_port_t channel, uint16_t num_tx, uint16_t num_rx, uint16_t buffer_size)
Configure the per-port descriptor-ring sizing.
ra8_err_t ra8_etha_get_stats(ra8_etha_port_t channel, ra8_etha_port_stats_t *out_stats)
Snapshot the per-port software-maintained traffic counters.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Definition ra8_isr.c:439
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.
Definition ra8_mstp.c:291
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
Per-port ETHA configuration knobs.
Per-port runtime traffic counters maintained by ra8_etha.