ChibiOS/HAL  7.0.3
hal_spi_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_lld.h
19  * @brief PLATFORM SPI subsystem low level driver header.
20  *
21  * @addtogroup SPI
22  * @{
23  */
24 
25 #ifndef HAL_SPI_LLD_H
26 #define HAL_SPI_LLD_H
27 
28 #if (HAL_USE_SPI == TRUE) || 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 /* Driver pre-compile time settings. */
41 /*===========================================================================*/
42 
43 /**
44  * @name PLATFORM configuration options
45  * @{
46  */
47 /**
48  * @brief SPI1 driver enable switch.
49  * @details If set to @p TRUE the support for SPI1 is included.
50  * @note The default is @p FALSE.
51  */
52 #if !defined(PLATFORM_SPI_USE_SPI1) || defined(__DOXYGEN__)
53 #define PLATFORM_SPI_USE_SPI1 FALSE
54 #endif
55 /** @} */
56 
57 /*===========================================================================*/
58 /* Derived constants and error checks. */
59 /*===========================================================================*/
60 
61 /*===========================================================================*/
62 /* Driver data structures and types. */
63 /*===========================================================================*/
64 
65 /*===========================================================================*/
66 /* Driver macros. */
67 /*===========================================================================*/
68 
69 /**
70  * @brief Low level fields of the SPI driver structure.
71  */
72 #define spi_lld_driver_fields \
73  /* Dummy field, it is not needed.*/ \
74  uint32_t dummy
75 
76 /**
77  * @brief Low level fields of the SPI configuration structure.
78  */
79 #define spi_lld_config_fields \
80  /* Dummy configuration, it is not needed.*/ \
81  uint32_t dummy
82 
83 /*===========================================================================*/
84 /* External declarations. */
85 /*===========================================================================*/
86 
87 #if (PLATFORM_SPI_USE_SPI1 == TRUE) && !defined(__DOXYGEN__)
88 extern SPIDriver SPID1;
89 #endif
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94  void spi_lld_init(void);
95  void spi_lld_start(SPIDriver *spip);
96  void spi_lld_stop(SPIDriver *spip);
97 #if (SPI_SELECT_MODE == SPI_SELECT_MODE_LLD) || defined(__DOXYGEN__)
98  void spi_lld_select(SPIDriver *spip);
99  void spi_lld_unselect(SPIDriver *spip);
100 #endif
101  void spi_lld_select(SPIDriver *spip);
102  void spi_lld_unselect(SPIDriver *spip);
103  void spi_lld_ignore(SPIDriver *spip, size_t n);
104  void spi_lld_exchange(SPIDriver *spip, size_t n,
105  const void *txbuf, void *rxbuf);
106  void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf);
107  void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);
108 #if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
109  void spi_lld_abort(SPIDriver *spip);
110 #endif
111  uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame);
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* HAL_USE_SPI == TRUE */
117 
118 #endif /* HAL_SPI_LLD_H */
119 
120 /** @} */
void spi_lld_ignore(SPIDriver *spip, size_t n)
Ignores data on the SPI bus.
Definition: hal_spi_lld.c:151
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf)
Receives data from the SPI bus.
Definition: hal_spi_lld.c:217
void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf)
Sends data over the SPI bus.
Definition: hal_spi_lld.c:196
Structure representing an SPI driver.
Definition: hal_spi.h:192
void spi_lld_exchange(SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf)
Exchanges data on the SPI bus.
Definition: hal_spi_lld.c:173
void spi_lld_stop(SPIDriver *spip)
Deactivates the SPI peripheral.
Definition: hal_spi_lld.c:101
void spi_lld_abort(SPIDriver *spip)
Aborts the ongoing SPI operation, if any.
Definition: hal_spi_lld.c:233
void spi_lld_start(SPIDriver *spip)
Configures and activates the SPI peripheral.
Definition: hal_spi_lld.c:80
void spi_lld_init(void)
Low level SPI driver initialization.
Definition: hal_spi_lld.c:65
void spi_lld_unselect(SPIDriver *spip)
Deasserts the slave select signal.
Definition: hal_spi_lld.c:134
uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame)
Exchanges one frame using a polled wait.
Definition: hal_spi_lld.c:253
void spi_lld_select(SPIDriver *spip)
Asserts the slave select signal and prepares for transfers.
Definition: hal_spi_lld.c:120
SPIDriver SPID1
SPI1 driver identifier.
Definition: hal_spi_lld.c:41