Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
|
Handling of SPI hardware for lpc21xx. More...
#include "mcu_periph/spi.h"
#include "std.h"
#include "LPC21xx.h"
#include "armVIC.h"
#include <BOARD_CONFIG>
Go to the source code of this file.
Macros | |
#define | SSP_PINSEL1_SCK (2 << 2) |
#define | SSP_PINSEL1_MISO (2 << 4) |
#define | SSP_PINSEL1_MOSI (2 << 6) |
#define | SSP_PINSEL1_SSEL (2 << 8) |
#define | SPI1_VIC_SLOT 7 |
default initial settings More... | |
#define | MASTER_SSP_DSS 0x07 << 0 |
data size : 8 bits More... | |
#define | MASTER_SSP_FRF 0x00 << 4 |
frame format : SPI More... | |
#define | MASTER_SSP_CPOL 0x00 << 6 |
clock polarity : SCK idles low More... | |
#define | MASTER_SSP_CPHA 0x00 << 7 |
clock phase : data captured on first clock transition More... | |
#define | MASTER_SSP_SCR 0x0F << 8 |
serial clock rate : divide by 16 More... | |
#define | MASTER_SSP_LBM 0x00 << 0 |
loopback mode : disabled More... | |
#define | MASTER_SSP_SSE 0x00 << 1 |
SSP enable : disabled. More... | |
#define | MASTER_SSP_MS 0x00 << 2 |
master slave mode : master More... | |
#define | MASTER_SSP_SOD 0x00 << 3 |
slave output disable : don't care when master More... | |
#define | SSPCPSR_VAL 0x02 /* clock prescale */ |
Clock prescaler. More... | |
Functions | |
static void | SpiSetDataSize (struct spi_periph *p, enum SPIDataSizeSelect dss) |
Set the SPI data size to 8 or 16bit. More... | |
void | spi0_arch_init (void) |
Architecture dependent SPI0 initialization. More... | |
void | spi1_ISR (void) |
void | spi1_arch_init (void) |
Architecture dependent SPI1 initialization. More... | |
bool_t | spi_submit (struct spi_periph *p, struct spi_transaction *t) |
Submit a spi transaction. More... | |
void | spi_init_slaves (void) |
Initialize all used slaves and unselect them. More... | |
void | spi_slave_select (uint8_t slave) |
Select a slave. More... | |
void | spi_slave_unselect (uint8_t slave) |
Unselect a slave. More... | |
bool_t | spi_lock (struct spi_periph *p, uint8_t slave) |
Lock the SPI fifo. More... | |
bool_t | spi_resume (struct spi_periph *p, uint8_t slave) |
Resume the SPI fifo. More... | |
bool_t | spi_slave_register (struct spi_periph *p, struct spi_transaction *t) |
Register one (and only one) transaction to use spi as slave. More... | |
bool_t | spi_slave_wait (struct spi_periph *p) |
Initialized and wait for the next transaction. More... | |
SPI clock | |
Spi clock polarity and phase functions. | |
static void | SpiSetCPOL (struct spi_periph *p) |
static void | SpiClearCPOL (struct spi_periph *p) |
static void | SpiSetCPHA (struct spi_periph *p) |
static void | SpiClearCPHA (struct spi_periph *p) |
SPI control | |
Spi control functions. | |
static void | SpiEnable (struct spi_periph *p) |
static void | SpiDisable (struct spi_periph *p) |
static void | SpiEnableRti (struct spi_periph *p) |
static void | SpiDisableRti (struct spi_periph *p) |
static void | SpiClearRti (struct spi_periph *p) |
static void | SpiEnableTxi (struct spi_periph *p) |
static void | SpiDisableTxi (struct spi_periph *p) |
static void | SpiEnableRxi (struct spi_periph *p) |
static void | SpiDisableRxi (struct spi_periph *p) |
static void | SpiSend (struct spi_periph *p, uint16_t c) |
static void | SpiRead (struct spi_periph *p, uint16_t *c) |
static void | SpiTransmit (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiReceive (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiInitBuf (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiStart (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiEndOfTransaction (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiAutomaton (struct spi_periph *p) |
static void | SpiSlaveStart (struct spi_periph *p, struct spi_transaction *t) |
static void | SpiSlaveAutomaton (struct spi_periph *p) |
Variables | |
uint8_t | spi0_vic_slot |
uint8_t | spi1_vic_slot |
Slave selection | |
#define | SPI_SELECT_SLAVE_IO__(port, reg) IO ## port ## reg |
#define | SPI_SELECT_SLAVE_IO_(port, reg) SPI_SELECT_SLAVE_IO__(port, reg) |
#define | SPI_SELECT_SLAVE0_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, DIR) |
#define | SPI_SELECT_SLAVE0_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, CLR) |
#define | SPI_SELECT_SLAVE0_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, SET) |
#define | SPI_SELECT_SLAVE1_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, DIR) |
#define | SPI_SELECT_SLAVE1_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, CLR) |
#define | SPI_SELECT_SLAVE1_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, SET) |
static void | SpiSlaveSelect (uint8_t slave) |
static void | SpiSlaveUnselect (uint8_t slave) |
Handling of SPI hardware for lpc21xx.
for now only SPI1 ( aka SSP )
TODO current implementation only works for SPI1 (SSP)
Definition in file spi_arch.c.
#define MASTER_SSP_CPHA 0x00 << 7 |
clock phase : data captured on first clock transition
Definition at line 436 of file spi_arch.c.
Referenced by spi1_arch_init().
#define MASTER_SSP_CPOL 0x00 << 6 |
clock polarity : SCK idles low
Definition at line 435 of file spi_arch.c.
Referenced by spi1_arch_init().
#define MASTER_SSP_DSS 0x07 << 0 |
#define MASTER_SSP_FRF 0x00 << 4 |
#define MASTER_SSP_LBM 0x00 << 0 |
#define MASTER_SSP_MS 0x00 << 2 |
master slave mode : master
Definition at line 442 of file spi_arch.c.
Referenced by spi1_arch_init().
#define MASTER_SSP_SCR 0x0F << 8 |
serial clock rate : divide by 16
Definition at line 437 of file spi_arch.c.
Referenced by spi1_arch_init().
#define MASTER_SSP_SOD 0x00 << 3 |
slave output disable : don't care when master
Definition at line 443 of file spi_arch.c.
Referenced by spi1_arch_init().
#define MASTER_SSP_SSE 0x00 << 1 |
SSP enable : disabled.
Definition at line 441 of file spi_arch.c.
#define SPI1_VIC_SLOT 7 |
#define SPI_SELECT_SLAVE0_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, CLR) |
Definition at line 48 of file spi_arch.c.
Referenced by SpiSlaveSelect().
#define SPI_SELECT_SLAVE0_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, DIR) |
Definition at line 47 of file spi_arch.c.
Referenced by spi_init_slaves().
#define SPI_SELECT_SLAVE0_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, SET) |
Definition at line 49 of file spi_arch.c.
Referenced by SpiSlaveUnselect().
#define SPI_SELECT_SLAVE1_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, CLR) |
Definition at line 52 of file spi_arch.c.
Referenced by SpiSlaveSelect().
#define SPI_SELECT_SLAVE1_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, DIR) |
Definition at line 51 of file spi_arch.c.
Referenced by spi_init_slaves().
#define SPI_SELECT_SLAVE1_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, SET) |
Definition at line 53 of file spi_arch.c.
Referenced by SpiSlaveUnselect().
#define SPI_SELECT_SLAVE_IO_ | ( | port, | |
reg | |||
) | SPI_SELECT_SLAVE_IO__(port, reg) |
Definition at line 45 of file spi_arch.c.
#define SPI_SELECT_SLAVE_IO__ | ( | port, | |
reg | |||
) | IO ## port ## reg |
Definition at line 44 of file spi_arch.c.
#define SSP_PINSEL1_MISO (2 << 4) |
Definition at line 386 of file spi_arch.c.
Referenced by max11040_hw_init(), micromag_hw_init(), and spi1_arch_init().
#define SSP_PINSEL1_MOSI (2 << 6) |
Definition at line 387 of file spi_arch.c.
Referenced by max11040_hw_init(), micromag_hw_init(), and spi1_arch_init().
#define SSP_PINSEL1_SCK (2 << 2) |
Definition at line 385 of file spi_arch.c.
Referenced by max11040_hw_init(), micromag_hw_init(), and spi1_arch_init().
#define SSP_PINSEL1_SSEL (2 << 8) |
Definition at line 388 of file spi_arch.c.
Referenced by max11040_hw_init().
#define SSPCPSR_VAL 0x02 /* clock prescale */ |
Clock prescaler.
SPI clock rate = PCLK / (CPSR*(SCR+1)) with PCLK = 30 MHz, CPSR = 2 and SCR = 15 -> clock ~ 1 MHz
Definition at line 450 of file spi_arch.c.
Referenced by spi1_arch_init().
void spi1_ISR | ( | void | ) |
Definition at line 455 of file spi_arch.c.
References ISR_ENTRY, ISR_EXIT, spi1, SpiAutomaton(), and VICVectAddr.
Referenced by spi1_arch_init().
|
inlinestatic |
Definition at line 306 of file spi_arch.c.
References BSY, spi_transaction::input_length, spi_transaction::output_length, RTMIS, SpiClearRti(), SpiDisableRti(), SpiEnableTxi(), SpiEndOfTransaction(), SpiReceive(), SpiTransmit(), and TXMIS.
Referenced by spi1_ISR().
|
inlinestatic |
Definition at line 111 of file spi_arch.c.
References CPHA.
Referenced by spi_slave_register(), and SpiStart().
|
inlinestatic |
Definition at line 101 of file spi_arch.c.
References CPOL.
Referenced by spi_slave_register(), and SpiStart().
|
inlinestatic |
Definition at line 161 of file spi_arch.c.
References RTIC.
Referenced by ADS8344_start(), lcd_spi_tx(), SPI1_ISR(), SpiAutomaton(), and SpiSlaveAutomaton().
|
inlinestatic |
Definition at line 146 of file spi_arch.c.
References SSE.
Referenced by SpiEndOfTransaction(), and SpiSlaveAutomaton().
|
inlinestatic |
Definition at line 156 of file spi_arch.c.
References RTIM.
Referenced by SPI1_ISR(), SpiAutomaton(), and SpiSlaveAutomaton().
|
inlinestatic |
Definition at line 181 of file spi_arch.c.
References RXIM.
|
inlinestatic |
Definition at line 171 of file spi_arch.c.
References TXIM.
Referenced by SpiTransmit().
|
inlinestatic |
Definition at line 141 of file spi_arch.c.
Referenced by SpiSlaveStart(), and SpiStart().
|
inlinestatic |
Definition at line 151 of file spi_arch.c.
References RTIM.
Referenced by ADS8344_start(), baro_scp_start_high_res_measurement(), lcd_spi_tx(), SpiSlaveAutomaton(), and SpiStart().
|
inlinestatic |
Definition at line 176 of file spi_arch.c.
References RXIM.
|
inlinestatic |
Definition at line 166 of file spi_arch.c.
References TXIM.
Referenced by SpiAutomaton(), SpiSlaveStart(), and SpiStart().
|
inlinestatic |
Definition at line 278 of file spi_arch.c.
References SPI_TRANSACTION_QUEUE_LEN, SpiDisable(), SPIIdle, SPISelectUnselect, SpiSlaveUnselect(), SpiStart(), SPITransSuccess, and SPIUnselect.
Referenced by SpiAutomaton().
|
inlinestatic |
Definition at line 241 of file spi_arch.c.
References SpiTransmit().
Referenced by SpiSlaveStart(), and SpiStart().
|
inlinestatic |
Definition at line 191 of file spi_arch.c.
Referenced by SpiReceive().
|
inlinestatic |
Definition at line 221 of file spi_arch.c.
References foo, RNE, SPIDss16bit, SPIDss8bit, and SpiRead().
Referenced by SpiAutomaton(), and SpiSlaveAutomaton().
|
inlinestatic |
Definition at line 186 of file spi_arch.c.
Referenced by SpiTransmit().
|
inlinestatic |
Definition at line 106 of file spi_arch.c.
References CPHA.
Referenced by baro_MS5534A_send(), spi_slave_register(), and SpiStart().
|
inlinestatic |
Definition at line 96 of file spi_arch.c.
Referenced by spi_slave_register(), and SpiStart().
|
inlinestatic |
Set the SPI data size to 8 or 16bit.
p | SPI peripheral to set |
dss | data size |
Definition at line 123 of file spi_arch.c.
References DSS, DSS_VAL16, DSS_VAL8, SPIDss16bit, and SPIDss8bit.
Referenced by spi_slave_register(), and SpiStart().
|
inlinestatic |
Definition at line 350 of file spi_arch.c.
References spi_transaction::after_cb, RTMIS, SpiClearRti(), SpiDisable(), SpiDisableRti(), SpiEnableRti(), SPIIdle, SpiReceive(), SpiTransmit(), SPITransSuccess, spi_transaction::status, and TXMIS.
|
inlinestatic |
Definition at line 55 of file spi_arch.c.
References SPI_SELECT_SLAVE0_IOCLR, SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE1_IOCLR, SPI_SELECT_SLAVE1_PIN, SPI_SLAVE0, and SPI_SLAVE1.
Referenced by spi_slave_select(), and SpiStart().
|
inlinestatic |
Definition at line 335 of file spi_arch.c.
References SpiEnable(), SpiEnableTxi(), SpiInitBuf(), SPIRunning, and SPITransRunning.
Referenced by spi_slave_wait().
|
inlinestatic |
Definition at line 73 of file spi_arch.c.
References SPI_SELECT_SLAVE0_IOSET, SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE1_IOSET, SPI_SELECT_SLAVE1_PIN, SPI_SLAVE0, and SPI_SLAVE1.
Referenced by spi_init_slaves(), spi_slave_unselect(), and SpiEndOfTransaction().
|
inlinestatic |
Definition at line 249 of file spi_arch.c.
References SpiClearCPHA(), SpiClearCPOL(), SPICphaEdge2, SPICpolIdleHigh, SpiEnable(), SpiEnableRti(), SpiEnableTxi(), SpiInitBuf(), SPIRunning, SPISelect, SPISelectUnselect, SpiSetCPHA(), SpiSetCPOL(), SpiSetDataSize(), SpiSlaveSelect(), and SPITransRunning.
Referenced by baro_MS5534A_send(), spi_resume(), spi_submit(), and SpiEndOfTransaction().
|
inlinestatic |
Definition at line 197 of file spi_arch.c.
References Max, SpiDisableTxi(), SPIDss16bit, SPIDss8bit, SpiSend(), and TNF.
Referenced by SpiAutomaton(), SpiInitBuf(), and SpiSlaveAutomaton().
uint8_t spi0_vic_slot |
Definition at line 415 of file spi_arch.c.
uint8_t spi1_vic_slot |
Definition at line 465 of file spi_arch.c.