68static const char*
s_tag =
"SPI_B_TGT";
100typedef enum : uint32_t {
308 if (reg ==
nullptr) {
347 reg->
SPDR = (uint32_t)tx;
362 const uint8_t received = (uint8_t)reg->
SPDR;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
Bounded wait-flag primitives for RA8D2 HAL drivers.
static ra8_err_t ra8_hw_wait_flag_set32(volatile const uint32_t *reg, uint32_t mask, uint32_t budget)
Spin until (*reg & mask) != 0 or budget runs out.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_mstp_t
Packed (reg << 8) | bit module-stop identifier.
@ k_ra8_mstp_spi0
MSTPB19 SPI0.
@ k_ra8_mstp_spi1
MSTPB18 SPI1.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
@ k_ra8_spi_mode_0
CPOL=0, CPHA=0.
@ k_ra8_spi_mode_3
CPOL=1, CPHA=1.
@ k_ra8_spi_mode_1
CPOL=0, CPHA=1.
@ k_ra8_spi_mode_2
CPOL=1, CPHA=0.
static const ra8_mstp_t s_spi_mstp_table[k_ra8_spi_b_channel_count]
Channel-index -> MSTP id (HUM Ch 11.2.7 "MSTPCRB", p 444).
static uint32_t internal_target_spcr(void)
Build the SPCR value for target (peripheral) mode.
ra8_err_t ra8_spi_b_target_xfer(uint8_t channel, uint8_t tx, uint8_t *rx)
Exchange one byte as the SPI target in a polled blocking call.
ra8_spi_b_target_poll_t
Polling-loop budget for SPSR flag waits in target mode.
@ k_spi_b_target_poll_limit
Max iterations per flag wait.
static void internal_target_program_regs(volatile r_spi_regs_t *reg, const ra8_spi_cfg_t *cfg)
Write all control registers while SPCR.SPE=0.
ra8_err_t ra8_spi_b_target_init(uint8_t channel, const ra8_spi_cfg_t *cfg)
Initialise an SPI_B channel in target (peripheral) mode.
static uint32_t internal_spcmd_target(const ra8_spi_cfg_t *cfg)
Build SPCMD0 value from a caller-supplied configuration.
static ra8_err_t internal_target_wait_spsr(volatile r_spi_regs_t *reg, uint32_t flag_mask)
Wait for a single SPSR flag to assert, with a bounded poll.
SPI_B register layout for the Renesas RA8D2.
@ k_ra8_spcmd_bit_spb_lo
Data Length [20:16] low.
@ k_ra8_spcmd_mask_cpol
RA8 spcmd mask cpol.
@ k_ra8_spcmd_mask_lsbf
RA8 spcmd mask lsbf.
@ k_ra8_spcmd_mask_cpha
RA8 spcmd mask cpha.
@ k_ra8_spcmd_mask_spb
[20:16] data length
@ k_ra8_spcr_mask_spe
RA8 spcr mask spe.
@ k_ra8_spcr_mask_modfen
RA8 spcr mask modfen.
static volatile r_spi_regs_t * ra8_spi(uint8_t channel)
Get pointer to SPI_B channel channel (0..1).
@ k_ra8_spfcr_mask_spfrst
Reset both FIFOs.
@ k_ra8_spsr_mask_sprf
RA8 spsr mask sprf.
@ k_ra8_spsr_mask_sptef
RA8 spsr mask sptef.
@ k_ra8_spi_b_channel_count
SPI0 + SPI1.
@ k_ra8_spcmd_spb_8bit
0b00111 -> 8-bit frame.
@ k_ra8_spsrc_mask_all
Clear every flag at once.
@ k_ra8_spsrc_mask_sprfc
RA8 spsrc mask sprfc.
@ k_ra8_spsrc_mask_sptefc
RA8 spsrc mask sptefc.
SPI_B register-window mirror (matches FSP R_SPI_B0_Type, 0x70 bytes).
volatile uint32_t SPDECR
+0x04 SPI Delay Control Register.
volatile uint32_t SPSRC
+0x68 SPI Status Clear Register.
volatile uint32_t SPDCR2
+0x44 SPI Data Control Register 2.
volatile uint32_t SPCR
+0x08 SPI Control Register 1.
volatile uint32_t SPCR3
+0x10 SPI Control Register 3.
volatile uint32_t SPCMD[8]
+0x14..0x30 Command Registers SPCMD0..7.
volatile uint32_t SPFCR
+0x6C SPI FIFO Clear Register.
volatile uint32_t SPSR
+0x50 SPI Status Register.
volatile uint32_t SPDCR
+0x40 SPI Data Control Register.
volatile uint32_t SPCR2
+0x0C SPI Control Register 2.
volatile uint32_t SPDR
+0x00 SPI Data Register.
Configuration descriptor for ra8_spi_init.
bool lsb_first
True for LSB-first transfers.
ra8_spi_mode_t mode
CPOL / CPHA combination.