ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_nsc_periph_init.c
Go to the documentation of this file.
1
19
20#include <stdint.h>
21
22#include "ra8_attributes.h"
23#include "ra8_dma.h"
24#include "ra8_err.h"
25#include "ra8_isr.h"
26#include "ra8_log.h"
27#include "ra8_mstp.h"
28#include "ra8_nsc.h"
29#include "ra8_nsc_veneer.h"
30#include "ra8_pwr.h"
31
32#ifdef RA8_APP_UART_LOG
33/* The e-reader product defines RA8_APP_UART_LOG to mirror ra8_log onto the SCI8
34 * J-Link console, so the logs appear on the UART (ra8_emulator's on-screen console
35 * + a real serial terminal) and not only on the ITM/SWO trace. Gated so other
36 * ra8_nsc consumers do not pick up a ra8_board dependency. */
37#include "ra8_board_ek_ra8d2.h"
38#endif
39
40static const char* s_tag = "NSCPRH";
41
42static bool s_initialized = false;
43
44#ifdef RA8_APP_UART_LOG
50typedef enum : uint32_t {
51 k_ra8_nsc_uart_log_baud = 115200U,
52} ra8_nsc_uart_log_cfg_t;
53
75static void internal_uart_log_sink(void* ctx, uint8_t byte)
76{
77 (void)ctx;
78 (void)ra8_board_uart_console_write(&byte, 1U);
79}
80#endif
81
113{
114 if (s_initialized) {
115 return k_ra8_ok;
116 }
117
118 ra8_err_t err = ra8_mstp_init();
119 if (err != k_ra8_ok) {
120 ra8_log_error_val(s_tag, "ra8_mstp_init", (uint32_t)err);
122 }
123
124 err = ra8_pwr_init();
125 if (err != k_ra8_ok) {
126 ra8_log_error_val(s_tag, "ra8_pwr_init", (uint32_t)err);
128 }
129
130 err = ra8_isr_init();
131 if (err != k_ra8_ok) {
132 ra8_log_error_val(s_tag, "ra8_isr_init", (uint32_t)err);
134 }
135
136 err = ra8_dma_init();
137 if (err != k_ra8_ok) {
138 ra8_log_error_val(s_tag, "ra8_dma_init", (uint32_t)err);
140 }
141
142#ifdef RA8_APP_UART_LOG
143 /* Bring up the SCI8 console and redirect ra8_log to it so the logs land on the
144 * UART (ra8_emulator console + serial), not only ITM. ra8_cgc_init already ran in
145 * SystemInit. Best-effort: a console bring-up failure must not fail the
146 * substrate, so its result is dropped and ra8_log keeps its ITM default. */
147 if (ra8_board_uart_console_init((uint32_t)k_ra8_nsc_uart_log_baud) == k_ra8_ok) {
148 ra8_log_set_byte_sink(internal_uart_log_sink, nullptr);
149 }
150#endif
151
152 s_initialized = true;
153 ra8_log_info(s_tag, "secure substrate up");
154 return k_ra8_ok;
155}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_NSC_VENEER
Mark a TrustZone Secure-to-Non-Secure entry-point veneer.
#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.
static bool s_initialized
True once display_init has succeeded.
Generic DMA transfer substrate (DMAC engine).
ra8_err_t ra8_dma_init(void)
Initialise the DMA substrate.
Definition ra8_dma.c:215
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
Definition ra8_err.h:290
@ 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.
ra8_err_t ra8_isr_init(void)
Initialise the ra8_isr table.
Definition ra8_isr.c:229
Lightweight Logging Interface for ra8-firmware.
void ra8_log_set_byte_sink(ra8_log_byte_sink_fn_t fn, void *ctx)
Install (or clear) an optional byte sink for log output.
Definition ra8_log.c:56
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
Definition ra8_log.h:337
#define ra8_log_info(tag, message)
RA8 log info.
Definition ra8_log.h:364
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
Non-Secure Callable veneers – the only NS->S gateway.
ra8_err_t ra8_nsc_periph_init(void)
NSC veneer: bring up the secure-side peripheral substrate.
Macros for declaring Non-Secure Callable veneer functions.
Low Power Mode + clock-domain wrapper.
ra8_err_t ra8_pwr_init(void)
Initialise the LPM substrate.
Definition ra8_pwr.c:141