ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_nsc_comms.h
Go to the documentation of this file.
1
47
48#pragma once
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <stdint.h>
55
56#include "ra8_err.h"
57#include "ra8_i3c.h"
58#include "ra8_nsc_veneer.h"
59#include "ra8_sci.h"
60#include "ra8_spi.h"
61#include "ra8_usb.h"
62
63/* =============================================================================
64 * SCI veneers
65 * =============================================================================
66 */
67
81[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_sci_init(uint8_t channel, const ra8_sci_cfg_t* cfg);
82
92[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_sci_putc(uint8_t channel, uint8_t byte);
93
103[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_sci_getc(uint8_t channel, uint8_t* out_byte);
104
105/* =============================================================================
106 * IIC veneers
107 * =============================================================================
108 */
109
114[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_iic_init(uint8_t channel, const ra8_i3c_cfg_t* cfg);
115
120[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_iic_write(uint8_t channel,
121 uint8_t target_7b,
122 const uint8_t* data,
123 uint32_t len);
124
129[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_iic_read(uint8_t channel,
130 uint8_t target_7b,
131 uint8_t* out_buf,
132 uint32_t len);
133
134/* =============================================================================
135 * SPI veneers
136 * =============================================================================
137 */
138
143[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_spi_init(uint8_t channel, const ra8_spi_cfg_t* cfg);
144
149[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_spi_xfer8(uint8_t channel, uint8_t tx, uint8_t* rx);
150
159[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_spi_write(uint8_t channel,
160 const void* tx,
161 uint32_t len,
162 ra8_spi_bit_width_t bit_width);
163
172[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_spi_read(uint8_t channel,
173 void* rx,
174 uint32_t len,
175 ra8_spi_bit_width_t bit_width);
176
181typedef enum : uint32_t {
185
212static inline uint32_t ra8_nsc_spi_ch_bw(uint8_t channel, ra8_spi_bit_width_t bit_width)
213{
214 return ((uint32_t)channel & (uint32_t)k_ra8_nsc_spi_byte_msk) |
215 ((uint32_t)bit_width << (uint32_t)k_ra8_nsc_spi_bw_shift);
216}
217
230[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_spi_write_read(uint32_t ch_bw,
231 const void* tx,
232 void* rx,
233 uint32_t len);
234
235/* =============================================================================
236 * USB veneers
237 * =============================================================================
238 */
239
245
250[[nodiscard]] RA8_NSC_VENEER ra8_err_t ra8_nsc_usb_attach(ra8_usb_speed_t speed, bool attached);
251
252#ifdef __cplusplus
253}
254#endif
#define RA8_NSC_VENEER
Mark a TrustZone Secure-to-Non-Secure entry-point veneer.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
I3C Bus Interface driver – unified native-I3C + I2C-compat modes.
ra8_err_t ra8_nsc_sci_getc(uint8_t channel, uint8_t *out_byte)
NSC veneer: blocking single-byte SCI read.
ra8_err_t ra8_nsc_iic_init(uint8_t channel, const ra8_i3c_cfg_t *cfg)
NSC veneer: bring up an IIC channel.
ra8_err_t ra8_nsc_spi_write_read(uint32_t ch_bw, const void *tx, void *rx, uint32_t len)
NSC veneer: multi-frame full-duplex polling SPI exchange.
ra8_err_t ra8_nsc_spi_xfer8(uint8_t channel, uint8_t tx, uint8_t *rx)
NSC veneer: full-duplex single-byte SPI exchange.
ra8_err_t ra8_nsc_sci_putc(uint8_t channel, uint8_t byte)
NSC veneer: blocking single-byte SCI write.
ra8_err_t ra8_nsc_iic_write(uint8_t channel, uint8_t target_7b, const uint8_t *data, uint32_t len)
NSC veneer: blocking I2C write to a 7-bit target.
ra8_nsc_spi_pack_const_t
Bit layout for ra8_nsc_spi_ch_bw() packed argument.
@ k_ra8_nsc_spi_bw_shift
Bit position of bit_width.
@ k_ra8_nsc_spi_byte_msk
Byte mask within the packed word.
ra8_err_t ra8_nsc_spi_init(uint8_t channel, const ra8_spi_cfg_t *cfg)
NSC veneer: bring up an SPI controller channel.
ra8_err_t ra8_nsc_spi_write(uint8_t channel, const void *tx, uint32_t len, ra8_spi_bit_width_t bit_width)
NSC veneer: multi-frame TX-only polling SPI write.
ra8_err_t ra8_nsc_spi_read(uint8_t channel, void *rx, uint32_t len, ra8_spi_bit_width_t bit_width)
NSC veneer: multi-frame RX-only polling SPI read.
static uint32_t ra8_nsc_spi_ch_bw(uint8_t channel, ra8_spi_bit_width_t bit_width)
Pack channel + bit_width into a single 32-bit argument.
ra8_err_t ra8_nsc_iic_read(uint8_t channel, uint8_t target_7b, uint8_t *out_buf, uint32_t len)
NSC veneer: blocking I2C read from a 7-bit target.
ra8_err_t ra8_nsc_sci_init(uint8_t channel, const ra8_sci_cfg_t *cfg)
NSC veneer: bring up an SCI channel from NS code.
ra8_err_t ra8_nsc_usb_init(ra8_usb_speed_t speed)
NSC veneer: bring up the USB device controller.
ra8_err_t ra8_nsc_usb_attach(ra8_usb_speed_t speed, bool attached)
NSC veneer: raise / drop USB D+ pull-up.
Macros for declaring Non-Secure Callable veneer functions.
Full-featured Serial Communications Interface driver.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
ra8_spi_bit_width_t
Per-frame bit width for multi-byte transfers.
Definition ra8_spi.h:84
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
Per-channel bring-up configuration for ra8_i3c_init.
Definition ra8_i3c.h:90
Configuration descriptor for ra8_sci_init.
Definition ra8_sci.h:103
Configuration descriptor for ra8_spi_init.
Definition ra8_spi.h:99