ChibiOS/HAL 9.0.0
hal_spi_v2_lld.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_spi_v2_lld.h
19 * @brief PLATFORM SPI (v2) subsystem low level driver header.
20 *
21 * @addtogroup SPI_V2
22 * @{
23 */
24
25#ifndef HAL_SPI_V2_LLD_H
26#define HAL_SPI_V2_LLD_H
27
28#if HAL_USE_SPI || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @brief Circular mode support flag.
36 */
37#define SPI_SUPPORTS_CIRCULAR TRUE
38
39/**
40 * @brief Slave mode support flag.
41 */
42#define SPI_SUPPORTS_SLAVE_MODE TRUE
43
44/*===========================================================================*/
45/* Driver pre-compile time settings. */
46/*===========================================================================*/
47
48/**
49 * @name PLATFORM configuration options
50 * @{
51 */
52/**
53 * @brief SPI1 driver enable switch.
54 * @details If set to @p TRUE the support for SPI1 is included.
55 * @note The default is @p FALSE.
56 */
57#if !defined(PLATFORM_SPI_USE_SPI1) || defined(__DOXYGEN__)
58#define PLATFORM_SPI_USE_SPI1 FALSE
59#endif
60/** @} */
61
62/*===========================================================================*/
63/* Derived constants and error checks. */
64/*===========================================================================*/
65
66/*===========================================================================*/
67/* Driver data structures and types. */
68/*===========================================================================*/
69
70/*===========================================================================*/
71/* Driver macros. */
72/*===========================================================================*/
73
74/**
75 * @brief Low level fields of the SPI driver structure.
76 */
77#define spi_lld_driver_fields \
78 /* Dummy field, it is not needed.*/ \
79 uint32_t dummy;
80
81/**
82 * @brief Low level fields of the SPI configuration structure.
83 */
84#define spi_lld_config_fields \
85 /* Dummy configuration, it is not needed.*/ \
86 uint32_t dummy;
87
88/*===========================================================================*/
89/* External declarations. */
90/*===========================================================================*/
91
92#if (PLATFORM_SPI_USE_SPI1 == TRUE) && !defined(__DOXYGEN__)
93extern SPIDriver SPID1;
94#endif
95
96#ifdef __cplusplus
97extern "C" {
98#endif
99 void spi_lld_init(void);
101 void spi_lld_stop(SPIDriver *spip);
102#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LLD) || defined(__DOXYGEN__)
103 void spi_lld_select(SPIDriver *spip);
104 void spi_lld_unselect(SPIDriver *spip);
105#endif
106 msg_t spi_lld_ignore(SPIDriver *spip, size_t n);
107 msg_t spi_lld_exchange(SPIDriver *spip, size_t n,
108 const void *txbuf, void *rxbuf);
109 msg_t spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf);
110 msg_t spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);
111 msg_t spi_lld_stop_transfer(SPIDriver *spip, size_t *sizep);
112 uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame);
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* HAL_USE_SPI */
118
119#endif /* HAL_SPI_V2_LLD_H */
120
121/** @} */
int32_t msg_t
Type of a message.
Definition osal.h:159
void spi_lld_ignore(SPIDriver *spip, size_t n)
Ignores data on the SPI bus.
SPIDriver SPID1
SPI1 driver identifier.
Definition hal_spi_lld.c:41
void spi_lld_select(SPIDriver *spip)
Asserts the slave select signal and prepares for transfers.
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf)
Receives data from the SPI bus.
void spi_lld_init(void)
Low level SPI driver initialization.
Definition hal_spi_lld.c:65
void spi_lld_exchange(SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf)
Exchanges data on the SPI bus.
void spi_lld_stop(SPIDriver *spip)
Deactivates the SPI peripheral.
void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf)
Sends data over the SPI bus.
struct hal_spi_driver SPIDriver
Type of a structure representing an SPI driver.
Definition hal_spi_v1.h:117
uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame)
Exchanges one frame using a polled wait.
void spi_lld_start(SPIDriver *spip)
Configures and activates the SPI peripheral.
Definition hal_spi_lld.c:80
void spi_lld_unselect(SPIDriver *spip)
Deasserts the slave select signal.
msg_t spi_lld_stop_transfer(SPIDriver *spip, size_t *sizep)
Aborts the ongoing SPI operation, if any.