ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_spi_regs.h
Go to the documentation of this file.
1
49
50#pragma once
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56#include <stdint.h>
57
58#include "ra8_attributes.h"
59
64typedef enum : uintptr_t {
65 k_ra8_spi0_base_addr = 0x4035C000UL,
66 k_ra8_spi1_base_addr = 0x4035C100UL,
68
79
91typedef struct {
92 volatile uint32_t SPDR;
93 volatile uint32_t SPDECR;
94 volatile uint32_t SPCR;
95 volatile uint32_t SPCR2;
96 volatile uint32_t SPCR3;
97 volatile uint32_t SPCMD[8];
98 volatile uint32_t _reserved0[3];
99 volatile uint32_t SPDCR;
100 volatile uint32_t SPDCR2;
101 volatile uint32_t _reserved1[2];
102 volatile uint32_t SPSR;
103 volatile uint32_t _reserved2;
104 volatile uint32_t SPTFSR;
105 volatile uint32_t SPRFSR;
106 volatile uint32_t SPPSR;
107 volatile uint32_t _reserved3;
108 volatile uint32_t SPSRC;
109 volatile uint32_t SPFCR;
111
137
142typedef enum : uint32_t {
143 k_ra8_spcr_mask_spe = 0x00000001UL,
144 k_ra8_spcr_mask_modfen = 0x00004000UL,
145 k_ra8_spcr_mask_speie = 0x00010000UL,
146 k_ra8_spcr_mask_sprie = 0x00020000UL,
147 k_ra8_spcr_mask_sptie = 0x00100000UL,
148 k_ra8_spcr_mask_cendie = 0x00200000UL,
149 k_ra8_spcr_mask_sckase = 0x00001000UL,
150 k_ra8_spcr_mask_mstr = 0x40000000UL,
151 k_ra8_spcr_mask_txmd = 0x30000000UL,
153
169
174typedef enum : uint32_t {
175 k_ra8_spsr_mask_spdrf = 0x00800000UL,
176 k_ra8_spsr_mask_ovrf = 0x01000000UL,
177 k_ra8_spsr_mask_idlnf = 0x02000000UL,
178 k_ra8_spsr_mask_modf = 0x04000000UL,
179 k_ra8_spsr_mask_perf = 0x08000000UL,
180 k_ra8_spsr_mask_udrf = 0x10000000UL,
181 k_ra8_spsr_mask_sptef = 0x20000000UL,
182 k_ra8_spsr_mask_cendf = 0x40000000UL,
183 k_ra8_spsr_mask_sprf = 0x80000000UL,
184 k_ra8_spsr_mask_errs = 0x1D000000UL,
186
191typedef enum : uint32_t {
192 k_ra8_spsrc_mask_spdrfc = 0x00800000UL,
193 k_ra8_spsrc_mask_ovrfc = 0x01000000UL,
194 k_ra8_spsrc_mask_modfc = 0x04000000UL,
195 k_ra8_spsrc_mask_perfc = 0x08000000UL,
196 k_ra8_spsrc_mask_udrfc = 0x10000000UL,
197 k_ra8_spsrc_mask_sptefc = 0x20000000UL,
198 k_ra8_spsrc_mask_cendfc = 0x40000000UL,
199 k_ra8_spsrc_mask_sprfc = 0x80000000UL,
200 k_ra8_spsrc_mask_all = 0xFD800000UL,
202
219
224typedef enum : uint32_t {
225 k_ra8_spcmd_mask_cpha = 0x00000001UL,
226 k_ra8_spcmd_mask_cpol = 0x00000002UL,
227 k_ra8_spcmd_mask_brdv = 0x0000000CUL,
228 k_ra8_spcmd_mask_sslkp = 0x00000080UL,
229 k_ra8_spcmd_mask_lsbf = 0x00001000UL,
230 k_ra8_spcmd_mask_spnden = 0x00002000UL,
231 k_ra8_spcmd_mask_slnden = 0x00004000UL,
232 k_ra8_spcmd_mask_sckden = 0x00008000UL,
233 k_ra8_spcmd_mask_spb = 0x001F0000UL,
234 k_ra8_spcmd_mask_ssla = 0x07000000UL,
236
248typedef enum : uint8_t {
253
266
271typedef enum : uint32_t {
273 k_ra8_spcr3_mask_spbr = 0x0000FF00UL,
274 k_ra8_spcr3_mask_spsln = 0x07000000UL,
276
281typedef enum : uint8_t {
284
289typedef enum : uint32_t {
290 k_ra8_spfcr_mask_spfrst = 0x00000001UL,
292
297typedef enum : uint32_t {
298 k_ra8_spcr2_mask_splp = 0x00010000UL,
299 k_ra8_spcr2_mask_splp2 = 0x00020000UL,
300 k_ra8_spcr2_mask_moife = 0x00200000UL,
301 k_ra8_spcr2_mask_moifv = 0x00100000UL,
303
308typedef enum : uint32_t {
309 k_ra8_sppsr_mask_speps = 0x00000001UL,
311
321typedef enum : uint8_t {
324
341static inline volatile r_spi_regs_t* ra8_spi(uint8_t channel)
342{
343 if ((uint16_t)channel >= k_ra8_spi_primary_count) {
344 return nullptr;
345 }
346 return (volatile r_spi_regs_t*)(k_ra8_spi0_base_addr +
347 ((uintptr_t)channel * (uintptr_t)k_ra8_spi_channel_stride));
348}
349
350#ifdef __cplusplus
351}
352#endif
Annotation-attribute framework macros for ra8-firmware.
#define RA8_HW_REGISTER_ACCESS
Mark an MMIO accessor function (returns volatile register pointer).
ra8_spcmd_bit_t
SPCMDn (command register) bit positions.
@ k_ra8_spcmd_bit_sslkp
SSL Signal Level Hold.
@ k_ra8_spcmd_bit_spb_lo
Data Length [20:16] low.
@ k_ra8_spcmd_bit_brdv0
Bit-Rate Division bit 0.
@ k_ra8_spcmd_bit_lsbf
LSB-first.
@ k_ra8_spcmd_bit_cpha
Clock Phase.
@ k_ra8_spcmd_bit_brdv1
Bit-Rate Division bit 1.
@ k_ra8_spcmd_bit_cpol
Clock Polarity.
@ k_ra8_spcmd_bit_slnden
SSL Negation Delay Enable.
@ k_ra8_spcmd_bit_spnden
Next-Access Delay Enable.
@ k_ra8_spcmd_bit_sckden
SCK Delay Enable.
ra8_spcr3_bit_t
SPCR3 bit positions (SSLnP polarity, SPBR, SPSLN).
@ k_ra8_spcr3_bit_spsln
SPSLN field [26:24] – sequence length.
@ k_ra8_spcr3_bit_ssl0p
SSL0 polarity (0=active low).
@ k_ra8_spcr3_bit_ssl2p
SSL2 polarity.
@ k_ra8_spcr3_bit_ssl1p
SSL1 polarity.
@ k_ra8_spcr3_bit_ssl3p
SSL3 polarity.
@ k_ra8_spcr3_bit_spbr
SPBR field [15:8] – bit-rate divider.
ra8_spsr_bit_t
SPSR (status register) bit positions.
@ k_ra8_spsr_bit_modf
Mode Fault Error Flag.
@ k_ra8_spsr_bit_ovrf
Overrun Error Flag.
@ k_ra8_spsr_bit_sptef
TX Buffer Empty Flag.
@ k_ra8_spsr_bit_udrf
Underrun Error Flag.
@ k_ra8_spsr_bit_sprf
RX Buffer Full Flag.
@ k_ra8_spsr_bit_perf
Parity Error Flag.
@ k_ra8_spsr_bit_spdrf
Receive Data Ready Flag.
@ k_ra8_spsr_bit_idlnf
Idle Flag.
@ k_ra8_spsr_bit_cendf
Communication End Flag.
ra8_spcmd_mask_t
SPCMDn bit-masks (HUM Ch 43.2.7 p 2893).
@ k_ra8_spcmd_mask_slnden
RA8 spcmd mask slnden.
@ k_ra8_spcmd_mask_sckden
RA8 spcmd mask sckden.
@ k_ra8_spcmd_mask_cpol
RA8 spcmd mask cpol.
@ k_ra8_spcmd_mask_lsbf
RA8 spcmd mask lsbf.
@ k_ra8_spcmd_mask_ssla
[26:24] SSL select
@ k_ra8_spcmd_mask_spnden
RA8 spcmd mask spnden.
@ k_ra8_spcmd_mask_cpha
RA8 spcmd mask cpha.
@ k_ra8_spcmd_mask_spb
[20:16] data length
@ k_ra8_spcmd_mask_brdv
[3:2]
@ k_ra8_spcmd_mask_sslkp
RA8 spcmd mask sslkp.
ra8_spcr_mask_t
SPCR bit-masks.
@ k_ra8_spcr_mask_mstr
RA8 spcr mask mstr.
@ k_ra8_spcr_mask_spe
RA8 spcr mask spe.
@ k_ra8_spcr_mask_speie
RA8 spcr mask speie.
@ k_ra8_spcr_mask_sckase
RA8 spcr mask sckase.
@ k_ra8_spcr_mask_sprie
RA8 spcr mask sprie.
@ k_ra8_spcr_mask_cendie
RA8 spcr mask cendie.
@ k_ra8_spcr_mask_txmd
[29:28] communication mode.
@ k_ra8_spcr_mask_modfen
RA8 spcr mask modfen.
@ k_ra8_spcr_mask_sptie
RA8 spcr mask sptie.
static volatile r_spi_regs_t * ra8_spi(uint8_t channel)
Get pointer to SPI_B channel channel (0..1).
ra8_sppsr_mask_t
SPPSR (polling status) masks.
@ k_ra8_sppsr_mask_speps
Asserted while SPI is busy.
ra8_spfcr_mask_t
SPFCR (FIFO clear) masks.
@ k_ra8_spfcr_mask_spfrst
Reset both FIFOs.
ra8_spcr2_mask_t
SPCR2 (control 2) masks.
@ k_ra8_spcr2_mask_splp2
Non-inverting loopback (rx = tx).
@ k_ra8_spcr2_mask_splp
Inverting loopback (rx = ~tx).
@ k_ra8_spcr2_mask_moife
COPI Idle Fixed Value Enable.
@ k_ra8_spcr2_mask_moifv
COPI Idle Fixed Value.
ra8_spi_addr_t
SPI_B register-window base addresses (FSP R_SPI_B0_BASE / R_SPI_B1_BASE).
@ k_ra8_spi1_base_addr
HUM Ch 43, SPI1 base.
@ k_ra8_spi0_base_addr
HUM Ch 43, SPI0 base.
ra8_spcr3_mask_t
SPCR3 masks.
@ k_ra8_spcr3_mask_spbr
[15:8] bit-rate divider.
@ k_ra8_spcr3_mask_spsln
[26:24] sequence length.
@ k_ra8_spcr3_mask_ssl_pol
[3:0] SSLnP.
ra8_spsr_mask_t
SPSR bit-masks.
@ k_ra8_spsr_mask_ovrf
RA8 spsr mask ovrf.
@ k_ra8_spsr_mask_sprf
RA8 spsr mask sprf.
@ k_ra8_spsr_mask_udrf
RA8 spsr mask udrf.
@ k_ra8_spsr_mask_spdrf
RA8 spsr mask spdrf.
@ k_ra8_spsr_mask_perf
RA8 spsr mask perf.
@ k_ra8_spsr_mask_cendf
RA8 spsr mask cendf.
@ k_ra8_spsr_mask_modf
RA8 spsr mask modf.
@ k_ra8_spsr_mask_sptef
RA8 spsr mask sptef.
@ k_ra8_spsr_mask_idlnf
RA8 spsr mask idlnf.
@ k_ra8_spsr_mask_errs
OVRF | MODF | PERF | UDRF.
ra8_spi_b_channel_count_t
Channel count addressed by the SPI_B driver.
@ k_ra8_spi_b_channel_count
SPI0 + SPI1.
ra8_spi_limits_t
SPI_B static dimensioning constants.
@ k_ra8_spi_channel_stride
256-byte channel stride.
@ k_ra8_spi_block_size
112-byte register footprint.
@ k_ra8_spi_cmd_count
SPCMD0..SPCMD7 sequence slots.
@ k_ra8_spi_primary_count
Number of SPI_B channels.
ra8_spcmd_spb_t
SPB[4:0] data-length encodings used by the driver.
@ k_ra8_spcmd_spb_32bit
0b11111 -> 32-bit frame.
@ k_ra8_spcmd_spb_16bit
0b01111 -> 16-bit frame.
@ k_ra8_spcmd_spb_8bit
0b00111 -> 8-bit frame.
ra8_spcr3_misc_t
SPCR3 misc constants used in driver-side bit-shifting math.
@ k_ra8_spbr_max
SPBR is 8-bit unsigned.
ra8_spsrc_mask_t
SPSRC (status clear, write-1-to-clear) masks.
@ k_ra8_spsrc_mask_cendfc
RA8 spsrc mask cendfc.
@ k_ra8_spsrc_mask_all
Clear every flag at once.
@ k_ra8_spsrc_mask_spdrfc
RA8 spsrc mask spdrfc.
@ k_ra8_spsrc_mask_udrfc
RA8 spsrc mask udrfc.
@ k_ra8_spsrc_mask_ovrfc
RA8 spsrc mask ovrfc.
@ k_ra8_spsrc_mask_perfc
RA8 spsrc mask perfc.
@ k_ra8_spsrc_mask_modfc
RA8 spsrc mask modfc.
@ k_ra8_spsrc_mask_sprfc
RA8 spsrc mask sprfc.
@ k_ra8_spsrc_mask_sptefc
RA8 spsrc mask sptefc.
ra8_spcr_bit_t
SPCR (control register 1) bit positions.
@ k_ra8_spcr_bit_bfds
Between Burst Transfer Frames Delay Sel.
@ k_ra8_spcr_bit_bpen
Synchronization Circuit Bypass Enable.
@ k_ra8_spcr_bit_modfen
Mode Fault Error Detection Enable.
@ k_ra8_spcr_bit_spiie
Idle Interrupt Enable.
@ k_ra8_spcr_bit_spoe
Parity Mode (0=even, 1=odd).
@ k_ra8_spcr_bit_txmd_hi
Communication Mode bit 1.
@ k_ra8_spcr_bit_spe
SPI Function Enable.
@ k_ra8_spcr_bit_txmd_lo
Communication Mode bit 0.
@ k_ra8_spcr_bit_pte
Parity Self-Diagnosis Enable.
@ k_ra8_spcr_bit_spfrf
Frame Format Select (Motorola/TI SSP).
@ k_ra8_spcr_bit_speie
Error Interrupt Enable.
@ k_ra8_spcr_bit_sptie
TX Buffer Empty Interrupt Enable.
@ k_ra8_spcr_bit_sprie
RX Buffer Full Interrupt Enable.
@ k_ra8_spcr_bit_spms
3-Wire Mode Select (1) vs 4-Wire (0).
@ k_ra8_spcr_bit_spdres
Receive Data Ready Error Select.
@ k_ra8_spcr_bit_sckase
RSPCK Auto-Stop Function Enable.
@ k_ra8_spcr_bit_sppe
Parity Enable.
@ k_ra8_spcr_bit_cendie
Communication End Interrupt Enable.
@ k_ra8_spcr_bit_mstr
Controller/Peripheral Mode Select (1=controller).
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 _reserved1[2]
+0x48..0x4C reserved.
volatile uint32_t SPCR
+0x08 SPI Control Register 1.
volatile uint32_t _reserved0[3]
+0x34..0x3C reserved.
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 SPPSR
+0x60 SPI Polling Register.
volatile uint32_t SPSR
+0x50 SPI Status Register.
volatile uint32_t SPRFSR
+0x5C RX FIFO Status Register.
volatile uint32_t _reserved3
+0x64 reserved.
volatile uint32_t SPDCR
+0x40 SPI Data Control Register.
volatile uint32_t SPTFSR
+0x58 TX FIFO Status Register.
volatile uint32_t SPCR2
+0x0C SPI Control Register 2.
volatile uint32_t SPDR
+0x00 SPI Data Register.
volatile uint32_t _reserved2
+0x54 reserved.