Loading...
Searching...
No Matches
hal_spi.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include "periph/spi.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
26#define HAL_SPI_MODE0 (SPI_MODE_0)
28#define HAL_SPI_MODE1 (SPI_MODE_1)
30#define HAL_SPI_MODE2 (SPI_MODE_2)
32#define HAL_SPI_MODE3 (SPI_MODE_3)
33
37typedef void (*hal_spi_txrx_cb)(void *arg, int len);
38
49
62int hal_spi_config(int spi_num, struct hal_spi_settings *psettings);
63
79int hal_spi_set_txrx_cb(int spi_num, hal_spi_txrx_cb txrx_cb, void *arg);
80
90int hal_spi_enable(int spi_num);
91
100int hal_spi_disable(int spi_num);
101
125int hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int cnt);
126
159int hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int cnt);
160
161#ifdef __cplusplus
162}
163#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:37
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:43
spi_clk_t baudrate
Baudrate in kHz.
Definition hal_spi.h:47
spi_mode_t data_mode
Data mode of SPI driver, defined by HAL_SPI_MODEn.
Definition hal_spi.h:45