|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
43 #define SPI_SELECT_SLAVE_IO__(port, reg) IO ## port ## reg
45 #define SPI_SELECT_SLAVE_IO_(port, reg) SPI_SELECT_SLAVE_IO__(port, reg)
47 #define SPI_SELECT_SLAVE0_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, DIR)
48 #define SPI_SELECT_SLAVE0_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, CLR)
49 #define SPI_SELECT_SLAVE0_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE0_PORT, SET)
51 #define SPI_SELECT_SLAVE1_IODIR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, DIR)
52 #define SPI_SELECT_SLAVE1_IOCLR SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, CLR)
53 #define SPI_SELECT_SLAVE1_IOSET SPI_SELECT_SLAVE_IO_(SPI_SELECT_SLAVE1_PORT, SET)
202 while (
p->tx_idx_buf < max_idx && bit_is_set(((
sspRegs_t *)(
p->reg_addr))->sr,
TNF)) {
216 if (
p->tx_idx_buf == max_idx) {
293 p->trans_extract_idx++;
295 p->trans_extract_idx = 0;
298 if (
p->trans_extract_idx ==
p->trans_insert_idx ||
p->suspend) {
385 #define SSP_PINSEL1_SCK (2 << 2)
386 #define SSP_PINSEL1_MISO (2 << 4)
387 #define SSP_PINSEL1_MOSI (2 << 6)
388 #define SSP_PINSEL1_SSEL (2 << 8)
391 #ifndef SPI1_VIC_SLOT
392 #define SPI1_VIC_SLOT 7
405 #error "SPI0 is currently not implemented in the mcu_periph/spi HAL for the LPC!"
433 #define MASTER_SSP_DSS 0x07 << 0
434 #define MASTER_SSP_FRF 0x00 << 4
435 #define MASTER_SSP_CPOL 0x00 << 6
436 #define MASTER_SSP_CPHA 0x00 << 7
437 #define MASTER_SSP_SCR 0x0F << 8
440 #define MASTER_SSP_LBM 0x00 << 0
441 #define MASTER_SSP_SSE 0x00 << 1
442 #define MASTER_SSP_MS 0x00 << 2
443 #define MASTER_SSP_SOD 0x00 << 3
450 #define SSPCPSR_VAL 0x02
453 void spi1_ISR(
void) __attribute__((naked));
498 idx =
p->trans_insert_idx + 1;
500 if (
idx ==
p->trans_extract_idx) {
513 p->trans[
p->trans_insert_idx] = t;
514 p->trans_insert_idx =
idx;
516 if (
p->status ==
SPIIdle && !
p->suspend) {
549 #error SPI_SLAVE2 is not implemented yet, sorry
567 if (slave < 254 && p->suspend == 0) {
568 p->suspend = slave + 1;
580 if (
p->suspend == slave + 1) {
583 if (
p->trans_extract_idx !=
p->trans_insert_idx &&
p->status ==
SPIIdle) {
607 #if (PCLK == 15000000)
611 #if (PCLK == 30000000)
615 #if (PCLK == 60000000)
619 #error unknown PCLK frequency
625 #error SPI0 in slave mode is not implemented yet, sorry
631 #define SLAVE_SSP_DSS 0x07 << 0
632 #define SLAVE_SSP_FRF 0x00 << 4
633 #define SLAVE_SSP_CPOL 0x00 << 6
634 #define SLAVE_SSP_CPHA 0x01 << 7
635 #define SLAVE_SSP_SCR 0x0F << 8
638 #define SLAVE_SSP_LBM 0x00 << 0
639 #define SLAVE_SSP_SSE 0x00 << 1
640 #define SLAVE_SSP_MS 0x01 << 2
641 #define SLAVE_SSP_SOD 0x00 << 3
643 void spi1_slave_ISR(
void) __attribute__((naked));
645 void spi1_slave_ISR(
void)
655 void spi1_slave_arch_init(
void)
664 SSPCR0 = SLAVE_SSP_DSS | SLAVE_SSP_FRF | SLAVE_SSP_CPOL | SLAVE_SSP_CPHA | SLAVE_SSP_SCR;
665 SSPCR1 = SLAVE_SSP_LBM | SLAVE_SSP_MS | SLAVE_SSP_SOD;
682 if (
p->trans_insert_idx >= 1) {
688 p->trans[
p->trans_insert_idx] = t;
689 p->trans_insert_idx = 1;
705 if (
p->trans_insert_idx == 0) {
static void SpiEndOfTransaction(struct spi_periph *p, struct spi_transaction *t)
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
#define SPI1_VIC_SLOT
default initial settings
static void SpiRead(struct spi_periph *p, uint16_t *c)
unsigned disableIRQ(void)
enum SPIClockPolarity cpol
clock polarity control
static void SpiDisableTxi(struct spi_periph *p)
#define MASTER_SSP_FRF
frame format : SPI
static void SpiSetCPOL(struct spi_periph *p)
#define SPI_SELECT_SLAVE1_PINSEL_VAL
uint16_t output_length
number of data words to write
#define MASTER_SSP_SOD
slave output disable : don't care when master
SPI transaction structure.
#define MASTER_SSP_CPHA
clock phase : data captured on first clock transition
#define SPI_SELECT_SLAVE1_PINSEL
static void SpiDisable(struct spi_periph *p)
#define SPI_SELECT_SLAVE1_IOSET
#define MASTER_SSP_SCR
serial clock rate : divide by 16
#define SPI_SELECT_SLAVE0_PINSEL_BIT
bool spi_slave_register(struct spi_periph *p, struct spi_transaction *t)
Register one (and only one) transaction to use spi as slave.
static void SpiSetCPHA(struct spi_periph *p)
static void SpiEnable(struct spi_periph *p)
#define MASTER_SSP_LBM
loopback mode : disabled
#define SPI_SELECT_SLAVE1_IOCLR
@ SPISelectUnselect
slave is selected before transaction and unselected after
static void SpiSlaveAutomaton(struct spi_periph *p)
#define SPI_SELECT_SLAVE0_PIN
static void SpiSlaveUnselect(uint8_t slave)
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
SPI peripheral structure.
static void SpiClearRti(struct spi_periph *p)
enum SPISlaveSelect select
slave selection behavior
static void SpiEnableRti(struct spi_periph *p)
@ SPIUnselect
slave is not selected but unselected after transaction
static void SpiSend(struct spi_periph *p, uint16_t c)
#define SPI_SELECT_SLAVE1_PIN
enum SPIClockPhase cpha
clock phase control
static void SpiSetDataSize(struct spi_periph *p, enum SPIDataSizeSelect dss)
Set the SPI data size to 8 or 16bit.
SPICallback after_cb
NULL or function called after the transaction.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
static void SpiEnableRxi(struct spi_periph *p)
static void SpiSlaveStart(struct spi_periph *p, struct spi_transaction *t)
bool spi_resume(struct spi_periph *p, uint8_t slave)
spi_resume() function
static void SpiClearCPOL(struct spi_periph *p)
static void SpiEnableTxi(struct spi_periph *p)
#define MASTER_SSP_CPOL
clock polarity : SCK idles low
#define SPI_SELECT_SLAVE1_IODIR
void spi_slave_unselect(uint8_t slave)
spi_slave_unselect() function
#define MASTER_SSP_DSS
data size : 8 bits
@ SPICpolIdleHigh
CPOL = 1.
#define SPI_SELECT_SLAVE0_IODIR
bool spi_slave_wait(struct spi_periph *p)
Initialized and wait for the next transaction.
static void SpiClearCPHA(struct spi_periph *p)
#define SPI_SELECT_SLAVE0_IOCLR
static void SpiDisableRti(struct spi_periph *p)
#define SPI_SELECT_SLAVE1_PINSEL_BIT
void spi_slave_select(uint8_t slave)
spi_slave_select() function
bool spi_lock(struct spi_periph *p, uint8_t slave)
spi_lock() function
static void SpiReceive(struct spi_periph *p, struct spi_transaction *t)
uint16_t input_length
number of data words to read
static void SpiAutomaton(struct spi_periph *p)
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
static void SpiTransmit(struct spi_periph *p, struct spi_transaction *t)
@ SPISelect
slave is selected before transaction but not unselected
volatile uint8_t * input_buf
pointer to receive buffer for DMA
#define SPI_SELECT_SLAVE0_PINSEL_VAL
static void SpiDisableRxi(struct spi_periph *p)
#define SPI_SELECT_SLAVE0_IOSET
static void SpiSlaveSelect(uint8_t slave)
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
process_rx_dma_interrupt & spi1
receive transferred over DMA
static void SpiInitBuf(struct spi_periph *p, struct spi_transaction *t)
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
SPICallback before_cb
NULL or function called before the transaction.
#define SPI_SELECT_SLAVE0_PINSEL
void spi_init_slaves(void)
spi_init_slaves() function
#define SSPCPSR_VAL
Clock prescaler.
static void SpiStart(struct spi_periph *p, struct spi_transaction *t)
#define SPI_TRANSACTION_QUEUE_LEN
SPI transaction queue length.
enum SPITransactionStatus status
#define MASTER_SSP_MS
master slave mode : master
SPIDataSizeSelect
SPI data word size of transfer.