spi.h
1 // THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
2 
3 /*
4  * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _HARDWARE_STRUCTS_SPI_H
10 #define _HARDWARE_STRUCTS_SPI_H
11 
13 #include "hardware/regs/spi.h"
14 
15 // Reference to datasheet: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#tab-registerlist_spi
16 //
17 // The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature)
18 // _REG_(x) will link to the corresponding register in hardware/regs/spi.h.
19 //
20 // Bit-field descriptions are of the form:
21 // BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION
22 
23 typedef struct {
24  _REG_(SPI_SSPCR0_OFFSET) // SPI_SSPCR0
25  // Control register 0, SSPCR0 on page 3-4
26  // 0x0000ff00 [15:8] : SCR (0): Serial clock rate
27  // 0x00000080 [7] : SPH (0): SSPCLKOUT phase, applicable to Motorola SPI frame format only
28  // 0x00000040 [6] : SPO (0): SSPCLKOUT polarity, applicable to Motorola SPI frame format only
29  // 0x00000030 [5:4] : FRF (0): Frame format: 00 Motorola SPI frame format
30  // 0x0000000f [3:0] : DSS (0): Data Size Select: 0000 Reserved, undefined operation
31  io_rw_32 cr0;
32 
33  _REG_(SPI_SSPCR1_OFFSET) // SPI_SSPCR1
34  // Control register 1, SSPCR1 on page 3-5
35  // 0x00000008 [3] : SOD (0): Slave-mode output disable
36  // 0x00000004 [2] : MS (0): Master or slave mode select
37  // 0x00000002 [1] : SSE (0): Synchronous serial port enable: 0 SSP operation disabled
38  // 0x00000001 [0] : LBM (0): Loop back mode: 0 Normal serial port operation enabled
39  io_rw_32 cr1;
40 
41  _REG_(SPI_SSPDR_OFFSET) // SPI_SSPDR
42  // Data register, SSPDR on page 3-6
43  // 0x0000ffff [15:0] : DATA (0): Transmit/Receive FIFO: Read Receive FIFO
44  io_rw_32 dr;
45 
46  _REG_(SPI_SSPSR_OFFSET) // SPI_SSPSR
47  // Status register, SSPSR on page 3-7
48  // 0x00000010 [4] : BSY (0): PrimeCell SSP busy flag, RO: 0 SSP is idle
49  // 0x00000008 [3] : RFF (0): Receive FIFO full, RO: 0 Receive FIFO is not full
50  // 0x00000004 [2] : RNE (0): Receive FIFO not empty, RO: 0 Receive FIFO is empty
51  // 0x00000002 [1] : TNF (1): Transmit FIFO not full, RO: 0 Transmit FIFO is full
52  // 0x00000001 [0] : TFE (1): Transmit FIFO empty, RO: 0 Transmit FIFO is not empty
53  io_ro_32 sr;
54 
55  _REG_(SPI_SSPCPSR_OFFSET) // SPI_SSPCPSR
56  // Clock prescale register, SSPCPSR on page 3-8
57  // 0x000000ff [7:0] : CPSDVSR (0): Clock prescale divisor
58  io_rw_32 cpsr;
59 
60  _REG_(SPI_SSPIMSC_OFFSET) // SPI_SSPIMSC
61  // Interrupt mask set or clear register, SSPIMSC on page 3-9
62  // 0x00000008 [3] : TXIM (0): Transmit FIFO interrupt mask: 0 Transmit FIFO half empty or less condition interrupt is masked
63  // 0x00000004 [2] : RXIM (0): Receive FIFO interrupt mask: 0 Receive FIFO half full or less condition interrupt is masked
64  // 0x00000002 [1] : RTIM (0): Receive timeout interrupt mask: 0 Receive FIFO not empty and no read prior to timeout...
65  // 0x00000001 [0] : RORIM (0): Receive overrun interrupt mask: 0 Receive FIFO written to while full condition...
66  io_rw_32 imsc;
67 
68  _REG_(SPI_SSPRIS_OFFSET) // SPI_SSPRIS
69  // Raw interrupt status register, SSPRIS on page 3-10
70  // 0x00000008 [3] : TXRIS (1): Gives the raw interrupt state, prior to masking, of the SSPTXINTR interrupt
71  // 0x00000004 [2] : RXRIS (0): Gives the raw interrupt state, prior to masking, of the SSPRXINTR interrupt
72  // 0x00000002 [1] : RTRIS (0): Gives the raw interrupt state, prior to masking, of the SSPRTINTR interrupt
73  // 0x00000001 [0] : RORRIS (0): Gives the raw interrupt state, prior to masking, of the SSPRORINTR interrupt
74  io_ro_32 ris;
75 
76  _REG_(SPI_SSPMIS_OFFSET) // SPI_SSPMIS
77  // Masked interrupt status register, SSPMIS on page 3-11
78  // 0x00000008 [3] : TXMIS (0): Gives the transmit FIFO masked interrupt state, after masking, of the SSPTXINTR interrupt
79  // 0x00000004 [2] : RXMIS (0): Gives the receive FIFO masked interrupt state, after masking, of the SSPRXINTR interrupt
80  // 0x00000002 [1] : RTMIS (0): Gives the receive timeout masked interrupt state, after masking, of the SSPRTINTR interrupt
81  // 0x00000001 [0] : RORMIS (0): Gives the receive over run masked interrupt status, after masking, of the...
82  io_ro_32 mis;
83 
84  _REG_(SPI_SSPICR_OFFSET) // SPI_SSPICR
85  // Interrupt clear register, SSPICR on page 3-11
86  // 0x00000002 [1] : RTIC (0): Clears the SSPRTINTR interrupt
87  // 0x00000001 [0] : RORIC (0): Clears the SSPRORINTR interrupt
88  io_rw_32 icr;
89 
90  _REG_(SPI_SSPDMACR_OFFSET) // SPI_SSPDMACR
91  // DMA control register, SSPDMACR on page 3-12
92  // 0x00000002 [1] : TXDMAE (0): Transmit DMA Enable
93  // 0x00000001 [0] : RXDMAE (0): Receive DMA Enable
94  io_rw_32 dmacr;
95 } spi_hw_t;
96 
97 #define spi0_hw ((spi_hw_t *)SPI0_BASE)
98 #define spi1_hw ((spi_hw_t *)SPI1_BASE)
99 
100 #endif
address_mapped.h
spi_hw_t
Definition: spi.h:23