APM:Libraries
|
Go to the source code of this file.
Classes | |
struct | SPI_DMA |
struct | SPI_state |
struct | spi_dev |
Macros | |
#define | SPI_BIT_RXNE ((uint16_t)0x0001) |
#define | SPI_BIT_TXE ((uint16_t)0x0002) |
#define | SPI_BIT_CRCERR ((uint16_t)0x0010) |
#define | SPI_BIT_MODF ((uint16_t)0x0020) |
#define | SPI_BIT_OVR ((uint16_t)0x0040) |
#define | SPI_BIT_BSY ((uint16_t)0x0080) |
#define | SPI_BIT_TIFRFE ((uint16_t)0x0100) |
#define | SPI_size_16b ((uint16_t)0x0800) |
#define | SPI_size_8b ((uint16_t)0x0000) |
#define | SPI_DMAreq_Tx ((uint16_t)0x0002) |
#define | SPI_DMAreq_Rx ((uint16_t)0x0001) |
#define | SPI_INTERRUPTS_ALL |
Mask for all spi_interrupt values. More... | |
Typedefs | |
typedef struct SPI_DMA | Spi_DMA |
typedef struct SPI_state | spi_state |
typedef struct spi_dev | spi_dev |
typedef enum spi_firstbit | spi_firstbit |
typedef enum spi_mode | spi_mode |
SPI mode configuration. More... | |
typedef enum spi_baud_rate | spi_baud_rate |
SPI baud rate configuration, as a divisor of f_PCLK, the PCLK clock frequency. More... | |
typedef enum spi_interrupt | spi_interrupt |
Enumerations | |
enum | spi_firstbit { LSBFIRST =0, MSBFIRST } |
enum | spi_mode { SPI_MODE_0 =0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3 } |
SPI mode configuration. More... | |
enum | spi_baud_rate { SPI_BAUD_PCLK_DIV_2 = ((uint16_t)0x0000), SPI_BAUD_PCLK_DIV_4 = ((uint16_t)0x0008), SPI_BAUD_PCLK_DIV_8 = ((uint16_t)0x0010), SPI_BAUD_PCLK_DIV_16 = ((uint16_t)0x0018), SPI_BAUD_PCLK_DIV_32 = ((uint16_t)0x0020), SPI_BAUD_PCLK_DIV_64 = ((uint16_t)0x0028), SPI_BAUD_PCLK_DIV_128 = ((uint16_t)0x0030), SPI_BAUD_PCLK_DIV_256 = ((uint16_t)0x0038) } |
SPI baud rate configuration, as a divisor of f_PCLK, the PCLK clock frequency. More... | |
enum | spi_interrupt { SPI_TXE_INTERRUPT = 1<<7, SPI_RXNE_INTERRUPT = 1<<6, SPI_ERR_INTERRUPT = 1<<5, SPI_RXNE_TXE_INTERRUPTS = SPI_RXNE_INTERRUPT | SPI_TXE_INTERRUPT, SPI_INTERRUPTS_ALL = SPI_TXE_INTERRUPT | SPI_RXNE_INTERRUPT | SPI_ERR_INTERRUPT } |
Functions | |
static void | spi_peripheral_enable (const spi_dev *dev) |
Enable a SPI peripheral. More... | |
static void | spi_peripheral_disable (const spi_dev *dev) |
Disable a SPI peripheral. More... | |
void | spi_reconfigure (const spi_dev *dev, uint8_t ismaster, uint16_t baudPrescaler, uint16_t bitorder, uint8_t mode) |
void | spi_init (const spi_dev *dev) |
Initialize and reset a SPI device. More... | |
static void | spi_master_enable (const spi_dev *dev, spi_baud_rate baudPrescaler, spi_mode mode, uint16_t bitorder) |
Configure GPIO bit modes for use as a SPI port's pins. More... | |
void | spi_gpio_slave_cfg (const spi_dev *dev, const gpio_dev *comm_dev, uint8_t sck_bit, uint8_t miso_bit, uint8_t mosi_bit) |
void | spi_gpio_master_cfg (const spi_dev *dev, const gpio_dev *comm_dev, uint8_t sck_bit, uint8_t miso_bit, uint8_t mosi_bit) |
Configure and enable a SPI device as bus master. More... | |
void | spi_slave_enable (const spi_dev *dev, spi_mode mode, uint16_t bitorder) |
Configure and enable a SPI device as a bus slave. More... | |
void | spi_set_speed (const spi_dev *dev, uint16_t baudPrescaler) |
void | spi_foreach (void(*fn)(const spi_dev *)) |
Call a function on each SPI port. More... | |
uint32_t | spi_tx (const spi_dev *dev, const void *buf, uint16_t len) |
int | spimaster_transfer (const spi_dev *dev, const uint8_t *txbuf, uint16_t txcount, uint8_t *rxbuf, uint16_t rxcount) |
static uint8_t | spi_is_enabled (const spi_dev *dev) |
static void | spi_peripheral_disable_all (void) |
static void | spi_enable_irq (const spi_dev *dev, spi_interrupt interrupt_flags) |
static void | spi_disable_irq (const spi_dev *dev, spi_interrupt interrupt_flags) |
static bool | spi_is_irq_enabled (const spi_dev *dev, uint32_t interrupt_flags) |
static uint16_t | spi_dff (const spi_dev *dev) |
static uint8_t | spi_is_rx_nonempty (const spi_dev *dev) |
static uint8_t | spi_rx_reg (const spi_dev *dev) |
static uint8_t | spi_is_tx_empty (const spi_dev *dev) |
static void | spi_tx_reg (const spi_dev *dev, uint8_t val) |
static uint8_t | spi_is_busy (const spi_dev *dev) |
static void | spi_wait_busy (const spi_dev *dev) |
static void | spi_enable_dma_req (const spi_dev *dev, uint16_t SPI_DMAReq) |
static void | spi_disable_dma_req (const spi_dev *dev, uint16_t SPI_DMAReq) |
static void | spi_attach_interrupt (const spi_dev *dev, Handler handler) |
static void | spi_detach_interrupt (const spi_dev *dev) |
Variables | |
const spi_dev *const | _SPI1 |
const spi_dev *const | _SPI2 |
const spi_dev *const | _SPI3 |
#define SPI_BIT_BSY ((uint16_t)0x0080) |
Definition at line 87 of file spi.h.
Referenced by spi_is_busy(), spi_wait_busy(), and spimaster_transfer().
#define SPI_BIT_RXNE ((uint16_t)0x0001) |
Definition at line 82 of file spi.h.
Referenced by spi_is_rx_nonempty(), and spimaster_transfer().
#define SPI_BIT_TXE ((uint16_t)0x0002) |
Definition at line 83 of file spi.h.
Referenced by spi_is_tx_empty(), spi_reconfigure(), and spimaster_transfer().
#define SPI_DMAreq_Rx ((uint16_t)0x0001) |
Definition at line 94 of file spi.h.
Referenced by F4Light::SPIDevice::disable_dma(), and F4Light::SPIDevice::start_dma_transfer().
#define SPI_DMAreq_Tx ((uint16_t)0x0002) |
Definition at line 93 of file spi.h.
Referenced by F4Light::SPIDevice::disable_dma(), and F4Light::SPIDevice::start_dma_transfer().
#define SPI_INTERRUPTS_ALL |
Mask for all spi_interrupt values.
#define SPI_size_16b ((uint16_t)0x0800) |
#define SPI_size_8b ((uint16_t)0x0000) |
typedef enum spi_baud_rate spi_baud_rate |
SPI baud rate configuration, as a divisor of f_PCLK, the PCLK clock frequency.
typedef enum spi_firstbit spi_firstbit |
typedef enum spi_interrupt spi_interrupt |
Available SPI interrupts - see SPI_I2S_GetITStatus
SPI mode configuration.
Determines a combination of clock polarity (CPOL), which determines idle state of the clock line, and clock phase (CPHA), which determines which clock edge triggers data capture.
enum spi_baud_rate |
SPI baud rate configuration, as a divisor of f_PCLK, the PCLK clock frequency.
enum spi_firstbit |
enum spi_interrupt |
Available SPI interrupts - see SPI_I2S_GetITStatus
enum spi_mode |
SPI mode configuration.
Determines a combination of clock polarity (CPOL), which determines idle state of the clock line, and clock phase (CPHA), which determines which clock edge triggers data capture.
Definition at line 295 of file spi.h.
Referenced by F4Light::SPIDevice::send_strobe(), F4Light::SPIDevice::setup_isr_transfer(), and F4Light::SPIDevice::wait_for().
|
inlinestatic |
Definition at line 306 of file spi.h.
Referenced by F4Light::SPIDevice::isr_transfer_finish().
|
inlinestatic |
Definition at line 289 of file spi.h.
Referenced by F4Light::SPIDevice::disable_dma().
|
inlinestatic |
Definition at line 241 of file spi.h.
Referenced by F4Light::SPIDevice::dma_isr(), F4Light::SPIDevice::get_dma_ready(), isr_handler(), F4Light::SPIDevice::isr_transfer_finish(), F4Light::SPIDevice::spi_isr(), and spi_reconfigure().
|
inlinestatic |
Definition at line 284 of file spi.h.
Referenced by F4Light::SPIDevice::start_dma_transfer().
|
inlinestatic |
Definition at line 237 of file spi.h.
Referenced by F4Light::SPIDevice::dma_isr(), F4Light::SPIDevice::do_transfer(), F4Light::SPIDevice::spi_isr(), and F4Light::SPIDevice::wait_for().
void spi_foreach | ( | void(*)(const spi_dev *) | fn | ) |
Call a function on each SPI port.
fn | Function to call. |
Definition at line 84 of file spi.c.
Referenced by spi_master_enable(), and spi_peripheral_disable_all().
void spi_gpio_master_cfg | ( | const spi_dev * | dev, |
const gpio_dev * | comm_dev, | ||
uint8_t | sck_bit, | ||
uint8_t | miso_bit, | ||
uint8_t | mosi_bit | ||
) |
Configure and enable a SPI device as bus master.
The device's peripheral will be disabled before being reconfigured.
dev | Device to configure as bus master |
baud | Bus baud rate |
mode | SPI mode |
flags | Logical OR of spi_cfg_flag values. |
Definition at line 92 of file spi.c.
Referenced by F4Light::SPIDevice::init(), and spi_master_enable().
void spi_gpio_slave_cfg | ( | const spi_dev * | dev, |
const gpio_dev * | comm_dev, | ||
uint8_t | sck_bit, | ||
uint8_t | miso_bit, | ||
uint8_t | mosi_bit | ||
) |
Definition at line 115 of file spi.c.
Referenced by spi_master_enable().
void spi_init | ( | const spi_dev * | dev | ) |
Initialize and reset a SPI device.
dev | Device to initialize and reset. |
Definition at line 57 of file spi.c.
Referenced by F4Light::SPIDevice::init(), setup(), spi_peripheral_disable(), and spi_reconfigure().
|
inlinestatic |
Definition at line 271 of file spi.h.
Referenced by F4Light::SPIDevice::_transfer(), F4Light::SPIDevice::send(), and spimaster_transfer().
|
inlinestatic |
|
inlinestatic |
Definition at line 246 of file spi.h.
Referenced by F4Light::SPIDevice::spi_isr().
|
inlinestatic |
Definition at line 255 of file spi.h.
Referenced by F4Light::SPIDevice::_transfer(), F4Light::SPIDevice::isr_transfer_finish(), and F4Light::SPIDevice::spi_isr().
|
inlinestatic |
Definition at line 263 of file spi.h.
Referenced by F4Light::SPIDevice::_transfer(), F4Light::SPIDevice::send(), and F4Light::SPIDevice::spi_isr().
|
inlinestatic |
Configure GPIO bit modes for use as a SPI port's pins.
as_master | If true, configure bits for use as a bus master. Otherwise, configure bits for use as slave. |
nss_dev | NSS pin's GPIO device |
comm_dev | SCK, MISO, MOSI pins' GPIO device |
nss_bit | NSS pin's GPIO bit on nss_dev |
sck_bit | SCK pin's GPIO bit on comm_dev |
miso_bit | MISO pin's GPIO bit on comm_dev |
mosi_bit | MOSI pin's GPIO bit on comm_dev |
Definition at line 163 of file spi.h.
Referenced by F4Light::SPIDevice::init().
|
inlinestatic |
Disable a SPI peripheral.
dev | Device to disable |
Definition at line 138 of file spi.h.
Referenced by spi_peripheral_disable_all(), and spi_reconfigure().
|
inlinestatic |
|
inlinestatic |
void spi_reconfigure | ( | const spi_dev * | dev, |
uint8_t | ismaster, | ||
uint16_t | baudPrescaler, | ||
uint16_t | bitorder, | ||
uint8_t | mode | ||
) |
Definition at line 132 of file spi.c.
Referenced by spi_master_enable(), and spi_peripheral_disable().
|
inlinestatic |
Definition at line 259 of file spi.h.
Referenced by F4Light::SPIDevice::isr_transfer_finish().
void spi_set_speed | ( | const spi_dev * | dev, |
uint16_t | baudPrescaler | ||
) |
Definition at line 205 of file spi.c.
Referenced by F4Light::SPIDevice::apply_speed(), spi_master_enable(), F4Light::SPIDevice::transfer(), and F4Light::SPIDevice::transfer_fullduplex().
Configure and enable a SPI device as a bus slave.
The device's peripheral will be disabled before being reconfigured.
dev | Device to configure as a bus slave |
mode | SPI mode |
flags | Logical OR of spi_cfg_flag values. |
Referenced by spi_master_enable().
uint32_t spi_tx | ( | const spi_dev * | dev, |
const void * | buf, | ||
uint16_t | len | ||
) |
|
inlinestatic |
Definition at line 267 of file spi.h.
Referenced by F4Light::SPIDevice::send().
|
inlinestatic |
Definition at line 275 of file spi.h.
Referenced by F4Light::SPIDevice::_cs_release(), F4Light::SPIDevice::dma_isr(), F4Light::SPIDevice::isr_transfer_finish(), F4Light::SPIDevice::spi_isr(), and F4Light::SPIDevice::wait_busy().
int spimaster_transfer | ( | const spi_dev * | dev, |
const uint8_t * | txbuf, | ||
uint16_t | txcount, | ||
uint8_t * | rxbuf, | ||
uint16_t | rxcount | ||
) |
Definition at line 219 of file spi.c.
Referenced by spi_master_enable(), and F4Light::SPIDevice::transfer().