hal_spi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef HAL_HAL_SPI_H
21 #define HAL_HAL_SPI_H
22 
23 #include "periph/spi.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
30 #define HAL_SPI_MODE0 (SPI_MODE_0)
31 
32 #define HAL_SPI_MODE1 (SPI_MODE_1)
33 
34 #define HAL_SPI_MODE2 (SPI_MODE_2)
35 
36 #define HAL_SPI_MODE3 (SPI_MODE_3)
37 
41 typedef void (*hal_spi_txrx_cb)(void *arg, int len);
42 
52 };
53 
66 int hal_spi_config(int spi_num, struct hal_spi_settings *psettings);
67 
83 int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg);
84 
94 int hal_spi_enable(int spi_num);
95 
104 int hal_spi_disable(int spi_num);
105 
129 int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt);
130 
163 int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* HAL_HAL_SPI_H */
hal_spi_enable
int hal_spi_enable(int spi_num)
Enables the SPI.
spi.h
Low-level SPI peripheral driver interface definition.
hal_spi_txrx_noblock
int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt)
Non-blocking interface to send a buffer and store received values.
hal_spi_txrx
int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt)
Blocking interface to send a buffer and store the received values from the slave.
spi_mode_t
spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
Definition: spi.h:157
spi_clk_t
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
hal_spi_txrx_cb
void(* hal_spi_txrx_cb)(void *arg, int len)
Prototype for tx/rx callback.
Definition: hal_spi.h:41
hal_spi_settings
since one spi device can control multiple devices, some configuration can be changed on the fly from ...
Definition: hal_spi.h:47
hal_spi_set_txrx_cb
int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg)
Sets the txrx callback (executed at interrupt context) when the buffer is transferred by the master o...
hal_spi_disable
int hal_spi_disable(int spi_num)
Disables the SPI.
hal_spi_settings::data_mode
spi_mode_t data_mode
Data mode of SPI driver, defined by HAL_SPI_MODEn.
Definition: hal_spi.h:49
hal_spi_config
int hal_spi_config(int spi_num, struct hal_spi_settings *psettings)
Configure the spi.
hal_spi_settings::baudrate
spi_clk_t baudrate
Baudrate in kHz.
Definition: hal_spi.h:51