InES Hardware Abstraction Layer
hal_spi.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * -- _____ ______ _____ -
3  * -- |_ _| | ____|/ ____| -
4  * -- | | _ __ | |__ | (___ Institute of Embedded Systems -
5  * -- | | | '_ \| __| \___ \ Zurich University of -
6  * -- _| |_| | | | |____ ____) | Applied Sciences -
7  * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
8  * ------------------------------------------------------------------------- */
18 /* Re-definition guard */
19 #ifndef _HAL_SPI_H
20 #define _HAL_SPI_H
21 
22 /* Removing weak tag for gcc usage*/
23 #ifdef TESTING
24  #define __weak
25 #endif
26 
27 
28 /* User includes */
29 #include "reg_stm32f4xx.h"
30 #include "hal_common.h"
31 
32 
33 /* -- Type definitions
34  * ------------------------------------------------------------------------- */
35 
40  typedef enum {
41  HAL_SPI_MODE_SLAVE = 0x0,
44 
45 
50  typedef enum {
51  HAL_SPI_DIR_BOTH = 0x0,
54  } hal_spi_dir_t;
55 
56 
61  typedef enum {
62  HAL_SPI_SIZE_8B = 0u,
65 
66 
71  typedef enum {
72  HAL_SPI_NSS_HW = 0x0,
74  } hal_spi_nss_t;
75 
76 
81  typedef enum {
82  HAL_SPI_PRE_2 = 0u,
91 
92 
97  typedef enum {
98  HAL_SPI_FRAME_MOTOROLLA = 0x0,
100  } hal_spi_frame_t;
101 
102 
107 typedef struct {
116 
117 
118 /* -- Public function declarations
119  * ------------------------------------------------------------------------- */
120 
125 void hal_spi_reset(reg_spi_t *spi)
126 __attribute__((deprecated("Please use SPIx_RESET().")));
127 
133 void hal_spi_init(reg_spi_t *spi, hal_spi_init_t init);
134 
141 uint8_t hal_spi_read_write(reg_spi_t *spi, uint8_t write_byte);
142 
143 
144 #endif
void hal_spi_reset(reg_spi_t *spi) __attribute__((deprecated("Please use SPIx_RESET().")))
Resets spi to default values.
Definition: hal_spi.h:84
hal_spi_mode_t
Controller mode.
Definition: hal_spi.h:40
Definition: hal_spi.h:63
void hal_spi_init(reg_spi_t *spi, hal_spi_init_t init)
Initializes the specified serial peripheral interface.
Definition: hal_spi.h:73
Definition: hal_spi.h:89
Registries for STM32F4xx.
hal_bool_t hw_crc
Definition: hal_spi.h:114
Definition: hal_spi.h:88
Definition: hal_spi.h:83
hal_spi_mode_t mode
Definition: hal_spi.h:108
Representation of SPI register.
Definition: reg_stm32f4xx.h:1354
Definition: hal_spi.h:52
uint8_t hal_spi_read_write(reg_spi_t *spi, uint8_t write_byte)
Start specified SPI.
hal_spi_dir_t
Transfer direction.
Definition: hal_spi.h:50
hal_spi_size_t
Size of the data frame.
Definition: hal_spi.h:61
Definition: hal_spi.h:86
hal_spi_size_t data_size
Definition: hal_spi.h:110
Common #defines and typedefs.
Initialization structure for the serial peripheral interface.
Definition: hal_spi.h:107
hal_spi_nss_t
Control of slave select pin.
Definition: hal_spi.h:71
hal_spi_frame_t
Defines SPI frame format.
Definition: hal_spi.h:97
Definition: hal_spi.h:87
hal_spi_prescaler_t
Baude rate control.
Definition: hal_spi.h:81
Definition: hal_spi.h:42
Definition: hal_spi.h:99
hal_bool_t
Often used TRUE / FALSE type.
Definition: hal_common.h:31
hal_spi_prescaler_t prescaler
Definition: hal_spi.h:112
hal_spi_frame_t frame_type
Definition: hal_spi.h:113
hal_spi_dir_t direction
Definition: hal_spi.h:109
hal_spi_nss_t nss_mode
Definition: hal_spi.h:111
Definition: hal_spi.h:53
Definition: hal_spi.h:85