Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
spi_arch.c File Reference

Implementation of SPI interface for ChibiOS arch. More...

#include "mcu_periph/spi.h"
#include "mcu_periph/gpio.h"
+ Include dependency graph for spi_arch.c:

Go to the source code of this file.

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 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, 1024)
 
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, 1024)
 
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...
 

Detailed Description

Implementation of SPI interface for ChibiOS arch.

Only Master mode is allowed in ChibiOS.

Definition in file spi_arch.c.

Function Documentation

static SEMAPHORE_DECL ( spi1_sem  ,
 
)
static

Configure SPI peripherals.

static SEMAPHORE_DECL ( spi2_sem  ,
 
)
static
static uint16_t spi_resolve_CR1 ( struct spi_transaction t)
inlinestatic

Resolve CR1.

Given the transaction settings, returns the right configuration of SPIx_CR1 register.

This function is currently architecture dependent (for STM32F1xx and STM32F4xx only) TODO: extend for other architectures too

Parameters
[in]tpointer to a spi_transaction struct

Definition at line 148 of file spi_arch.c.

References spi_transaction::bitorder, spi_transaction::cdiv, spi_transaction::cpha, spi_transaction::cpol, spi_transaction::dss, SPICphaEdge2, SPICpolIdleHigh, SPIDiv128, SPIDiv16, SPIDiv2, SPIDiv256, SPIDiv32, SPIDiv4, SPIDiv64, SPIDiv8, SPIDss16bit, and SPILSBFirst.

Referenced by handle_spi_thd().

+ Here is the caller graph for this function:

static uint16_t spi_resolve_slave_pin ( uint8_t  slave)
inlinestatic

Resolve slave pin.

Given the slave number and the board config file, returns the right pin (i.e. 12)

Parameters
[in]slaveindex number of a slave

Definition at line 97 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().

+ Here is the caller graph for this function:

static ioportid_t spi_resolve_slave_port ( uint8_t  slave)
inlinestatic

Resolve slave port.

Given the slave number and the board config file, returns the right port (i.e. GPIOC)

Parameters
[in]slaveindex number of a slave

Definition at line 50 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().

+ Here is the caller graph for this function:

static void thd_spi1 ( void *  arg)
static

Definition at line 276 of file spi_arch.c.

References handle_spi_thd(), spi1, and TRUE.

Referenced by spi1_arch_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void thd_spi2 ( void *  arg)
static

Definition at line 300 of file spi_arch.c.

References handle_spi_thd(), spi2, and TRUE.

Referenced by spi2_arch_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static THD_WORKING_AREA ( wa_thd_spi1  ,
1024   
)
static
static THD_WORKING_AREA ( wa_thd_spi2  ,
1024   
)
static