Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Data Structures | |
struct | spi_transaction |
SPI transaction structure. More... | |
struct | spi_periph |
SPI peripheral structure. More... | |
Macros | |
#define | SPI_TRANSACTION_QUEUE_LEN 8 |
SPI transaction queue length. More... | |
#define | SPI_SLAVE0 0 |
#define | SPI_SLAVE1 1 |
#define | SPI_SLAVE2 2 |
#define | SPI_SLAVE3 3 |
#define | SPI_SLAVE4 4 |
#define | SPI_SLAVE5 5 |
#define | SPI_SLAVE6 6 |
#define | SPI_SLAVE7 7 |
#define | SPI_SLAVE8 8 |
Typedefs | |
typedef void(* | SPICallback) (struct spi_transaction *trans) |
SPI Callback function. More... | |
Enumerations | |
enum | SPIMode { SPIMaster , SPISlave } |
enum | SPISlaveSelect { SPISelectUnselect , SPISelect , SPIUnselect , SPINoSelect } |
SPI slave selection behavior options. More... | |
enum | SPIClockPhase { SPICphaEdge1 , SPICphaEdge2 } |
SPI CPHA (clock phase) options. More... | |
enum | SPIClockPolarity { SPICpolIdleLow , SPICpolIdleHigh } |
SPI CPOL (clock polarity) options. More... | |
enum | SPIDataSizeSelect { SPIDss8bit , SPIDss16bit } |
SPI data word size of transfer. More... | |
enum | SPITransactionStatus { SPITransPending , SPITransRunning , SPITransSuccess , SPITransFailed , SPITransDone } |
SPI transaction status. More... | |
enum | SPIStatus { SPIIdle , SPIRunning } |
SPI peripheral status. More... | |
enum | SPIBitOrder { SPIMSBFirst , SPILSBFirst } |
enum | SPIClockDiv { SPIDiv2 , SPIDiv4 , SPIDiv8 , SPIDiv16 , SPIDiv32 , SPIDiv64 , SPIDiv128 , SPIDiv256 } |
Peripheral clock divider. More... | |
Functions | |
void | spi0_init (void) |
void | spi0_arch_init (void) |
Architecture dependent SPI0 initialization. More... | |
void | spi1_init (void) |
void | spi1_arch_init (void) |
Architecture dependent SPI1 initialization. More... | |
void | spi2_init (void) |
void | spi2_arch_init (void) |
Architecture dependent SPI2 initialization. More... | |
void | spi_init (struct spi_periph *p) |
Initialize a spi peripheral. More... | |
void | spi_init_slaves (void) |
Initialize all used slaves and unselect them. More... | |
bool | spi_submit (struct spi_periph *p, struct spi_transaction *t) |
Submit a spi transaction. More... | |
static bool | spi_blocking_transceive (struct spi_periph *p, struct spi_transaction *t) |
Perform a spi transaction (blocking). More... | |
void | spi_slave_select (uint8_t slave) |
Select a slave. More... | |
void | spi_slave_unselect (uint8_t slave) |
Unselect a slave. More... | |
bool | spi_lock (struct spi_periph *p, uint8_t slave) |
Lock the SPI fifo. More... | |
bool | spi_resume (struct spi_periph *p, uint8_t slave) |
Resume the SPI fifo. More... | |
void | spi_slave_init (struct spi_periph *p) |
Initialize a spi peripheral in slave mode. More... | |
bool | spi_slave_register (struct spi_periph *p, struct spi_transaction *t) |
Register a spi transaction in slave mode (only one transaction can be registered). More... | |
bool | spi_slave_wait (struct spi_periph *p) |
Initialized and wait for the next transaction. More... | |
Variables | |
struct spi_periph | spi0 |
struct spi_periph | spi1 |
receive transferred over DMA More... | |
struct spi_periph | spi2 |
receive transferred over DMA More... | |
struct spi_transaction |
SPI transaction structure.
Data Fields | ||
---|---|---|
SPICallback | after_cb | NULL or function called after the transaction. |
SPICallback | before_cb | NULL or function called before the transaction. |
enum SPIBitOrder | bitorder | MSB/LSB order. |
enum SPIClockDiv | cdiv | prescaler of main clock to use as SPI clock |
enum SPIClockPhase | cpha | clock phase control |
enum SPIClockPolarity | cpol | clock polarity control |
enum SPIDataSizeSelect | dss | data transfer word size |
volatile uint8_t * | input_buf | pointer to receive buffer for DMA |
uint16_t | input_length | number of data words to read |
volatile uint8_t * | output_buf | pointer to transmit buffer for DMA |
uint16_t | output_length | number of data words to write |
enum SPISlaveSelect | select | slave selection behavior |
uint8_t | slave_idx | slave id: SPI_SLAVE0 to SPI_SLAVE4 |
enum SPITransactionStatus | status |
struct spi_periph |
Data Fields | ||
---|---|---|
void * | init_struct | |
enum SPIMode | mode | |
void * | reg_addr | |
volatile uint8_t | rx_idx_buf | |
enum SPIStatus | status | internal state of the peripheral |
volatile uint8_t | suspend | control for stop/resume of the fifo |
struct spi_transaction * | trans[SPI_TRANSACTION_QUEUE_LEN] | circular buffer holding transactions |
uint8_t | trans_extract_idx | |
uint8_t | trans_insert_idx | |
volatile uint8_t | tx_idx_buf |
#define SPI_TRANSACTION_QUEUE_LEN 8 |
typedef void(* SPICallback) (struct spi_transaction *trans) |
enum SPIBitOrder |
enum SPIClockDiv |
enum SPIClockPhase |
enum SPIClockPolarity |
enum SPIDataSizeSelect |
enum SPISlaveSelect |
SPI slave selection behavior options.
Default operation should be SelectUnselected, but some peripherals might need some special control. Use non-default control only if you know what you're doing.
enum SPIStatus |
enum SPITransactionStatus |
void spi0_arch_init | ( | void | ) |
Architecture dependent SPI0 initialization.
Must be implemented by underlying architecture
Definition at line 137 of file spi_arch.c.
References fd, spi_periph::init_struct, spi_periph::reg_addr, spi0, SPI0_BITS_PER_WORD, SPI0_LSB_FIRST, SPI0_MAX_SPEED_HZ, and SPI0_MODE.
Referenced by spi0_init().
void spi0_init | ( | void | ) |
Definition at line 37 of file spi.c.
References spi0, spi0_arch_init(), and spi_init().
Referenced by mcu_init().
void spi1_arch_init | ( | void | ) |
Architecture dependent SPI1 initialization.
Must be implemented by underlying architecture
Definition at line 423 of file spi_arch.c.
References locm3_spi_comm::br, spi_periph_dma::comm, spi_periph_dma::comm_sig, locm3_spi_comm::cpha, locm3_spi_comm::cpol, locm3_spi_comm::dff, spi_periph_dma::dma, FALSE, fd, get_comm_signature(), gpio_setup_pin_af(), locm3_spi_comm::lsbfirst, spi_periph_dma::rcc_dma, spi_periph_dma::rx_chan, spi_periph_dma::rx_chan_sel, spi_periph_dma::rx_dummy_buf, spi_periph_dma::rx_extra_dummy_dma, spi_periph_dma::rx_nvic_irq, set_default_comm_config(), spi1, SPI1_BITS_PER_WORD, spi1_dma, SPI1_GPIO_AF, SPI1_GPIO_MISO, SPI1_GPIO_MOSI, SPI1_GPIO_PORT_MISO, SPI1_GPIO_PORT_MOSI, SPI1_GPIO_PORT_SCK, SPI1_GPIO_SCK, SPI1_LSB_FIRST, SPI1_MAX_SPEED_HZ, SPI1_MODE, spi_arch_int_enable(), spi_periph_dma::spidr, SPIIdle, thd_spi(), TRUE, spi_periph_dma::tx_chan, spi_periph_dma::tx_chan_sel, spi_periph_dma::tx_dummy_buf, spi_periph_dma::tx_extra_dummy_dma, and spi_periph_dma::tx_nvic_irq.
Referenced by spi1_init().
void spi1_init | ( | void | ) |
Definition at line 48 of file spi.c.
References spi1, spi1_arch_init(), and spi_init().
Referenced by mcu_init().
void spi2_arch_init | ( | void | ) |
Architecture dependent SPI2 initialization.
Must be implemented by underlying architecture
Definition at line 442 of file spi_arch.c.
References locm3_spi_comm::br, spi_periph_dma::comm, spi_periph_dma::comm_sig, locm3_spi_comm::cpha, locm3_spi_comm::cpol, locm3_spi_comm::dff, spi_periph_dma::dma, FALSE, get_comm_signature(), gpio_setup_pin_af(), locm3_spi_comm::lsbfirst, spi_periph_dma::rcc_dma, spi_periph_dma::rx_chan, spi_periph_dma::rx_chan_sel, spi_periph_dma::rx_dummy_buf, spi_periph_dma::rx_extra_dummy_dma, spi_periph_dma::rx_nvic_irq, set_default_comm_config(), spi2, spi2_dma, SPI2_GPIO_AF, SPI2_GPIO_MISO, SPI2_GPIO_MOSI, SPI2_GPIO_PORT_MISO, SPI2_GPIO_PORT_MOSI, SPI2_GPIO_PORT_SCK, SPI2_GPIO_SCK, spi_arch_int_enable(), spi_periph_dma::spidr, SPIIdle, thd_spi(), TRUE, spi_periph_dma::tx_chan, spi_periph_dma::tx_chan_sel, spi_periph_dma::tx_dummy_buf, spi_periph_dma::tx_extra_dummy_dma, and spi_periph_dma::tx_nvic_irq.
Referenced by spi2_init().
void spi2_init | ( | void | ) |
Definition at line 59 of file spi.c.
References spi2, spi2_arch_init(), and spi_init().
Referenced by mcu_init().
|
inlinestatic |
Perform a spi transaction (blocking).
p | spi peripheral to be used |
t | spi transaction |
Definition at line 299 of file spi.h.
References get_sys_time_float(), p, SPI_BLOCKING_TIMEOUT, spi_submit(), SPITransPending, SPITransRunning, and spi_transaction::status.
Referenced by readRegister_blocking(), and writeRegister_blocking().
void spi_init | ( | struct spi_periph * | p | ) |
Initialize a spi peripheral.
p | spi peripheral to be configured |
Definition at line 98 of file spi.c.
References p, SPIIdle, and SPIMaster.
Referenced by spi0_init(), spi1_init(), and spi2_init().
void spi_init_slaves | ( | void | ) |
Initialize all used slaves and unselect them.
Initialize all used slaves and unselect them.
Definition at line 709 of file spi_arch.c.
References gpio_setup_output(), SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE0_PORT, SPI_SELECT_SLAVE1_PIN, SPI_SELECT_SLAVE1_PORT, SPI_SELECT_SLAVE2_PIN, SPI_SELECT_SLAVE2_PORT, SPI_SELECT_SLAVE3_PIN, SPI_SELECT_SLAVE3_PORT, SPI_SELECT_SLAVE4_PIN, SPI_SELECT_SLAVE4_PORT, SPI_SELECT_SLAVE5_PIN, SPI_SELECT_SLAVE5_PORT, spi_slave_unselect(), and SpiSlaveUnselect().
Referenced by mcu_init().
bool spi_lock | ( | struct spi_periph * | p, |
uint8_t | slave | ||
) |
Lock the SPI fifo.
This will stop the SPI fifo after the current transaction if any, or before the next one if none are pending. Only the slave that locks the fifo can unlock it.
p | spi peripheral to be used |
slave | slave id |
Lock the SPI fifo.
Empty, for paparazzi compatibility only
Definition at line 681 of file spi_arch.c.
References FALSE, p, spi_arch_int_disable(), spi_arch_int_enable(), and TRUE.
Referenced by max1168_lock_cb().
bool spi_resume | ( | struct spi_periph * | p, |
uint8_t | slave | ||
) |
Resume the SPI fifo.
Only the slave that locks the fifo can unlock it.
p | spi peripheral to be used |
slave | slave id |
Resume the SPI fifo.
Empty, for paparazzi compatibility only
Definition at line 695 of file spi_arch.c.
References FALSE, p, spi_arch_int_disable(), spi_arch_int_enable(), spi_start_dma_transaction(), SPIIdle, and TRUE.
Referenced by max1168_event().
void spi_slave_init | ( | struct spi_periph * | p | ) |
bool spi_slave_register | ( | struct spi_periph * | p, |
struct spi_transaction * | t | ||
) |
Register a spi transaction in slave mode (only one transaction can be registered).
Must be implemented by the underlying architecture
p | spi peripheral to be used |
t | spi transaction |
Definition at line 1624 of file spi_arch.c.
References spi_periph_dma::dma, spi_transaction::dss, get_transaction_signature(), spi_periph::init_struct, spi_transaction::input_buf, spi_transaction::input_length, spi_transaction::output_buf, spi_transaction::output_length, spi_periph::reg_addr, spi_arch_int_enable(), spi_configure_dma(), spi_slave_set_config(), SPIRunning, SPITransRunning, spi_transaction::status, spi_periph::status, spi_periph::trans, spi_periph::trans_insert_idx, and TRUE.
Referenced by bluegiga_init(), bluegiga_receive(), qr_code_spi_link_init(), and qr_code_spi_link_periodic().
void spi_slave_select | ( | uint8_t | slave | ) |
Select a slave.
slave | slave id |
Select a slave.
Definition at line 566 of file spi_arch.c.
References gpio_clear(), SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE0_PORT, SPI_SELECT_SLAVE1_PIN, SPI_SELECT_SLAVE1_PORT, SPI_SELECT_SLAVE2_PIN, SPI_SELECT_SLAVE2_PORT, SPI_SELECT_SLAVE3_PIN, SPI_SELECT_SLAVE3_PORT, SPI_SELECT_SLAVE4_PIN, SPI_SELECT_SLAVE4_PORT, SPI_SELECT_SLAVE5_PIN, SPI_SELECT_SLAVE5_PORT, and SpiSlaveSelect().
void spi_slave_unselect | ( | uint8_t | slave | ) |
Unselect a slave.
slave | slave id |
Unselect a slave.
Definition at line 623 of file spi_arch.c.
References gpio_set(), SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE0_PORT, SPI_SELECT_SLAVE1_PIN, SPI_SELECT_SLAVE1_PORT, SPI_SELECT_SLAVE2_PIN, SPI_SELECT_SLAVE2_PORT, SPI_SELECT_SLAVE3_PIN, SPI_SELECT_SLAVE3_PORT, SPI_SELECT_SLAVE4_PIN, SPI_SELECT_SLAVE4_PORT, SPI_SELECT_SLAVE5_PIN, SPI_SELECT_SLAVE5_PORT, and SpiSlaveUnselect().
Referenced by max1168_event(), and spi_init_slaves().
bool spi_slave_wait | ( | struct spi_periph * | p | ) |
Initialized and wait for the next transaction.
If a transaction is registered for this peripheral, the spi will be waiting for a communication from the master
p | spi peripheral to be used |
bool spi_submit | ( | struct spi_periph * | p, |
struct spi_transaction * | t | ||
) |
Submit a spi transaction.
Must be implemented by the underlying architecture
p | spi peripheral to be used |
t | spi transaction |
Submit a spi transaction.
Interafces Paparazzi SPI code with ChibiOS SPI driver. The transaction length is max(rx,tx), before and after callbacks are called accordingly.
ChibiOS doesn't provide error checking for the SPI transactions, since all spi functions are return void. The SPI transaction is synchronous, so we always assume success if the transaction finishes.
There is no explicit timeout on SPI transaction. TODO: Timeout on SPI trans and error detection.
[in] | p | pointer to a spi_periph struct |
[in] | t | pointer to a spi_transaction struct |
Definition at line 533 of file spi_arch.c.
References spi_transaction::dss, FALSE, fd, idx, if(), spi_transaction::input_buf, spi_transaction::input_length, spi_transaction::output_buf, spi_transaction::output_length, p, spi_transaction::select, spi_arch_int_disable(), spi_arch_int_enable(), spi_start_dma_transaction(), SPI_TRANSACTION_QUEUE_LEN, SPIDss16bit, SPIIdle, SPISelectUnselect, SPITransFailed, SPITransPending, SPITransSuccess, SPIUnselect, spi_transaction::status, and TRUE.
Referenced by ads1220_configure(), ads1220_read(), ads1220_send_config(), adxl345_spi_read(), adxl345_spi_write_to_reg(), bmp280_register_read(), bmp280_register_write(), cyrf6936_read_block(), cyrf6936_write_block(), eeprom25AA256_read(), high_speed_logger_direct_memory_init(), high_speed_logger_spi_link_periodic(), ins_configure(), invensense2_register_read(), invensense2_register_write(), invensense2_select_bank(), invensense3_register_read(), invensense3_register_write(), invensense3_select_bank(), l3gd20_spi_read(), l3gd20_spi_send_config(), l3gd20_spi_write_to_reg(), lis302dl_spi_read(), lis302dl_spi_send_config(), lis302dl_spi_write_to_reg(), lsm303d_spi_read(), lsm303d_spi_send_config(), lsm303d_spi_tx_reg(), max1168_read(), max7456_event(), max7456_periodic(), mcp355x_read(), memory_completly_erase(), memory_erase_4k(), memory_read_id(), memory_read_status_1(), memory_read_values(), memory_send_wrdi(), memory_send_wren(), memory_write_values(), mpu60x0_spi_read(), mpu60x0_spi_start_configure(), mpu60x0_spi_write_to_reg(), mpu9250_spi_read(), mpu9250_spi_start_configure(), mpu9250_spi_write_to_reg(), mpu_wait_slave4_ready(), ms2100_event(), ms2100_read(), ms5611_spi_event(), ms5611_spi_periodic_check(), ms5611_spi_start_configure(), ms5611_spi_start_conversion(), osd_put_s(), readRegister_nonblocking(), rxSpiReadCommandMulti(), rxSpiWriteCommandMulti(), sdcard_spi_multiwrite_next(), sdcard_spi_multiwrite_stop(), sdcard_spi_periodic(), sdcard_spi_request_bytes(), sdcard_spi_send_app_cmd(), sdcard_spi_send_cmd(), sdcard_spi_spicallback(), sonar_bebop_read(), spi_blocking_transceive(), sst25vfxxxx_after_cb(), sst25vfxxxx_block_write_en(), sst25vfxxxx_chip_erase(), sst25vfxxxx_read(), sst25vfxxxx_read_id(), sst25vfxxxx_write(), vn100_periodic_task(), w5100_get(), and w5100_set().
|
extern |
Definition at line 1 of file spi.c.
Referenced by sonar_bebop_read(), spi0_arch_init(), and spi0_init().
|
extern |
receive transferred over DMA
transmit transferred over DMA
Definition at line 967 of file spi_arch.c.
Referenced by imu_px4fmu_init(), mcp355x_read(), qr_code_spi_link_init(), qr_code_spi_link_periodic(), spi1_arch_init(), and spi1_init().
|
extern |
receive transferred over DMA
transmit transferred over DMA
Definition at line 1004 of file spi_arch.c.
Referenced by spi2_arch_init(), and spi2_init().