libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
spi_common_all.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SPI1   SPI1_BASE
 
#define SPI2   SPI2_BASE
 
#define SPI3   SPI3_BASE
 
#define SPI4   SPI4_BASE
 
#define SPI5   SPI5_BASE
 
#define SPI6   SPI6_BASE
 
#define SPI_CR1(spi_base)   MMIO32((spi_base) + 0x00)
 
#define SPI1_CR1   SPI_CR1(SPI1_BASE)
 
#define SPI2_CR1   SPI_CR1(SPI2_BASE)
 
#define SPI3_CR1   SPI_CR1(SPI3_BASE)
 
#define SPI_CR2(spi_base)   MMIO32((spi_base) + 0x04)
 
#define SPI1_CR2   SPI_CR2(SPI1_BASE)
 
#define SPI2_CR2   SPI_CR2(SPI2_BASE)
 
#define SPI3_CR2   SPI_CR2(SPI3_BASE)
 
#define SPI_SR(spi_base)   MMIO32((spi_base) + 0x08)
 
#define SPI1_SR   SPI_SR(SPI1_BASE)
 
#define SPI2_SR   SPI_SR(SPI2_BASE)
 
#define SPI3_SR   SPI_SR(SPI3_BASE)
 
#define SPI_DR(spi_base)   MMIO32((spi_base) + 0x0c)
 
#define SPI1_DR   SPI_DR(SPI1_BASE)
 
#define SPI2_DR   SPI_DR(SPI2_BASE)
 
#define SPI3_DR   SPI_DR(SPI3_BASE)
 
#define SPI_CRCPR(spi_base)   MMIO32((spi_base) + 0x10)
 
#define SPI1_CRCPR   SPI_CRCPR(SPI1_BASE)
 
#define SPI2_CRCPR   SPI_CRCPR(SPI2_BASE)
 
#define SPI3_CRCPR   SPI_CRCPR(SPI3_BASE)
 
#define SPI_RXCRCR(spi_base)   MMIO32((spi_base) + 0x14)
 
#define SPI1_RXCRCR   SPI_RXCRCR(SPI1_BASE)
 
#define SPI2_RXCRCR   SPI_RXCRCR(SPI2_BASE)
 
#define SPI3_RXCRCR   SPI_RXCRCR(SPI3_BASE)
 
#define SPI_TXCRCR(spi_base)   MMIO32((spi_base) + 0x18)
 
#define SPI1_TXCRCR   SPI_TXCRCR(SPI1_BASE)
 
#define SPI2_TXCRCR   SPI_TXCRCR(SPI2_BASE)
 
#define SPI3_TXCRCR   SPI_TXCRCR(SPI3_BASE)
 
#define SPI_I2SCFGR(spi_base)   MMIO32((spi_base) + 0x1c)
 
#define SPI1_I2SCFGR   SPI_I2SCFGR(SPI1_BASE)
 
#define SPI2_I2SCFGR   SPI_I2SCFGR(SPI2_BASE)
 
#define SPI3_I2SCFGR   SPI_I2SCFGR(SPI3_BASE)
 
#define SPI_I2SPR(spi_base)   MMIO32((spi_base) + 0x20)
 
#define SPI1_I2SPR   SPI_I2SPR(SPI1_BASE)
 
#define SPI2_I2SPR   SPI_I2SPR(SPI2_BASE)
 
#define SPI3_I2SPR   SPI_I2SPR(SPI3_BASE)
 
#define SPI_CR1_BIDIMODE_2LINE_UNIDIR   (0 << 15)
 
#define SPI_CR1_BIDIMODE_1LINE_BIDIR   (1 << 15)
 
#define SPI_CR1_BIDIMODE   (1 << 15)
 
#define SPI_CR1_BIDIOE   (1 << 14)
 
#define SPI_CR1_CRCEN   (1 << 13)
 
#define SPI_CR1_CRCNEXT   (1 << 12)
 
#define SPI_CR1_RXONLY   (1 << 10)
 
#define SPI_CR1_SSM   (1 << 9)
 
#define SPI_CR1_SSI   (1 << 8)
 
#define SPI_CR1_MSBFIRST   (0 << 7)
 
#define SPI_CR1_LSBFIRST   (1 << 7)
 
#define SPI_CR1_SPE   (1 << 6)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_2   (0x00 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_4   (0x01 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_8   (0x02 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_16   (0x03 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_32   (0x04 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_64   (0x05 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_128   (0x06 << 3)
 
#define SPI_CR1_BAUDRATE_FPCLK_DIV_256   (0x07 << 3)
 
#define SPI_CR1_BR_FPCLK_DIV_2   0x0
 
#define SPI_CR1_BR_FPCLK_DIV_4   0x1
 
#define SPI_CR1_BR_FPCLK_DIV_8   0x2
 
#define SPI_CR1_BR_FPCLK_DIV_16   0x3
 
#define SPI_CR1_BR_FPCLK_DIV_32   0x4
 
#define SPI_CR1_BR_FPCLK_DIV_64   0x5
 
#define SPI_CR1_BR_FPCLK_DIV_128   0x6
 
#define SPI_CR1_BR_FPCLK_DIV_256   0x7
 
#define SPI_CR1_MSTR   (1 << 2)
 
#define SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE   (0 << 1)
 
#define SPI_CR1_CPOL_CLK_TO_1_WHEN_IDLE   (1 << 1)
 
#define SPI_CR1_CPOL   (1 << 1)
 
#define SPI_CR1_CPHA_CLK_TRANSITION_1   (0 << 0)
 
#define SPI_CR1_CPHA_CLK_TRANSITION_2   (1 << 0)
 
#define SPI_CR1_CPHA   (1 << 0)
 
#define SPI_CR2_TXEIE   (1 << 7)
 
#define SPI_CR2_RXNEIE   (1 << 6)
 
#define SPI_CR2_ERRIE   (1 << 5)
 
#define SPI_CR2_SSOE   (1 << 2)
 
#define SPI_CR2_TXDMAEN   (1 << 1)
 
#define SPI_CR2_RXDMAEN   (1 << 0)
 
#define SPI_SR_BSY   (1 << 7)
 
#define SPI_SR_OVR   (1 << 6)
 
#define SPI_SR_MODF   (1 << 5)
 
#define SPI_SR_CRCERR   (1 << 4)
 
#define SPI_SR_UDR   (1 << 3)
 
#define SPI_SR_CHSIDE   (1 << 2)
 
#define SPI_SR_TXE   (1 << 1)
 
#define SPI_SR_RXNE   (1 << 0)
 
#define SPI_I2SCFGR_I2SMOD   (1 << 11)
 
#define SPI_I2SCFGR_I2SE   (1 << 10)
 
#define SPI_I2SCFGR_I2SCFG_LSB   8
 
#define SPI_I2SCFGR_I2SCFG_SLAVE_TRANSMIT   0x0
 
#define SPI_I2SCFGR_I2SCFG_SLAVE_RECEIVE   0x1
 
#define SPI_I2SCFGR_I2SCFG_MASTER_TRANSMIT   0x2
 
#define SPI_I2SCFGR_I2SCFG_MASTER_RECEIVE   0x3
 
#define SPI_I2SCFGR_PCMSYNC   (1 << 7)
 
#define SPI_I2SCFGR_I2SSTD_LSB   4
 
#define SPI_I2SCFGR_I2SSTD_I2S_PHILIPS   0x0
 
#define SPI_I2SCFGR_I2SSTD_MSB_JUSTIFIED   0x1
 
#define SPI_I2SCFGR_I2SSTD_LSB_JUSTIFIED   0x2
 
#define SPI_I2SCFGR_I2SSTD_PCM   0x3
 
#define SPI_I2SCFGR_CKPOL   (1 << 3)
 
#define SPI_I2SCFGR_DATLEN_LSB   1
 
#define SPI_I2SCFGR_DATLEN_16BIT   0x0
 
#define SPI_I2SCFGR_DATLEN_24BIT   0x1
 
#define SPI_I2SCFGR_DATLEN_32BIT   0x2
 
#define SPI_I2SCFGR_CHLEN   (1 << 0)
 
#define SPI_I2SPR_MCKOE   (1 << 9)
 
#define SPI_I2SPR_ODD   (1 << 8)
 

Functions

void spi_enable (uint32_t spi)
 SPI Enable. More...
 
void spi_disable (uint32_t spi)
 SPI Disable. More...
 
uint16_t spi_clean_disable (uint32_t spi)
 SPI Clean Disable. More...
 
void spi_write (uint32_t spi, uint16_t data)
 SPI Data Write. More...
 
void spi_send (uint32_t spi, uint16_t data)
 SPI Data Write with Blocking. More...
 
uint16_t spi_read (uint32_t spi)
 SPI Data Read. More...
 
uint16_t spi_xfer (uint32_t spi, uint16_t data)
 SPI Data Write and Read Exchange. More...
 
void spi_set_bidirectional_mode (uint32_t spi)
 SPI Set Bidirectional Simplex Mode. More...
 
void spi_set_unidirectional_mode (uint32_t spi)
 SPI Set Unidirectional Mode. More...
 
void spi_set_bidirectional_receive_only_mode (uint32_t spi)
 SPI Set Bidirectional Simplex Receive Only Mode. More...
 
void spi_set_bidirectional_transmit_only_mode (uint32_t spi)
 SPI Set Bidirectional Simplex Receive Only Mode. More...
 
void spi_enable_crc (uint32_t spi)
 SPI Enable the CRC. More...
 
void spi_disable_crc (uint32_t spi)
 SPI Disable the CRC. More...
 
void spi_set_next_tx_from_buffer (uint32_t spi)
 SPI Next Transmit is a Data Word. More...
 
void spi_set_next_tx_from_crc (uint32_t spi)
 SPI Next Transmit is a CRC Word. More...
 
void spi_set_full_duplex_mode (uint32_t spi)
 SPI Set Full Duplex (3-wire) Mode. More...
 
void spi_set_receive_only_mode (uint32_t spi)
 SPI Set Receive Only Mode for Simplex (2-wire) Unidirectional Transfers. More...
 
void spi_disable_software_slave_management (uint32_t spi)
 SPI Disable Slave Management by Hardware. More...
 
void spi_enable_software_slave_management (uint32_t spi)
 SPI Enable Slave Management by Software. More...
 
void spi_set_nss_high (uint32_t spi)
 SPI Set the Software NSS Signal High. More...
 
void spi_set_nss_low (uint32_t spi)
 SPI Set the Software NSS Signal Low. More...
 
void spi_send_lsb_first (uint32_t spi)
 SPI Set to Send LSB First. More...
 
void spi_send_msb_first (uint32_t spi)
 SPI Set to Send MSB First. More...
 
void spi_set_baudrate_prescaler (uint32_t spi, uint8_t baudrate)
 SPI Set the Baudrate Prescaler. More...
 
void spi_set_master_mode (uint32_t spi)
 SPI Set to Master Mode. More...
 
void spi_set_slave_mode (uint32_t spi)
 SPI Set to Slave Mode. More...
 
void spi_set_clock_polarity_1 (uint32_t spi)
 SPI Set the Clock Polarity to High when Idle. More...
 
void spi_set_clock_polarity_0 (uint32_t spi)
 SPI Set the Clock Polarity to Low when Idle. More...
 
void spi_set_clock_phase_1 (uint32_t spi)
 SPI Set the Clock Phase to Capture on Trailing Edge. More...
 
void spi_set_clock_phase_0 (uint32_t spi)
 SPI Set the Clock Phase to Capture on Leading Edge. More...
 
void spi_enable_tx_buffer_empty_interrupt (uint32_t spi)
 SPI Enable the Transmit Buffer Empty Interrupt. More...
 
void spi_disable_tx_buffer_empty_interrupt (uint32_t spi)
 SPI Disable the Transmit Buffer Empty Interrupt. More...
 
void spi_enable_rx_buffer_not_empty_interrupt (uint32_t spi)
 SPI Enable the Receive Buffer Ready Interrupt. More...
 
void spi_disable_rx_buffer_not_empty_interrupt (uint32_t spi)
 SPI Disable the Receive Buffer Ready Interrupt. More...
 
void spi_enable_error_interrupt (uint32_t spi)
 SPI Enable the Error Interrupt. More...
 
void spi_disable_error_interrupt (uint32_t spi)
 SPI Disable the Error Interrupt. More...
 
void spi_enable_ss_output (uint32_t spi)
 SPI Set the NSS Pin as an Output. More...
 
void spi_disable_ss_output (uint32_t spi)
 SPI Set the NSS Pin as an Input. More...
 
void spi_enable_tx_dma (uint32_t spi)
 SPI Enable Transmit Transfers via DMA. More...
 
void spi_disable_tx_dma (uint32_t spi)
 SPI Disable Transmit Transfers via DMA. More...
 
void spi_enable_rx_dma (uint32_t spi)
 SPI Enable Receive Transfers via DMA. More...
 
void spi_disable_rx_dma (uint32_t spi)
 SPI Disable Receive Transfers via DMA. More...
 
void spi_set_standard_mode (uint32_t spi, uint8_t mode)
 SPI Standard Mode selection. More...