30#if defined(LIBOPENCM3_SPI_H)
32#ifndef LIBOPENCM3_SPI_COMMON_ALL_H
33#define LIBOPENCM3_SPI_COMMON_ALL_H
58#define SPI_CR1(spi_base) MMIO32((spi_base) + 0x00)
59#define SPI1_CR1 SPI_CR1(SPI1_BASE)
60#define SPI2_CR1 SPI_CR1(SPI2_BASE)
61#define SPI3_CR1 SPI_CR1(SPI3_BASE)
64#define SPI_CR2(spi_base) MMIO32((spi_base) + 0x04)
65#define SPI1_CR2 SPI_CR2(SPI1_BASE)
66#define SPI2_CR2 SPI_CR2(SPI2_BASE)
67#define SPI3_CR2 SPI_CR2(SPI3_BASE)
70#define SPI_SR(spi_base) MMIO32((spi_base) + 0x08)
71#define SPI1_SR SPI_SR(SPI1_BASE)
72#define SPI2_SR SPI_SR(SPI2_BASE)
73#define SPI3_SR SPI_SR(SPI3_BASE)
76#define SPI_DR(spi_base) MMIO32((spi_base) + 0x0c)
77#define SPI1_DR SPI_DR(SPI1_BASE)
78#define SPI2_DR SPI_DR(SPI2_BASE)
79#define SPI3_DR SPI_DR(SPI3_BASE)
83#define SPI_CRCPR(spi_base) MMIO32((spi_base) + 0x10)
84#define SPI1_CRCPR SPI_CRCPR(SPI1_BASE)
85#define SPI2_CRCPR SPI_CRCPR(SPI2_BASE)
86#define SPI3_CRCPR SPI_CRCPR(SPI3_BASE)
90#define SPI_RXCRCR(spi_base) MMIO32((spi_base) + 0x14)
91#define SPI1_RXCRCR SPI_RXCRCR(SPI1_BASE)
92#define SPI2_RXCRCR SPI_RXCRCR(SPI2_BASE)
93#define SPI3_RXCRCR SPI_RXCRCR(SPI3_BASE)
97#define SPI_TXCRCR(spi_base) MMIO32((spi_base) + 0x18)
98#define SPI1_TXCRCR SPI_TXCRCR(SPI1_BASE)
99#define SPI2_TXCRCR SPI_TXCRCR(SPI2_BASE)
100#define SPI3_TXCRCR SPI_TXCRCR(SPI3_BASE)
103#define SPI_I2SCFGR(spi_base) MMIO32((spi_base) + 0x1c)
104#define SPI1_I2SCFGR SPI_I2SCFGR(SPI1_BASE)
105#define SPI2_I2SCFGR SPI_I2SCFGR(SPI2_BASE)
106#define SPI3_I2SCFGR SPI_I2SCFGR(SPI3_BASE)
109#define SPI_I2SPR(spi_base) MMIO32((spi_base) + 0x20)
110#define SPI1_I2SPR SPI_I2SPR(SPI1_BASE)
111#define SPI2_I2SPR SPI_I2SPR(SPI2_BASE)
112#define SPI3_I2SPR SPI_I2SPR(SPI3_BASE)
119#define SPI_CR1_BIDIMODE_2LINE_UNIDIR (0 << 15)
120#define SPI_CR1_BIDIMODE_1LINE_BIDIR (1 << 15)
121#define SPI_CR1_BIDIMODE (1 << 15)
124#define SPI_CR1_BIDIOE (1 << 14)
127#define SPI_CR1_CRCEN (1 << 13)
130#define SPI_CR1_CRCNEXT (1 << 12)
133#define SPI_CR1_RXONLY (1 << 10)
136#define SPI_CR1_SSM (1 << 9)
139#define SPI_CR1_SSI (1 << 8)
147#define SPI_CR1_MSBFIRST (0 << 7)
148#define SPI_CR1_LSBFIRST (1 << 7)
152#define SPI_CR1_SPE (1 << 6)
160#define SPI_CR1_BAUDRATE_FPCLK_DIV_2 (0x00 << 3)
161#define SPI_CR1_BAUDRATE_FPCLK_DIV_4 (0x01 << 3)
162#define SPI_CR1_BAUDRATE_FPCLK_DIV_8 (0x02 << 3)
163#define SPI_CR1_BAUDRATE_FPCLK_DIV_16 (0x03 << 3)
164#define SPI_CR1_BAUDRATE_FPCLK_DIV_32 (0x04 << 3)
165#define SPI_CR1_BAUDRATE_FPCLK_DIV_64 (0x05 << 3)
166#define SPI_CR1_BAUDRATE_FPCLK_DIV_128 (0x06 << 3)
167#define SPI_CR1_BAUDRATE_FPCLK_DIV_256 (0x07 << 3)
174#define SPI_CR1_BR_FPCLK_DIV_2 0x0
175#define SPI_CR1_BR_FPCLK_DIV_4 0x1
176#define SPI_CR1_BR_FPCLK_DIV_8 0x2
177#define SPI_CR1_BR_FPCLK_DIV_16 0x3
178#define SPI_CR1_BR_FPCLK_DIV_32 0x4
179#define SPI_CR1_BR_FPCLK_DIV_64 0x5
180#define SPI_CR1_BR_FPCLK_DIV_128 0x6
181#define SPI_CR1_BR_FPCLK_DIV_256 0x7
185#define SPI_CR1_MSTR (1 << 2)
193#define SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE (0 << 1)
194#define SPI_CR1_CPOL_CLK_TO_1_WHEN_IDLE (1 << 1)
196#define SPI_CR1_CPOL (1 << 1)
204#define SPI_CR1_CPHA_CLK_TRANSITION_1 (0 << 0)
205#define SPI_CR1_CPHA_CLK_TRANSITION_2 (1 << 0)
207#define SPI_CR1_CPHA (1 << 0)
214#define SPI_CR2_TXEIE (1 << 7)
217#define SPI_CR2_RXNEIE (1 << 6)
220#define SPI_CR2_ERRIE (1 << 5)
226#define SPI_CR2_SSOE (1 << 2)
229#define SPI_CR2_TXDMAEN (1 << 1)
232#define SPI_CR2_RXDMAEN (1 << 0)
239#define SPI_SR_BSY (1 << 7)
242#define SPI_SR_OVR (1 << 6)
246#define SPI_SR_MODF (1 << 5)
250#define SPI_SR_CRCERR (1 << 4)
254#define SPI_SR_UDR (1 << 3)
258#define SPI_SR_CHSIDE (1 << 2)
261#define SPI_SR_TXE (1 << 1)
264#define SPI_SR_RXNE (1 << 0)
292#define SPI_I2SCFGR_I2SMOD (1 << 11)
295#define SPI_I2SCFGR_I2SE (1 << 10)
298#define SPI_I2SCFGR_I2SCFG_LSB 8
299#define SPI_I2SCFGR_I2SCFG_SLAVE_TRANSMIT 0x0
300#define SPI_I2SCFGR_I2SCFG_SLAVE_RECEIVE 0x1
301#define SPI_I2SCFGR_I2SCFG_MASTER_TRANSMIT 0x2
302#define SPI_I2SCFGR_I2SCFG_MASTER_RECEIVE 0x3
305#define SPI_I2SCFGR_PCMSYNC (1 << 7)
310#define SPI_I2SCFGR_I2SSTD_LSB 4
311#define SPI_I2SCFGR_I2SSTD_I2S_PHILIPS 0x0
312#define SPI_I2SCFGR_I2SSTD_MSB_JUSTIFIED 0x1
313#define SPI_I2SCFGR_I2SSTD_LSB_JUSTIFIED 0x2
314#define SPI_I2SCFGR_I2SSTD_PCM 0x3
317#define SPI_I2SCFGR_CKPOL (1 << 3)
320#define SPI_I2SCFGR_DATLEN_LSB 1
321#define SPI_I2SCFGR_DATLEN_16BIT 0x0
322#define SPI_I2SCFGR_DATLEN_24BIT 0x1
323#define SPI_I2SCFGR_DATLEN_32BIT 0x2
326#define SPI_I2SCFGR_CHLEN (1 << 0)
335#define SPI_I2SPR_MCKOE (1 << 9)
338#define SPI_I2SPR_ODD (1 << 8)
350void spi_write(uint32_t spi, uint16_t data);
351void spi_send(uint32_t spi, uint16_t data);
353uint16_t
spi_xfer(uint32_t spi, uint16_t data);
398#warning "spi_common_all.h should not be included explicitly, only via spi.h"
void spi_disable_rx_dma(uint32_t spi)
SPI Disable Receive Transfers via DMA.
void spi_set_next_tx_from_buffer(uint32_t spi)
SPI Next Transmit is a Data Word.
void spi_disable_crc(uint32_t spi)
SPI Disable the CRC.
uint16_t spi_read(uint32_t spi)
SPI Data Read.
void spi_send(uint32_t spi, uint16_t data)
SPI Data Write with Blocking.
void spi_set_unidirectional_mode(uint32_t spi)
SPI Set Unidirectional Mode.
void spi_enable(uint32_t spi)
SPI Enable.
void spi_set_clock_polarity_1(uint32_t spi)
SPI Set the Clock Polarity to High when Idle.
void spi_enable_crc(uint32_t spi)
SPI Enable the CRC.
void spi_disable(uint32_t spi)
SPI Disable.
void spi_set_nss_low(uint32_t spi)
SPI Set the Software NSS Signal Low.
void spi_enable_tx_buffer_empty_interrupt(uint32_t spi)
SPI Enable the Transmit Buffer Empty Interrupt.
void spi_disable_software_slave_management(uint32_t spi)
SPI Disable Slave Management by Hardware.
void spi_set_clock_polarity_0(uint32_t spi)
SPI Set the Clock Polarity to Low when Idle.
void spi_set_baudrate_prescaler(uint32_t spi, uint8_t baudrate)
SPI Set the Baudrate Prescaler.
void spi_write(uint32_t spi, uint16_t data)
SPI Data Write.
void spi_set_full_duplex_mode(uint32_t spi)
SPI Set Full Duplex (3-wire) Mode.
void spi_enable_tx_dma(uint32_t spi)
SPI Enable Transmit Transfers via DMA.
void spi_set_bidirectional_transmit_only_mode(uint32_t spi)
SPI Set Bidirectional Simplex Receive Only Mode.
void spi_disable_ss_output(uint32_t spi)
SPI Set the NSS Pin as an Input.
void spi_send_lsb_first(uint32_t spi)
SPI Set to Send LSB First.
void spi_disable_error_interrupt(uint32_t spi)
SPI Disable the Error Interrupt.
void spi_set_next_tx_from_crc(uint32_t spi)
SPI Next Transmit is a CRC Word.
void spi_set_receive_only_mode(uint32_t spi)
SPI Set Receive Only Mode for Simplex (2-wire) Unidirectional Transfers.
void spi_enable_software_slave_management(uint32_t spi)
SPI Enable Slave Management by Software.
void spi_set_clock_phase_0(uint32_t spi)
SPI Set the Clock Phase to Capture on Leading Edge.
void spi_disable_tx_buffer_empty_interrupt(uint32_t spi)
SPI Disable the Transmit Buffer Empty Interrupt.
void spi_enable_rx_dma(uint32_t spi)
SPI Enable Receive Transfers via DMA.
void spi_set_clock_phase_1(uint32_t spi)
SPI Set the Clock Phase to Capture on Trailing Edge.
void spi_set_standard_mode(uint32_t spi, uint8_t mode)
SPI Standard Mode selection.
void spi_enable_rx_buffer_not_empty_interrupt(uint32_t spi)
SPI Enable the Receive Buffer Ready Interrupt.
void spi_set_nss_high(uint32_t spi)
SPI Set the Software NSS Signal High.
void spi_enable_ss_output(uint32_t spi)
SPI Set the NSS Pin as an Output.
void spi_disable_rx_buffer_not_empty_interrupt(uint32_t spi)
SPI Disable the Receive Buffer Ready Interrupt.
void spi_send_msb_first(uint32_t spi)
SPI Set to Send MSB First.
uint16_t spi_xfer(uint32_t spi, uint16_t data)
SPI Data Write and Read Exchange.
void spi_set_slave_mode(uint32_t spi)
SPI Set to Slave Mode.
void spi_enable_error_interrupt(uint32_t spi)
SPI Enable the Error Interrupt.
void spi_set_bidirectional_mode(uint32_t spi)
SPI Set Bidirectional Simplex Mode.
void spi_set_bidirectional_receive_only_mode(uint32_t spi)
SPI Set Bidirectional Simplex Receive Only Mode.
uint16_t spi_clean_disable(uint32_t spi)
SPI Clean Disable.
void spi_disable_tx_dma(uint32_t spi)
SPI Disable Transmit Transfers via DMA.
void spi_set_master_mode(uint32_t spi)
SPI Set to Master Mode.