ARMEBS4  revision-26.06.2015
stm32_spi.h
Go to the documentation of this file.
1 /************************************************************************//**
2  * \file heivs/stm32_spi.h
3  * \brief SPI bus
4  * \author marc dot pignat at hevs dot ch
5  *
6  * \defgroup spi_bus SPI bus
7  * @{
8  * \brief SPI (Serial Peripheral Interface) bus.
9  * \ingroup bus
10  *
11  * \warning At this time only the master functionality of the bus is
12  * implemented.
13  ***************************************************************************/
14 #ifndef HEIVS_STM32_SPI_H
15 #define HEIVS_STM32_SPI_H
16 
17 #include "heivs/bus.h"
18 #include "heivs/stm32_gpio.h"
19 #include "heivs/bsp.h"
20 
21 /**
22  * \brief SPI specific options
23  */
25 {
26  SPI_OPTION_MASTER = (0<< 1), ///< Master mode
27  SPI_OPTION_SLAVE = (1<< 1), ///< Slave mode \warning Not yet implemented
28 
29  SPI_OPTION_MODE_0 = (0<< 2), ///< Mode 0 : CPOL = 0, CPHA = 0
30  SPI_OPTION_MODE_1 = (1<< 2), ///< Mode 1 : CPOL = 0, CPHA = 1
31  SPI_OPTION_MODE_2 = (2<< 2), ///< Mode 2 : CPOL = 1, CPHA = 0
32  SPI_OPTION_MODE_3 = (3<< 2), ///< Mode 3 : CPOL = 1, CPHA = 1
33 
34  SPI_OPTION_CS_LOW = (0<< 4), ///< Chip select active low
35  SPI_OPTION_CS_HIGH = (1<< 4), ///< Chip select active high
36 };
37 
38 /**
39  * \brief SPI specific data
40  */
42 {
43  SPI_TypeDef *ctrl; ///< Controller
44  const struct gpio_t gpios[4]; ///< Gpios
45  enum spi_option_e options; ///< Options
46 };
47 
48 #ifdef __cplusplus
49  extern "C" {
50 #endif
51 
52 /**
53  * \brief All SPI busses
54  */
55 extern const struct heivs_bus_t bus_spi[BSP_SPI_BUS_COUNT];
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 /**
62  * @}
63  */
64 #endif /* HEIVS_STM32_SPI_H */
bus abstraction
SPI_TypeDef * ctrl
Controller.
Definition: stm32_spi.h:43
Bus handler.
Definition: bus.h:92
BSP - Board Support Package.
enum spi_option_e options
Options.
Definition: stm32_spi.h:45
Master mode.
Definition: stm32_spi.h:26
Serial Peripheral Interface.
Definition: stm32f4xx.h:836
Mode 3 : CPOL = 1, CPHA = 1.
Definition: stm32_spi.h:32
Mode 2 : CPOL = 1, CPHA = 0.
Definition: stm32_spi.h:31
board specific defines
GPIO control structure.
Definition: stm32_gpio.h:96
const struct gpio_t gpios[4]
Gpios.
Definition: stm32_spi.h:44
Chip select active high.
Definition: stm32_spi.h:35
Mode 0 : CPOL = 0, CPHA = 0.
Definition: stm32_spi.h:29
SPI specific data.
Definition: stm32_spi.h:41
Slave mode.
Definition: stm32_spi.h:27
spi_option_e
SPI specific options.
Definition: stm32_spi.h:24
Chip select active low.
Definition: stm32_spi.h:34
Mode 1 : CPOL = 0, CPHA = 1.
Definition: stm32_spi.h:30