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
54
55#include <stdint.h>
56
57#include "c6_hosted.h"
58#include "ra8_board_ek_ra8d2.h"
59#include "ra8_boot_entry.h"
60#include "ra8_cgc.h"
61#include "ra8_err.h"
62#include "ra8_esp_hosted_port.h"
63#include "ra8_isr.h"
64#include "ra8_mstp.h"
65#include "ra8_time.h"
66#include "tx_api.h"
67
76static uint32_t s_c6_hosted_cpuclk_hz;
77
88static uint32_t s_c6_hosted_pclka_hz;
89
101
112
123static CHAR s_c6_hosted_worker_name[] = "c6_hosted_init";
124
135
146static void c6_hosted_panic_halt(void)
147{
148 while (1) {
149 __asm__ volatile("wfi");
150 }
151}
152
187
200static void c6_hosted_heartbeat(void)
201{
202 uint32_t beat = 0U;
203 while (1) {
204 c6_hosted_puts("c6_hosted_init: heartbeat n=");
205 c6_hosted_put_u32(beat);
206 c6_hosted_puts(" events=");
208 c6_hosted_puts("\r\n");
211 } else {
212 c6_hosted_puts("c6_hosted_init: port down -- side-band cannot be read\r\n");
213 }
214 beat++;
216 }
217}
218
233static void c6_hosted_worker_entry(ULONG thread_input)
234{
235 (void)thread_input;
236
237 c6_hosted_puts("c6_hosted_init: port_init=");
239 c6_hosted_puts("\r\n");
240
242 c6_hosted_puts("c6_hosted_init: FAIL port init failed -- no transaction attempted\r\n");
244 return;
245 }
246
250 ra8_esp_hosted_mem_dump("c6_hosted_init");
252}
253
268void tx_application_define(void* first_unused_memory)
269{
270 (void)first_unused_memory;
271
273 c6_hosted_puts("c6_hosted_init: event handler registration refused\r\n");
274 }
275
276 const ra8_esp_hosted_port_cfg_t cfg = {
277 .pclk_hz = s_c6_hosted_pclka_hz,
278 .sck_hz = (uint32_t)k_c6_hosted_sck_hz,
279 .edge_poll_ms = (uint16_t)k_c6_hosted_edge_poll_ms,
280 .sci_channel = (uint8_t)k_ra8_board_pmod1_sci_channel,
281 };
283
287 0U,
294 c6_hosted_puts("c6_hosted_init: worker thread creation failed\r\n");
295 }
296}
297
308void main(void)
309{
312
315 c6_hosted_puts("c6_hosted_init: entering ThreadX; port init runs from "
316 "tx_application_define\r\n");
317
318 tx_kernel_enter();
319
321}
void main(void)
Secure fallback main entry point.
Definition main.c:37
Shared contract for the esp-hosted port bring-up application.
void c6_hosted_print_banner(uint32_t cpuclk_hz, uint32_t pclka_hz)
Print the port identity, the clocks and the SPI parameters.
void c6_hosted_report_sideband(void)
Sample both side-band lines through the vtable and report them.
void c6_hosted_run_transaction(void)
Clock one full-duplex transaction and report the verdict.
uint32_t c6_hosted_event_count(void)
Report how many events c6_hosted_on_event has seen.
void c6_hosted_puts(const char *text)
Write a NUL-terminated string to the board console.
void c6_hosted_put_u32(uint32_t value)
Emit an unsigned 32-bit value in decimal.
void c6_hosted_print_pin_map(void)
Print the resolved pin map, bus pins and side-band alike.
@ k_c6_hosted_worker_stack
Worker-thread stack, in bytes.
Definition c6_hosted.h:68
@ k_c6_hosted_worker_prio
Worker priority and preemption threshold.
Definition c6_hosted.h:69
@ k_c6_hosted_sck_hz
SPI bit rate: the 5 MHz upstream recommends for first light, an order above the probe's 1 MHz.
Definition c6_hosted.h:61
@ k_c6_hosted_uart_baud
Console rate, 8N1, over the J-Link OB VCOM.
Definition c6_hosted.h:60
@ k_c6_hosted_edge_poll_ms
Poll period for a side-band pin with no ICU channel.
Definition c6_hosted.h:63
@ k_c6_hosted_boot_wait_ms
Settling delay before the first vtable read.
Definition c6_hosted.h:66
@ k_c6_hosted_heartbeat_ms
Heartbeat gap; the ThreadX tick is 1 ms, so this is also the sleep expressed in ticks.
Definition c6_hosted.h:64
void c6_hosted_on_event(void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len)
Report an event the port delivered from the vendored core.
void tx_application_define(void *first_unused_memory)
ThreadX system-define hook: build worker thread + byte pool.
Definition main.c:942
static ra8_err_t s_c6_hosted_init_err
Exact result of ra8_esp_hosted_port_init.
Definition main.c:100
static void c6_hosted_setup_or_halt(void)
Bring clocks, module-stop state, SysTick and the console up.
Definition main.c:166
static void c6_hosted_panic_halt(void)
Park the CPU forever after an unrecoverable bring-up failure.
Definition main.c:146
static uint32_t s_c6_hosted_cpuclk_hz
Cached CPUCLK0 rate, used to programme SysTick.
Definition main.c:76
static CHAR s_c6_hosted_worker_name[]
Thread name handed to ThreadX.
Definition main.c:123
static UCHAR s_c6_hosted_worker_stack[k_c6_hosted_worker_stack]
Stack backing s_c6_hosted_worker.
Definition main.c:134
static void c6_hosted_heartbeat(void)
Print heartbeat lines forever, never returning.
Definition main.c:200
static void c6_hosted_worker_entry(ULONG thread_input)
Worker thread: report the init, exercise the link, then heartbeat.
Definition main.c:233
static uint32_t s_c6_hosted_pclka_hz
Cached PCLKA rate, the SCI baud-clock source the port divides.
Definition main.c:88
static TX_THREAD s_c6_hosted_worker
Control block of the single application thread.
Definition main.c:111
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_pmod1_sci_channel
Pmod1 (J26) Simple-SPI is SCI2.
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
@ k_ra8_clock_id_pclka
PCLKA.
Definition ra8_cgc.h:73
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_err_not_initialized
Module not initialized – _init() not yet called successfully.
Definition ra8_err.h:235
@ 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
const char * ra8_err_to_str(ra8_err_t err)
Human-readable string for an error code.
Definition ra8_log.c:737
Public entry point of the RA8D2 + ThreadX port of esp-hosted.
bool ra8_esp_hosted_port_is_ready(void)
Report whether the port is currently initialised.
struct ra8_esp_hosted_port_cfg ra8_esp_hosted_port_cfg_t
ra8_err_t ra8_esp_hosted_port_set_event_cb(ra8_esp_hosted_event_cb_t cb, void *ctx)
Register the handler the port calls when the core posts an event.
ra8_err_t ra8_esp_hosted_port_init(const ra8_esp_hosted_port_cfg_t *cfg)
Bring the esp-hosted port up and publish the OS-abstraction vtable.
void ra8_esp_hosted_mem_dump(const char *label)
Report transport pool occupancy at a named point.
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
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Definition ra8_time.c:129
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
#define TX_SUCCESS
#define tx_thread_create
#define tx_thread_sleep
#define TX_NO_TIME_SLICE
char CHAR
ThreadX-compatible CHAR (host stub).
#define TX_AUTO_START
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.