Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "mcu_periph/spi.h"
#include "mcu_periph/gpio.h"
#include <BOARD_CONFIG>
#include <string.h>
#include "mcu_periph/ram_arch.h"
Go to the source code of this file.
Data Structures | |
struct | spi_init |
Macros | |
#define | SPI_THREAD_STACK_SIZE 512 |
#define | SPI_DMA_BUF_LEN 512 |
Functions | |
static ioportid_t | spi_resolve_slave_port (uint8_t slave) |
Resolve slave port. More... | |
static uint16_t | spi_resolve_slave_pin (uint8_t slave) |
Resolve slave pin. More... | |
static uint16_t | spi_resolve_CR1 (struct spi_transaction *t) |
Resolve CR1. More... | |
static uint16_t | spi_resolve_CR2 (struct spi_transaction *t) |
Resolve CR2. More... | |
static void | handle_spi_thd (struct spi_periph *p) |
main thread function More... | |
static | SEMAPHORE_DECL (spi1_sem, 0) |
Configure SPI peripherals. More... | |
static void | thd_spi1 (void *arg) |
static | THD_WORKING_AREA (wa_thd_spi1, SPI_THREAD_STACK_SIZE) |
void | spi1_arch_init (void) |
Architecture dependent SPI1 initialization. More... | |
static | SEMAPHORE_DECL (spi2_sem, 0) |
static void | thd_spi2 (void *arg) |
static | THD_WORKING_AREA (wa_thd_spi2, SPI_THREAD_STACK_SIZE) |
void | spi2_arch_init (void) |
Architecture dependent SPI2 initialization. More... | |
bool | spi_submit (struct spi_periph *p, struct spi_transaction *t) |
Submit SPI transaction. More... | |
void | spi_slave_select (uint8_t slave) |
spi_slave_select() function More... | |
void | spi_slave_unselect (uint8_t slave) |
spi_slave_unselect() function More... | |
bool | spi_lock (struct spi_periph *p, uint8_t slave) |
spi_lock() function More... | |
bool | spi_resume (struct spi_periph *p, uint8_t slave) |
spi_resume() function More... | |
void | spi_init_slaves (void) |
spi_init_slaves() function More... | |
Variables | |
static struct spi_init | spi1_init_s |
static struct spi_init | spi2_init_s |
Implementation of SPI interface for ChibiOS arch
Only Master mode is allowed in ChibiOS.
Definition in file spi_arch.c.
struct spi_init |
Definition at line 52 of file spi_arch.c.
Data Fields | ||
---|---|---|
semaphore_t * | sem |
#define SPI_DMA_BUF_LEN 512 |
Definition at line 59 of file spi_arch.c.
#define SPI_THREAD_STACK_SIZE 512 |
Definition at line 48 of file spi_arch.c.
|
static |
main thread function
[in] | p | pointer to an i2c peripheral |
Definition at line 247 of file spi_arch.c.
References spi_transaction::after_cb, spi_transaction::before_cb, spi_transaction::input_buf, spi_transaction::input_length, spi_transaction::output_buf, spi_transaction::output_length, p, spi_transaction::select, spi_init::sem, spi_transaction::slave_idx, spi_resolve_CR1(), spi_resolve_CR2(), spi_resolve_slave_pin(), spi_resolve_slave_port(), SPI_TRANSACTION_QUEUE_LEN, SPIIdle, SPIRunning, SPISelect, SPISelectUnselect, SPITransSuccess, SPIUnselect, and spi_transaction::status.
Referenced by thd_spi1(), and thd_spi2().
|
static |
Configure SPI peripherals.
|
static |
|
inlinestatic |
Resolve CR1.
Given the transaction settings, returns the right configuration of SPIx_CR1 register.
This function is currently architecture dependent (for STM32F1xx STM32F4xx and STM32F7xx only) TODO: extend for other architectures too
[in] | t | pointer to a spi_transaction struct |
Definition at line 167 of file spi_arch.c.
References SPICphaEdge2, SPICpolIdleHigh, SPIDiv128, SPIDiv16, SPIDiv2, SPIDiv256, SPIDiv32, SPIDiv4, SPIDiv64, SPIDiv8, SPIDss16bit, and SPILSBFirst.
Referenced by handle_spi_thd().
|
inlinestatic |
Resolve CR2.
Given the transaction settings, returns the right configuration of SPIx_CR2 register.
This function is currently architecture dependent (for STM32F1xx STM32F4xx and STM32F7xx only) TODO: extend for other architectures too
[in] | t | pointer to a spi_transaction struct |
Definition at line 229 of file spi_arch.c.
References SPIDss16bit.
Referenced by handle_spi_thd().
Resolve slave pin.
Given the slave number and the board config file, returns the right pin (i.e. 12)
[in] | slave | index number of a slave |
Definition at line 116 of file spi_arch.c.
References SPI_SELECT_SLAVE0_PIN, SPI_SELECT_SLAVE1_PIN, SPI_SELECT_SLAVE2_PIN, SPI_SELECT_SLAVE3_PIN, SPI_SELECT_SLAVE4_PIN, and SPI_SELECT_SLAVE5_PIN.
Referenced by handle_spi_thd().
|
inlinestatic |
Resolve slave port.
Given the slave number and the board config file, returns the right port (i.e. GPIOC)
[in] | slave | index number of a slave |
Definition at line 69 of file spi_arch.c.
References SPI_SELECT_SLAVE0_PORT, SPI_SELECT_SLAVE1_PORT, SPI_SELECT_SLAVE2_PORT, SPI_SELECT_SLAVE3_PORT, SPI_SELECT_SLAVE4_PORT, and SPI_SELECT_SLAVE5_PORT.
Referenced by handle_spi_thd().
|
static |
Definition at line 354 of file spi_arch.c.
References handle_spi_thd(), spi1, and TRUE.
Referenced by spi1_arch_init().
|
static |
Definition at line 393 of file spi_arch.c.
References handle_spi_thd(), spi2, and TRUE.
Referenced by spi2_arch_init().
|
static |
|
static |
|
static |
Definition at line 349 of file spi_arch.c.
Referenced by spi1_arch_init().
|
static |
Definition at line 388 of file spi_arch.c.
Referenced by spi2_arch_init().