Loading...
Searching...
No Matches
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
26extern "C" {
27#endif
28
30#define HAL_SPI_MODE0 (SPI_MODE_0)
32#define HAL_SPI_MODE1 (SPI_MODE_1)
34#define HAL_SPI_MODE2 (SPI_MODE_2)
36#define HAL_SPI_MODE3 (SPI_MODE_3)
37
41typedef void (*hal_spi_txrx_cb)(void *arg, int len);
42
53
66int hal_spi_config(int spi_num, struct hal_spi_settings *psettings);
67
83int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg);
84
94int hal_spi_enable(int spi_num);
95
104int hal_spi_disable(int spi_num);
105
129int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt);
130
163int 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 */
spi_clk_t
Definition periph_cpu.h:352
void(* hal_spi_txrx_cb)(void *arg, int len)
Prototype for tx/rx callback.
Definition hal_spi.h:41
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:43
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:47
spi_clk_t baudrate
Baudrate in kHz.
Definition hal_spi.h:51
spi_mode_t data_mode
Data mode of SPI driver, defined by HAL_SPI_MODEn.
Definition hal_spi.h:49