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 
9 #pragma once
10 
22 #include "periph/spi.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
29 #define HAL_SPI_MODE0 (SPI_MODE_0)
31 #define HAL_SPI_MODE1 (SPI_MODE_1)
33 #define HAL_SPI_MODE2 (SPI_MODE_2)
35 #define HAL_SPI_MODE3 (SPI_MODE_3)
36 
40 typedef void (*hal_spi_txrx_cb)(void *arg, int len);
41 
51 };
52 
65 int hal_spi_config(int spi_num, struct hal_spi_settings *psettings);
66 
82 int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg);
83 
93 int hal_spi_enable(int spi_num);
94 
103 int hal_spi_disable(int spi_num);
104 
128 int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt);
129 
162 int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt);
163 
164 #ifdef __cplusplus
165 }
166 #endif
spi_clk_t
Definition: periph_cpu.h:348
void(* hal_spi_txrx_cb)(void *arg, int len)
Prototype for tx/rx callback.
Definition: hal_spi.h:40
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.
int hal_spi_config(int spi_num, struct hal_spi_settings *psettings)
Configure the spi.
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...
int hal_spi_enable(int spi_num)
Enables the SPI.
int hal_spi_disable(int spi_num)
Disables the SPI.
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.
spi_mode_t
Support SPI modes.
Definition: periph_cpu.h:39
Low-level SPI peripheral driver interface definition.
since one spi device can control multiple devices, some configuration can be changed on the fly from ...
Definition: hal_spi.h:46
spi_clk_t baudrate
Baudrate in kHz.
Definition: hal_spi.h:50
spi_mode_t data_mode
Data mode of SPI driver, defined by HAL_SPI_MODEn.
Definition: hal_spi.h:48