19 #ifndef __RFLPC_SPI_H__
20 #define __RFLPC_SPI_H__
27 #ifdef RFLPC_CONFIG_ENABLE_SPI
30 #include "../interrupt.h"
52 #define RFLPC_SPI_CPOL_RISING_EDGE 0
54 #define RFLPC_SPI_CPOL_FALLING_EDGE 2
57 #define RFLPC_SPI_CPHA_PHASE_PIOR_TO_FIRST_EDGE 0
60 #define RFLPC_SPI_CPHA_PHASE_FIRST_EDGE 1
88 return (port ==
RFLPC_SPI0) ? LPC_SSP0 : LPC_SSP1;
100 return spi_base->SR & 1;
112 return ((spi_base->SR & 0x10) == 0);
125 return !(spi_base->SR & (1UL << 1));
137 return !(spi_base->SR & (1UL << 2));
void rflpc_spi_init(rflpc_spi_t port, rflpc_spi_mode_t mode, rflpc_clock_divider_t cpu_clock_divider, uint8_t data_size_transfert, uint8_t clock_prescale, uint8_t serial_clock_rate, uint8_t clock_polarity_phase)
Inits the SPI interface in master mode.
static int rflpc_spi_tx_fifo_empty(rflpc_spi_t port)
Tests if transmition FIFO is empty.
static int rflpc_spi_tx_fifo_full(rflpc_spi_t port)
Tests if the transmition FIFO is full.
rflpc_clock_divider_t
This enums defines the different cpu clock dividers for use as peripheral clocks. ...
static void rflpc_spi_write(rflpc_spi_t port, uint16_t data)
Sends data through the spi interface.
static int rflpc_spi_rx_fifo_empty(rflpc_spi_t port)
Tests if the reception FIFO is empty.
rflpc_spi_mode_t
Used to select the SPI operating mode.
static LPC_SSP_TypeDef * rflpc_spi_get_base_addr(rflpc_spi_t port)
Returns the base address of the SPI control block depending of the desired port.
rflpc_spi_t
Used to select which SPI port to use.
static int rflpc_spi_idle(rflpc_spi_t port)
Test if the spi is idle (nor transmiting neither receiving) This is useful when you need to handle CS...
void rflpc_spi_set_rx_callback(rflpc_spi_t port, rflpc_irq_handler_t callback)
Sets the interrupt handler for SPI reception.
static uint16_t rflpc_spi_read(rflpc_spi_t port)
Receive data through the spi interface.
void(* rflpc_irq_handler_t)(void)
Interrupt handler type.