Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 9 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief Header file of SPI HAL module. |
5 | * @brief Header file of SPI HAL module. |
| 6 | ****************************************************************************** |
6 | ****************************************************************************** |
| 7 | * @attention |
7 | * @attention |
| 8 | * |
8 | * |
| 9 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
| - | 10 | * All rights reserved.</center></h2> |
|
| 10 | * |
11 | * |
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
| 12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
| 13 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
| 14 | * this list of conditions and the following disclaimer. |
- | |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
| 16 | * this list of conditions and the following disclaimer in the documentation |
- | |
| 17 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
| 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
| 19 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
| 20 | * without specific prior written permission. |
- | |
| 21 | * |
- | |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
| 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
| 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
| 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
| 32 | * |
16 | * |
| 33 | ****************************************************************************** |
17 | ****************************************************************************** |
| 34 | */ |
18 | */ |
| 35 | 19 | ||
| 36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| 37 | #ifndef __STM32F1xx_HAL_SPI_H |
21 | #ifndef STM32F1xx_HAL_SPI_H |
| 38 | #define __STM32F1xx_HAL_SPI_H |
22 | #define STM32F1xx_HAL_SPI_H |
| 39 | 23 | ||
| 40 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
| 41 | extern "C" { |
25 | extern "C" { |
| 42 | #endif |
26 | #endif |
| 43 | 27 | ||
| 44 | /* Includes ------------------------------------------------------------------*/ |
28 | /* Includes ------------------------------------------------------------------*/ |
| 45 | #include "stm32f1xx_hal_def.h" |
29 | #include "stm32f1xx_hal_def.h" |
| 46 | 30 | ||
| 47 | /** @addtogroup STM32F1xx_HAL_Driver |
31 | /** @addtogroup STM32F1xx_HAL_Driver |
| 48 | * @{ |
32 | * @{ |
| 49 | */ |
33 | */ |
| 50 | 34 | ||
| Line 60... | Line 44... | ||
| 60 | /** |
44 | /** |
| 61 | * @brief SPI Configuration Structure definition |
45 | * @brief SPI Configuration Structure definition |
| 62 | */ |
46 | */ |
| 63 | typedef struct |
47 | typedef struct |
| 64 | { |
48 | { |
| 65 | uint32_t Mode; /*!< Specifies the SPI operating mode. |
49 | uint32_t Mode; /*!< Specifies the SPI operating mode. |
| 66 | This parameter can be a value of @ref SPI_Mode */ |
50 | This parameter can be a value of @ref SPI_Mode */ |
| 67 | 51 | ||
| 68 | uint32_t Direction; /*!< Specifies the SPI Directional mode state. |
52 | uint32_t Direction; /*!< Specifies the SPI bidirectional mode state. |
| 69 | This parameter can be a value of @ref SPI_Direction */ |
53 | This parameter can be a value of @ref SPI_Direction */ |
| 70 | 54 | ||
| 71 | uint32_t DataSize; /*!< Specifies the SPI data size. |
55 | uint32_t DataSize; /*!< Specifies the SPI data size. |
| 72 | This parameter can be a value of @ref SPI_Data_Size */ |
56 | This parameter can be a value of @ref SPI_Data_Size */ |
| 73 | 57 | ||
| 74 | uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. |
58 | uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. |
| 75 | This parameter can be a value of @ref SPI_Clock_Polarity */ |
59 | This parameter can be a value of @ref SPI_Clock_Polarity */ |
| 76 | 60 | ||
| 77 | uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. |
61 | uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. |
| 78 | This parameter can be a value of @ref SPI_Clock_Phase */ |
62 | This parameter can be a value of @ref SPI_Clock_Phase */ |
| 79 | 63 | ||
| 80 | uint32_t NSS; /*!< Specifies whether the NSS signal is managed by |
64 | uint32_t NSS; /*!< Specifies whether the NSS signal is managed by |
| 81 | hardware (NSS pin) or by software using the SSI bit. |
65 | hardware (NSS pin) or by software using the SSI bit. |
| 82 | This parameter can be a value of @ref SPI_Slave_Select_management */ |
66 | This parameter can be a value of @ref SPI_Slave_Select_management */ |
| 83 | 67 | ||
| 84 | uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be |
68 | uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be |
| 85 | used to configure the transmit and receive SCK clock. |
69 | used to configure the transmit and receive SCK clock. |
| 86 | This parameter can be a value of @ref SPI_BaudRate_Prescaler |
70 | This parameter can be a value of @ref SPI_BaudRate_Prescaler |
| 87 | @note The communication clock is derived from the master |
71 | @note The communication clock is derived from the master |
| 88 | clock. The slave clock does not need to be set. */ |
72 | clock. The slave clock does not need to be set. */ |
| 89 | 73 | ||
| 90 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
74 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
| 91 | This parameter can be a value of @ref SPI_MSB_LSB_transmission */ |
75 | This parameter can be a value of @ref SPI_MSB_LSB_transmission */ |
| 92 | 76 | ||
| 93 | uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. |
77 | uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. |
| 94 | This parameter can be a value of @ref SPI_TI_mode */ |
78 | This parameter can be a value of @ref SPI_TI_mode */ |
| 95 | 79 | ||
| 96 | uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. |
80 | uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. |
| 97 | This parameter can be a value of @ref SPI_CRC_Calculation */ |
81 | This parameter can be a value of @ref SPI_CRC_Calculation */ |
| 98 | 82 | ||
| 99 | uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. |
83 | uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. |
| 100 | This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */ |
84 | This parameter must be an odd number between Min_Data = 1 and Max_Data = 65535 */ |
| 101 | }SPI_InitTypeDef; |
85 | } SPI_InitTypeDef; |
| 102 | 86 | ||
| 103 | /** |
87 | /** |
| 104 | * @brief HAL SPI State structure definition |
88 | * @brief HAL SPI State structure definition |
| 105 | */ |
89 | */ |
| 106 | typedef enum |
90 | typedef enum |
| Line 109... | Line 93... | ||
| 109 | HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ |
93 | HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ |
| 110 | HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ |
94 | HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ |
| 111 | HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ |
95 | HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ |
| 112 | HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ |
96 | HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ |
| 113 | HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */ |
97 | HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */ |
| 114 | HAL_SPI_STATE_ERROR = 0x06U /*!< SPI error state */ |
98 | HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */ |
| - | 99 | HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */ |
|
| 115 | }HAL_SPI_StateTypeDef; |
100 | } HAL_SPI_StateTypeDef; |
| 116 | 101 | ||
| 117 | /** |
102 | /** |
| 118 | * @brief SPI handle Structure definition |
103 | * @brief SPI handle Structure definition |
| 119 | */ |
104 | */ |
| 120 | typedef struct __SPI_HandleTypeDef |
105 | typedef struct __SPI_HandleTypeDef |
| 121 | { |
106 | { |
| 122 | SPI_TypeDef *Instance; /*!< SPI registers base address */ |
107 | SPI_TypeDef *Instance; /*!< SPI registers base address */ |
| - | 108 | ||
| - | 109 | SPI_InitTypeDef Init; /*!< SPI communication parameters */ |
|
| - | 110 | ||
| - | 111 | uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */ |
|
| 123 | 112 | ||
| 124 | SPI_InitTypeDef Init; /*!< SPI communication parameters */ |
113 | uint16_t TxXferSize; /*!< SPI Tx Transfer size */ |
| 125 | 114 | ||
| 126 | uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */ |
115 | __IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */ |
| 127 | 116 | ||
| 128 | uint16_t TxXferSize; /*!< SPI Tx Transfer size */ |
117 | uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */ |
| 129 | 118 | ||
| 130 | __IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */ |
119 | uint16_t RxXferSize; /*!< SPI Rx Transfer size */ |
| 131 | 120 | ||
| 132 | uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */ |
121 | __IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */ |
| 133 | 122 | ||
| 134 | uint16_t RxXferSize; /*!< SPI Rx Transfer size */ |
123 | void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */ |
| 135 | 124 | ||
| 136 | __IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */ |
125 | void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */ |
| 137 | 126 | ||
| 138 | void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Rx ISR */ |
127 | DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */ |
| 139 | 128 | ||
| 140 | void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Tx ISR */ |
129 | DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */ |
| 141 | 130 | ||
| 142 | DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */ |
131 | HAL_LockTypeDef Lock; /*!< Locking object */ |
| 143 | 132 | ||
| 144 | DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */ |
133 | __IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */ |
| 145 | 134 | ||
| 146 | HAL_LockTypeDef Lock; /*!< Locking object */ |
135 | __IO uint32_t ErrorCode; /*!< SPI Error code */ |
| 147 | 136 | ||
| - | 137 | #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) |
|
| - | 138 | void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */ |
|
| - | 139 | void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */ |
|
| 148 | __IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */ |
140 | void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */ |
| - | 141 | void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */ |
|
| - | 142 | void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */ |
|
| - | 143 | void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */ |
|
| - | 144 | void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */ |
|
| - | 145 | void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */ |
|
| - | 146 | void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */ |
|
| - | 147 | void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */ |
|
| 149 | 148 | ||
| 150 | __IO uint32_t ErrorCode; /*!< SPI Error code */ |
149 | #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ |
| - | 150 | } SPI_HandleTypeDef; |
|
| 151 | 151 | ||
| - | 152 | #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) |
|
| - | 153 | /** |
|
| - | 154 | * @brief HAL SPI Callback ID enumeration definition |
|
| - | 155 | */ |
|
| - | 156 | typedef enum |
|
| - | 157 | { |
|
| - | 158 | HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */ |
|
| - | 159 | HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */ |
|
| - | 160 | HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */ |
|
| - | 161 | HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */ |
|
| - | 162 | HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */ |
|
| - | 163 | HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */ |
|
| - | 164 | HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */ |
|
| - | 165 | HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */ |
|
| - | 166 | HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */ |
|
| - | 167 | HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */ |
|
| - | 168 | ||
| 152 | }SPI_HandleTypeDef; |
169 | } HAL_SPI_CallbackIDTypeDef; |
| - | 170 | ||
| - | 171 | /** |
|
| - | 172 | * @brief HAL SPI Callback pointer definition |
|
| - | 173 | */ |
|
| - | 174 | typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */ |
|
| 153 | 175 | ||
| - | 176 | #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ |
|
| 154 | /** |
177 | /** |
| 155 | * @} |
178 | * @} |
| 156 | */ |
179 | */ |
| 157 | 180 | ||
| 158 | /* Exported constants --------------------------------------------------------*/ |
181 | /* Exported constants --------------------------------------------------------*/ |
| Line 161... | Line 184... | ||
| 161 | */ |
184 | */ |
| 162 | 185 | ||
| 163 | /** @defgroup SPI_Error_Code SPI Error Code |
186 | /** @defgroup SPI_Error_Code SPI Error Code |
| 164 | * @{ |
187 | * @{ |
| 165 | */ |
188 | */ |
| 166 | #define HAL_SPI_ERROR_NONE 0x00000000U /*!< No error */ |
189 | #define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */ |
| 167 | #define HAL_SPI_ERROR_MODF 0x00000001U /*!< MODF error */ |
190 | #define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */ |
| 168 | #define HAL_SPI_ERROR_CRC 0x00000002U /*!< CRC error */ |
191 | #define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */ |
| 169 | #define HAL_SPI_ERROR_OVR 0x00000004U /*!< OVR error */ |
192 | #define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */ |
| 170 | #define HAL_SPI_ERROR_FRE 0x00000008U /*!< FRE error */ |
193 | #define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */ |
| 171 | #define HAL_SPI_ERROR_DMA 0x00000010U /*!< DMA transfer error */ |
194 | #define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY Flag */ |
| 172 | #define HAL_SPI_ERROR_FLAG 0x00000020U /*!< Flag: RXNE,TXE, BSY */ |
195 | #define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */ |
| - | 196 | #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) |
|
| - | 197 | #define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */ |
|
| - | 198 | #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ |
|
| 173 | /** |
199 | /** |
| 174 | * @} |
200 | * @} |
| 175 | */ |
201 | */ |
| 176 | 202 | ||
| 177 | /** @defgroup SPI_Mode SPI Mode |
203 | /** @defgroup SPI_Mode SPI Mode |
| 178 | * @{ |
204 | * @{ |
| 179 | */ |
205 | */ |
| 180 | #define SPI_MODE_SLAVE 0x00000000U |
206 | #define SPI_MODE_SLAVE (0x00000000U) |
| 181 | #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) |
207 | #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) |
| 182 | /** |
208 | /** |
| 183 | * @} |
209 | * @} |
| 184 | */ |
210 | */ |
| 185 | 211 | ||
| 186 | /** @defgroup SPI_Direction SPI Direction Mode |
212 | /** @defgroup SPI_Direction SPI Direction Mode |
| 187 | * @{ |
213 | * @{ |
| 188 | */ |
214 | */ |
| 189 | #define SPI_DIRECTION_2LINES 0x00000000U |
215 | #define SPI_DIRECTION_2LINES (0x00000000U) |
| 190 | #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY |
216 | #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY |
| 191 | #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE |
217 | #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE |
| 192 | /** |
218 | /** |
| 193 | * @} |
219 | * @} |
| 194 | */ |
220 | */ |
| 195 | 221 | ||
| 196 | /** @defgroup SPI_Data_Size SPI Data Size |
222 | /** @defgroup SPI_Data_Size SPI Data Size |
| 197 | * @{ |
223 | * @{ |
| 198 | */ |
224 | */ |
| 199 | #define SPI_DATASIZE_8BIT 0x00000000U |
225 | #define SPI_DATASIZE_8BIT (0x00000000U) |
| 200 | #define SPI_DATASIZE_16BIT SPI_CR1_DFF |
226 | #define SPI_DATASIZE_16BIT SPI_CR1_DFF |
| 201 | /** |
227 | /** |
| 202 | * @} |
228 | * @} |
| 203 | */ |
229 | */ |
| 204 | 230 | ||
| 205 | /** @defgroup SPI_Clock_Polarity SPI Clock Polarity |
231 | /** @defgroup SPI_Clock_Polarity SPI Clock Polarity |
| 206 | * @{ |
232 | * @{ |
| 207 | */ |
233 | */ |
| 208 | #define SPI_POLARITY_LOW 0x00000000U |
234 | #define SPI_POLARITY_LOW (0x00000000U) |
| 209 | #define SPI_POLARITY_HIGH SPI_CR1_CPOL |
235 | #define SPI_POLARITY_HIGH SPI_CR1_CPOL |
| 210 | /** |
236 | /** |
| 211 | * @} |
237 | * @} |
| 212 | */ |
238 | */ |
| 213 | 239 | ||
| 214 | /** @defgroup SPI_Clock_Phase SPI Clock Phase |
240 | /** @defgroup SPI_Clock_Phase SPI Clock Phase |
| 215 | * @{ |
241 | * @{ |
| 216 | */ |
242 | */ |
| 217 | #define SPI_PHASE_1EDGE 0x00000000U |
243 | #define SPI_PHASE_1EDGE (0x00000000U) |
| 218 | #define SPI_PHASE_2EDGE SPI_CR1_CPHA |
244 | #define SPI_PHASE_2EDGE SPI_CR1_CPHA |
| 219 | /** |
245 | /** |
| 220 | * @} |
246 | * @} |
| 221 | */ |
247 | */ |
| 222 | 248 | ||
| 223 | /** @defgroup SPI_Slave_Select_management SPI Slave Select Management |
249 | /** @defgroup SPI_Slave_Select_management SPI Slave Select Management |
| 224 | * @{ |
250 | * @{ |
| 225 | */ |
251 | */ |
| 226 | #define SPI_NSS_SOFT SPI_CR1_SSM |
252 | #define SPI_NSS_SOFT SPI_CR1_SSM |
| 227 | #define SPI_NSS_HARD_INPUT 0x00000000U |
253 | #define SPI_NSS_HARD_INPUT (0x00000000U) |
| 228 | #define SPI_NSS_HARD_OUTPUT ((uint32_t)(SPI_CR2_SSOE << 16)) |
254 | #define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U) |
| 229 | /** |
255 | /** |
| 230 | * @} |
256 | * @} |
| 231 | */ |
257 | */ |
| 232 | 258 | ||
| 233 | /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler |
259 | /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler |
| 234 | * @{ |
260 | * @{ |
| 235 | */ |
261 | */ |
| 236 | #define SPI_BAUDRATEPRESCALER_2 0x00000000U |
262 | #define SPI_BAUDRATEPRESCALER_2 (0x00000000U) |
| 237 | #define SPI_BAUDRATEPRESCALER_4 SPI_CR1_BR_0 |
263 | #define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0) |
| 238 | #define SPI_BAUDRATEPRESCALER_8 SPI_CR1_BR_1 |
264 | #define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1) |
| 239 | #define SPI_BAUDRATEPRESCALER_16 (uint32_t)(SPI_CR1_BR_1 | SPI_CR1_BR_0) |
265 | #define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0) |
| 240 | #define SPI_BAUDRATEPRESCALER_32 SPI_CR1_BR_2 |
266 | #define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2) |
| 241 | #define SPI_BAUDRATEPRESCALER_64 (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_0) |
267 | #define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0) |
| 242 | #define SPI_BAUDRATEPRESCALER_128 (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_1) |
268 | #define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1) |
| 243 | #define SPI_BAUDRATEPRESCALER_256 (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) |
269 | #define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) |
| 244 | - | ||
| 245 | /** |
270 | /** |
| 246 | * @} |
271 | * @} |
| 247 | */ |
272 | */ |
| 248 | 273 | ||
| 249 | /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission |
274 | /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission |
| 250 | * @{ |
275 | * @{ |
| 251 | */ |
276 | */ |
| 252 | #define SPI_FIRSTBIT_MSB 0x00000000U |
277 | #define SPI_FIRSTBIT_MSB (0x00000000U) |
| 253 | #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST |
278 | #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST |
| 254 | /** |
279 | /** |
| 255 | * @} |
280 | * @} |
| 256 | */ |
281 | */ |
| 257 | 282 | ||
| 258 | /** @defgroup SPI_TI_mode SPI TI Mode |
283 | /** @defgroup SPI_TI_mode SPI TI Mode |
| 259 | * @{ |
284 | * @{ |
| 260 | */ |
285 | */ |
| 261 | #define SPI_TIMODE_DISABLE 0x00000000U |
286 | #define SPI_TIMODE_DISABLE (0x00000000U) |
| 262 | /** |
287 | /** |
| 263 | * @} |
288 | * @} |
| 264 | */ |
289 | */ |
| 265 | 290 | ||
| 266 | /** @defgroup SPI_CRC_Calculation SPI CRC Calculation |
291 | /** @defgroup SPI_CRC_Calculation SPI CRC Calculation |
| 267 | * @{ |
292 | * @{ |
| 268 | */ |
293 | */ |
| 269 | #define SPI_CRCCALCULATION_DISABLE 0x00000000U |
294 | #define SPI_CRCCALCULATION_DISABLE (0x00000000U) |
| 270 | #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN |
295 | #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN |
| 271 | /** |
296 | /** |
| 272 | * @} |
297 | * @} |
| 273 | */ |
298 | */ |
| 274 | 299 | ||
| 275 | /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition |
300 | /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition |
| Line 283... | Line 308... | ||
| 283 | */ |
308 | */ |
| 284 | 309 | ||
| 285 | /** @defgroup SPI_Flags_definition SPI Flags Definition |
310 | /** @defgroup SPI_Flags_definition SPI Flags Definition |
| 286 | * @{ |
311 | * @{ |
| 287 | */ |
312 | */ |
| 288 | #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */ |
313 | #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */ |
| 289 | #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */ |
314 | #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */ |
| 290 | #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */ |
315 | #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */ |
| 291 | #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */ |
316 | #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */ |
| 292 | #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */ |
317 | #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */ |
| 293 | #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */ |
318 | #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */ |
| - | 319 | #define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE | SPI_SR_BSY\ |
|
| - | 320 | | SPI_SR_CRCERR | SPI_SR_MODF | SPI_SR_OVR) |
|
| 294 | /** |
321 | /** |
| 295 | * @} |
322 | * @} |
| 296 | */ |
323 | */ |
| 297 | 324 | ||
| 298 | /** |
325 | /** |
| 299 | * @} |
326 | * @} |
| 300 | */ |
327 | */ |
| 301 | 328 | ||
| 302 | /* Exported macro ------------------------------------------------------------*/ |
329 | /* Exported macros -----------------------------------------------------------*/ |
| 303 | /** @defgroup SPI_Exported_Macros SPI Exported Macros |
330 | /** @defgroup SPI_Exported_Macros SPI Exported Macros |
| 304 | * @{ |
331 | * @{ |
| 305 | */ |
332 | */ |
| 306 | 333 | ||
| 307 | /** @brief Reset SPI handle state. |
334 | /** @brief Reset SPI handle state. |
| 308 | * @param __HANDLE__: specifies the SPI Handle. |
335 | * @param __HANDLE__ specifies the SPI Handle. |
| 309 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
336 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 310 | * @retval None |
337 | * @retval None |
| 311 | */ |
338 | */ |
| - | 339 | #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) |
|
| - | 340 | #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
|
| - | 341 | (__HANDLE__)->State = HAL_SPI_STATE_RESET; \ |
|
| - | 342 | (__HANDLE__)->MspInitCallback = NULL; \ |
|
| - | 343 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
|
| - | 344 | } while(0) |
|
| - | 345 | #else |
|
| 312 | #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) |
346 | #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) |
| - | 347 | #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ |
|
| 313 | 348 | ||
| 314 | /** @brief Enable the specified SPI interrupts. |
349 | /** @brief Enable the specified SPI interrupts. |
| 315 | * @param __HANDLE__: specifies the SPI handle. |
350 | * @param __HANDLE__ specifies the SPI Handle. |
| 316 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
351 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 317 | * @param __INTERRUPT__: specifies the interrupt source to enable. |
352 | * @param __INTERRUPT__ specifies the interrupt source to enable. |
| 318 | * This parameter can be one of the following values: |
353 | * This parameter can be one of the following values: |
| 319 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
354 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
| 320 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
355 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
| 321 | * @arg SPI_IT_ERR: Error interrupt enable |
356 | * @arg SPI_IT_ERR: Error interrupt enable |
| 322 | * @retval None |
357 | * @retval None |
| 323 | */ |
358 | */ |
| 324 | #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) |
359 | #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__)) |
| 325 | 360 | ||
| 326 | /** @brief Disable the specified SPI interrupts. |
361 | /** @brief Disable the specified SPI interrupts. |
| 327 | * @param __HANDLE__: specifies the SPI handle. |
362 | * @param __HANDLE__ specifies the SPI handle. |
| 328 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
363 | * This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral. |
| 329 | * @param __INTERRUPT__: specifies the interrupt source to disable. |
364 | * @param __INTERRUPT__ specifies the interrupt source to disable. |
| 330 | * This parameter can be one of the following values: |
365 | * This parameter can be one of the following values: |
| 331 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
366 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
| 332 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
367 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
| 333 | * @arg SPI_IT_ERR: Error interrupt enable |
368 | * @arg SPI_IT_ERR: Error interrupt enable |
| 334 | * @retval None |
369 | * @retval None |
| 335 | */ |
370 | */ |
| 336 | #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) |
371 | #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__)) |
| 337 | 372 | ||
| 338 | /** @brief Check whether the specified SPI interrupt source is enabled or not. |
373 | /** @brief Check whether the specified SPI interrupt source is enabled or not. |
| 339 | * @param __HANDLE__: specifies the SPI Handle. |
374 | * @param __HANDLE__ specifies the SPI Handle. |
| 340 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
375 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 341 | * @param __INTERRUPT__: specifies the SPI interrupt source to check. |
376 | * @param __INTERRUPT__ specifies the SPI interrupt source to check. |
| 342 | * This parameter can be one of the following values: |
377 | * This parameter can be one of the following values: |
| 343 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
378 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
| 344 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
379 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
| 345 | * @arg SPI_IT_ERR: Error interrupt enable |
380 | * @arg SPI_IT_ERR: Error interrupt enable |
| 346 | * @retval The new state of __IT__ (TRUE or FALSE). |
381 | * @retval The new state of __IT__ (TRUE or FALSE). |
| 347 | */ |
382 | */ |
| 348 | #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
383 | #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\ |
| - | 384 | & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
|
| 349 | 385 | ||
| 350 | /** @brief Check whether the specified SPI flag is set or not. |
386 | /** @brief Check whether the specified SPI flag is set or not. |
| 351 | * @param __HANDLE__: specifies the SPI Handle. |
387 | * @param __HANDLE__ specifies the SPI Handle. |
| 352 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
388 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 353 | * @param __FLAG__: specifies the flag to check. |
389 | * @param __FLAG__ specifies the flag to check. |
| 354 | * This parameter can be one of the following values: |
390 | * This parameter can be one of the following values: |
| 355 | * @arg SPI_FLAG_RXNE: Receive buffer not empty flag |
391 | * @arg SPI_FLAG_RXNE: Receive buffer not empty flag |
| 356 | * @arg SPI_FLAG_TXE: Transmit buffer empty flag |
392 | * @arg SPI_FLAG_TXE: Transmit buffer empty flag |
| 357 | * @arg SPI_FLAG_CRCERR: CRC error flag |
393 | * @arg SPI_FLAG_CRCERR: CRC error flag |
| 358 | * @arg SPI_FLAG_MODF: Mode fault flag |
394 | * @arg SPI_FLAG_MODF: Mode fault flag |
| Line 361... | Line 397... | ||
| 361 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
397 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
| 362 | */ |
398 | */ |
| 363 | #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
399 | #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
| 364 | 400 | ||
| 365 | /** @brief Clear the SPI CRCERR pending flag. |
401 | /** @brief Clear the SPI CRCERR pending flag. |
| 366 | * @param __HANDLE__: specifies the SPI Handle. |
402 | * @param __HANDLE__ specifies the SPI Handle. |
| 367 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
403 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 368 | * @retval None |
404 | * @retval None |
| 369 | */ |
405 | */ |
| 370 | #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR)) |
406 | #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR)) |
| 371 | 407 | ||
| 372 | /** @brief Clear the SPI MODF pending flag. |
408 | /** @brief Clear the SPI MODF pending flag. |
| 373 | * @param __HANDLE__: specifies the SPI Handle. |
409 | * @param __HANDLE__ specifies the SPI Handle. |
| 374 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
410 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 375 | * @retval None |
411 | * @retval None |
| 376 | */ |
412 | */ |
| 377 | #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \ |
413 | #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \ |
| 378 | do{ \ |
414 | do{ \ |
| 379 | __IO uint32_t tmpreg_modf = 0x00U; \ |
415 | __IO uint32_t tmpreg_modf = 0x00U; \ |
| 380 | tmpreg_modf = (__HANDLE__)->Instance->SR; \ |
416 | tmpreg_modf = (__HANDLE__)->Instance->SR; \ |
| 381 | (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \ |
417 | CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \ |
| 382 | UNUSED(tmpreg_modf); \ |
418 | UNUSED(tmpreg_modf); \ |
| 383 | } while(0U) |
419 | } while(0U) |
| 384 | 420 | ||
| 385 | /** @brief Clear the SPI OVR pending flag. |
421 | /** @brief Clear the SPI OVR pending flag. |
| 386 | * @param __HANDLE__: specifies the SPI Handle. |
422 | * @param __HANDLE__ specifies the SPI Handle. |
| 387 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
423 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 388 | * @retval None |
424 | * @retval None |
| 389 | */ |
425 | */ |
| 390 | #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \ |
426 | #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \ |
| 391 | do{ \ |
427 | do{ \ |
| 392 | __IO uint32_t tmpreg_ovr = 0x00U; \ |
428 | __IO uint32_t tmpreg_ovr = 0x00U; \ |
| 393 | tmpreg_ovr = (__HANDLE__)->Instance->DR; \ |
429 | tmpreg_ovr = (__HANDLE__)->Instance->DR; \ |
| 394 | tmpreg_ovr = (__HANDLE__)->Instance->SR; \ |
430 | tmpreg_ovr = (__HANDLE__)->Instance->SR; \ |
| 395 | UNUSED(tmpreg_ovr); \ |
431 | UNUSED(tmpreg_ovr); \ |
| 396 | } while(0U) |
432 | } while(0U) |
| 397 | 433 | ||
| 398 | - | ||
| 399 | /** @brief Enable the SPI peripheral. |
434 | /** @brief Enable the SPI peripheral. |
| 400 | * @param __HANDLE__: specifies the SPI Handle. |
435 | * @param __HANDLE__ specifies the SPI Handle. |
| 401 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
436 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 402 | * @retval None |
437 | * @retval None |
| 403 | */ |
438 | */ |
| 404 | #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE) |
439 | #define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE) |
| 405 | 440 | ||
| 406 | /** @brief Disable the SPI peripheral. |
441 | /** @brief Disable the SPI peripheral. |
| 407 | * @param __HANDLE__: specifies the SPI Handle. |
442 | * @param __HANDLE__ specifies the SPI Handle. |
| - | 443 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
|
| - | 444 | * @retval None |
|
| - | 445 | */ |
|
| - | 446 | #define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE) |
|
| - | 447 | ||
| - | 448 | /** |
|
| - | 449 | * @} |
|
| - | 450 | */ |
|
| - | 451 | ||
| - | 452 | /* Private constants ---------------------------------------------------------*/ |
|
| - | 453 | /** @defgroup SPI_Private_Constants SPI Private Constants |
|
| - | 454 | * @{ |
|
| - | 455 | */ |
|
| - | 456 | #define SPI_INVALID_CRC_ERROR 0U /* CRC error wrongly detected */ |
|
| - | 457 | #define SPI_VALID_CRC_ERROR 1U /* CRC error is true */ |
|
| - | 458 | /** |
|
| - | 459 | * @} |
|
| - | 460 | */ |
|
| - | 461 | ||
| - | 462 | /* Private macros ------------------------------------------------------------*/ |
|
| - | 463 | /** @defgroup SPI_Private_Macros SPI Private Macros |
|
| - | 464 | * @{ |
|
| - | 465 | */ |
|
| - | 466 | ||
| - | 467 | /** @brief Set the SPI transmit-only mode. |
|
| - | 468 | * @param __HANDLE__ specifies the SPI Handle. |
|
| 408 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
469 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
| 409 | * @retval None |
470 | * @retval None |
| 410 | */ |
471 | */ |
| 411 | #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE)) |
472 | #define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE) |
| - | 473 | ||
| - | 474 | /** @brief Set the SPI receive-only mode. |
|
| - | 475 | * @param __HANDLE__ specifies the SPI Handle. |
|
| - | 476 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
|
| - | 477 | * @retval None |
|
| - | 478 | */ |
|
| - | 479 | #define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE) |
|
| - | 480 | ||
| - | 481 | /** @brief Reset the CRC calculation of the SPI. |
|
| - | 482 | * @param __HANDLE__ specifies the SPI Handle. |
|
| - | 483 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
|
| - | 484 | * @retval None |
|
| - | 485 | */ |
|
| - | 486 | #define SPI_RESET_CRC(__HANDLE__) do{CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);\ |
|
| - | 487 | SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);}while(0U) |
|
| - | 488 | ||
| - | 489 | /** @brief Check whether the specified SPI flag is set or not. |
|
| - | 490 | * @param __SR__ copy of SPI SR register. |
|
| - | 491 | * @param __FLAG__ specifies the flag to check. |
|
| - | 492 | * This parameter can be one of the following values: |
|
| - | 493 | * @arg SPI_FLAG_RXNE: Receive buffer not empty flag |
|
| - | 494 | * @arg SPI_FLAG_TXE: Transmit buffer empty flag |
|
| - | 495 | * @arg SPI_FLAG_CRCERR: CRC error flag |
|
| - | 496 | * @arg SPI_FLAG_MODF: Mode fault flag |
|
| - | 497 | * @arg SPI_FLAG_OVR: Overrun flag |
|
| - | 498 | * @arg SPI_FLAG_BSY: Busy flag |
|
| - | 499 | * @retval SET or RESET. |
|
| - | 500 | */ |
|
| - | 501 | #define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == \ |
|
| - | 502 | ((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET) |
|
| - | 503 | ||
| - | 504 | /** @brief Check whether the specified SPI Interrupt is set or not. |
|
| - | 505 | * @param __CR2__ copy of SPI CR2 register. |
|
| - | 506 | * @param __INTERRUPT__ specifies the SPI interrupt source to check. |
|
| - | 507 | * This parameter can be one of the following values: |
|
| - | 508 | * @arg SPI_IT_TXE: Tx buffer empty interrupt enable |
|
| - | 509 | * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable |
|
| - | 510 | * @arg SPI_IT_ERR: Error interrupt enable |
|
| - | 511 | * @retval SET or RESET. |
|
| - | 512 | */ |
|
| - | 513 | #define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == \ |
|
| - | 514 | (__INTERRUPT__)) ? SET : RESET) |
|
| - | 515 | ||
| - | 516 | /** @brief Checks if SPI Mode parameter is in allowed range. |
|
| - | 517 | * @param __MODE__ specifies the SPI Mode. |
|
| - | 518 | * This parameter can be a value of @ref SPI_Mode |
|
| - | 519 | * @retval None |
|
| - | 520 | */ |
|
| - | 521 | #define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \ |
|
| - | 522 | ((__MODE__) == SPI_MODE_MASTER)) |
|
| - | 523 | ||
| - | 524 | /** @brief Checks if SPI Direction Mode parameter is in allowed range. |
|
| - | 525 | * @param __MODE__ specifies the SPI Direction Mode. |
|
| - | 526 | * This parameter can be a value of @ref SPI_Direction |
|
| - | 527 | * @retval None |
|
| - | 528 | */ |
|
| - | 529 | #define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \ |
|
| - | 530 | ((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \ |
|
| - | 531 | ((__MODE__) == SPI_DIRECTION_1LINE)) |
|
| - | 532 | ||
| - | 533 | /** @brief Checks if SPI Direction Mode parameter is 2 lines. |
|
| - | 534 | * @param __MODE__ specifies the SPI Direction Mode. |
|
| - | 535 | * @retval None |
|
| - | 536 | */ |
|
| - | 537 | #define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES) |
|
| - | 538 | ||
| - | 539 | /** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines. |
|
| - | 540 | * @param __MODE__ specifies the SPI Direction Mode. |
|
| - | 541 | * @retval None |
|
| - | 542 | */ |
|
| - | 543 | #define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \ |
|
| - | 544 | ((__MODE__) == SPI_DIRECTION_1LINE)) |
|
| - | 545 | ||
| - | 546 | /** @brief Checks if SPI Data Size parameter is in allowed range. |
|
| - | 547 | * @param __DATASIZE__ specifies the SPI Data Size. |
|
| - | 548 | * This parameter can be a value of @ref SPI_Data_Size |
|
| - | 549 | * @retval None |
|
| - | 550 | */ |
|
| - | 551 | #define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \ |
|
| - | 552 | ((__DATASIZE__) == SPI_DATASIZE_8BIT)) |
|
| - | 553 | ||
| - | 554 | /** @brief Checks if SPI Serial clock steady state parameter is in allowed range. |
|
| - | 555 | * @param __CPOL__ specifies the SPI serial clock steady state. |
|
| - | 556 | * This parameter can be a value of @ref SPI_Clock_Polarity |
|
| - | 557 | * @retval None |
|
| - | 558 | */ |
|
| - | 559 | #define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \ |
|
| - | 560 | ((__CPOL__) == SPI_POLARITY_HIGH)) |
|
| - | 561 | ||
| - | 562 | /** @brief Checks if SPI Clock Phase parameter is in allowed range. |
|
| - | 563 | * @param __CPHA__ specifies the SPI Clock Phase. |
|
| - | 564 | * This parameter can be a value of @ref SPI_Clock_Phase |
|
| - | 565 | * @retval None |
|
| - | 566 | */ |
|
| - | 567 | #define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \ |
|
| - | 568 | ((__CPHA__) == SPI_PHASE_2EDGE)) |
|
| - | 569 | ||
| - | 570 | /** @brief Checks if SPI Slave Select parameter is in allowed range. |
|
| - | 571 | * @param __NSS__ specifies the SPI Slave Select management parameter. |
|
| - | 572 | * This parameter can be a value of @ref SPI_Slave_Select_management |
|
| - | 573 | * @retval None |
|
| - | 574 | */ |
|
| - | 575 | #define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \ |
|
| - | 576 | ((__NSS__) == SPI_NSS_HARD_INPUT) || \ |
|
| - | 577 | ((__NSS__) == SPI_NSS_HARD_OUTPUT)) |
|
| - | 578 | ||
| - | 579 | /** @brief Checks if SPI Baudrate prescaler parameter is in allowed range. |
|
| - | 580 | * @param __PRESCALER__ specifies the SPI Baudrate prescaler. |
|
| - | 581 | * This parameter can be a value of @ref SPI_BaudRate_Prescaler |
|
| - | 582 | * @retval None |
|
| - | 583 | */ |
|
| - | 584 | #define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \ |
|
| - | 585 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \ |
|
| - | 586 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \ |
|
| - | 587 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \ |
|
| - | 588 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \ |
|
| - | 589 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \ |
|
| - | 590 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \ |
|
| - | 591 | ((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256)) |
|
| - | 592 | ||
| - | 593 | /** @brief Checks if SPI MSB LSB transmission parameter is in allowed range. |
|
| - | 594 | * @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit). |
|
| - | 595 | * This parameter can be a value of @ref SPI_MSB_LSB_transmission |
|
| - | 596 | * @retval None |
|
| - | 597 | */ |
|
| - | 598 | #define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \ |
|
| - | 599 | ((__BIT__) == SPI_FIRSTBIT_LSB)) |
|
| - | 600 | ||
| - | 601 | /** @brief Checks if SPI TI mode parameter is disabled. |
|
| - | 602 | * @param __MODE__ SPI_TIMODE_DISABLE. Device not support Ti Mode. |
|
| - | 603 | * This parameter can be a value of @ref SPI_TI_mode |
|
| - | 604 | * @retval None |
|
| - | 605 | */ |
|
| - | 606 | #define IS_SPI_TIMODE(__MODE__) ((__MODE__) == SPI_TIMODE_DISABLE) |
|
| - | 607 | ||
| - | 608 | /** @brief Checks if SPI CRC calculation enabled state is in allowed range. |
|
| - | 609 | * @param __CALCULATION__ specifies the SPI CRC calculation enable state. |
|
| - | 610 | * This parameter can be a value of @ref SPI_CRC_Calculation |
|
| - | 611 | * @retval None |
|
| - | 612 | */ |
|
| - | 613 | #define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \ |
|
| - | 614 | ((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE)) |
|
| - | 615 | ||
| - | 616 | /** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range. |
|
| - | 617 | * @param __POLYNOMIAL__ specifies the SPI polynomial value to be used for the CRC calculation. |
|
| - | 618 | * This parameter must be a number between Min_Data = 0 and Max_Data = 65535 |
|
| - | 619 | * @retval None |
|
| - | 620 | */ |
|
| - | 621 | #define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && \ |
|
| - | 622 | ((__POLYNOMIAL__) <= 0xFFFFU) && \ |
|
| - | 623 | (((__POLYNOMIAL__)&0x1U) != 0U)) |
|
| - | 624 | ||
| - | 625 | /** @brief Checks if DMA handle is valid. |
|
| - | 626 | * @param __HANDLE__ specifies a DMA Handle. |
|
| - | 627 | * @retval None |
|
| - | 628 | */ |
|
| - | 629 | #define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL) |
|
| - | 630 | ||
| - | 631 | /** |
|
| - | 632 | * @} |
|
| - | 633 | */ |
|
| - | 634 | ||
| - | 635 | /* Private functions ---------------------------------------------------------*/ |
|
| - | 636 | /** @defgroup SPI_Private_Functions SPI Private Functions |
|
| - | 637 | * @{ |
|
| - | 638 | */ |
|
| - | 639 | uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi); |
|
| 412 | /** |
640 | /** |
| 413 | * @} |
641 | * @} |
| 414 | */ |
642 | */ |
| 415 | 643 | ||
| 416 | /* Exported functions --------------------------------------------------------*/ |
644 | /* Exported functions --------------------------------------------------------*/ |
| Line 419... | Line 647... | ||
| 419 | */ |
647 | */ |
| 420 | 648 | ||
| 421 | /** @addtogroup SPI_Exported_Functions_Group1 |
649 | /** @addtogroup SPI_Exported_Functions_Group1 |
| 422 | * @{ |
650 | * @{ |
| 423 | */ |
651 | */ |
| 424 | /* Initialization/de-initialization functions **********************************/ |
652 | /* Initialization/de-initialization functions ********************************/ |
| 425 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); |
653 | HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); |
| 426 | HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi); |
654 | HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi); |
| 427 | void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); |
655 | void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); |
| 428 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); |
656 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); |
| - | 657 | ||
| - | 658 | /* Callbacks Register/UnRegister functions ***********************************/ |
|
| - | 659 | #if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U) |
|
| - | 660 | HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID, pSPI_CallbackTypeDef pCallback); |
|
| - | 661 | HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID); |
|
| - | 662 | #endif /* USE_HAL_SPI_REGISTER_CALLBACKS */ |
|
| 429 | /** |
663 | /** |
| 430 | * @} |
664 | * @} |
| 431 | */ |
665 | */ |
| 432 | 666 | ||
| 433 | /** @addtogroup SPI_Exported_Functions_Group2 |
667 | /** @addtogroup SPI_Exported_Functions_Group2 |
| 434 | * @{ |
668 | * @{ |
| 435 | */ |
669 | */ |
| 436 | /* I/O operation functions *****************************************************/ |
670 | /* I/O operation functions ***************************************************/ |
| 437 | HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
671 | HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
| 438 | HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
672 | HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
| 439 | HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
673 | HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, |
| - | 674 | uint32_t Timeout); |
|
| 440 | HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
675 | HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
| 441 | HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
676 | HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
| 442 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
677 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, |
| - | 678 | uint16_t Size); |
|
| 443 | HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
679 | HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
| 444 | HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
680 | HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); |
| 445 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); |
681 | HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, |
| - | 682 | uint16_t Size); |
|
| 446 | HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); |
683 | HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); |
| 447 | HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); |
684 | HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); |
| 448 | HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); |
685 | HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); |
| 449 | /* Transfer Abort functions */ |
686 | /* Transfer Abort functions */ |
| 450 | HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi); |
687 | HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi); |
| Line 475... | Line 712... | ||
| 475 | 712 | ||
| 476 | /** |
713 | /** |
| 477 | * @} |
714 | * @} |
| 478 | */ |
715 | */ |
| 479 | 716 | ||
| 480 | /* Private types -------------------------------------------------------------*/ |
- | |
| 481 | /* Private variables ---------------------------------------------------------*/ |
- | |
| 482 | /* Private constants ---------------------------------------------------------*/ |
- | |
| 483 | /** @defgroup SPI_Private_Constants SPI Private Constants |
- | |
| 484 | * @{ |
- | |
| 485 | */ |
- | |
| 486 | #define SPI_INVALID_CRC_ERROR 0U /* CRC error wrongly detected */ |
- | |
| 487 | #define SPI_VALID_CRC_ERROR 1U /* CRC error is true */ |
- | |
| 488 | /** |
- | |
| 489 | * @} |
- | |
| 490 | */ |
- | |
| 491 | /* Private macros ------------------------------------------------------------*/ |
- | |
| 492 | /** @defgroup SPI_Private_Macros SPI Private Macros |
- | |
| 493 | * @{ |
- | |
| 494 | */ |
- | |
| 495 | - | ||
| 496 | /** @brief Set the SPI transmit-only mode. |
- | |
| 497 | * @param __HANDLE__: specifies the SPI Handle. |
- | |
| 498 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
- | |
| 499 | * @retval None |
- | |
| 500 | */ |
- | |
| 501 | #define SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE) |
- | |
| 502 | - | ||
| 503 | /** @brief Set the SPI receive-only mode. |
- | |
| 504 | * @param __HANDLE__: specifies the SPI Handle. |
- | |
| 505 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
- | |
| 506 | * @retval None |
- | |
| 507 | */ |
- | |
| 508 | #define SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_BIDIOE)) |
- | |
| 509 | - | ||
| 510 | /** @brief Reset the CRC calculation of the SPI. |
- | |
| 511 | * @param __HANDLE__: specifies the SPI Handle. |
- | |
| 512 | * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. |
- | |
| 513 | * @retval None |
- | |
| 514 | */ |
- | |
| 515 | #define SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (uint16_t)(~SPI_CR1_CRCEN);\ |
- | |
| 516 | (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0U) |
- | |
| 517 | - | ||
| 518 | #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \ |
- | |
| 519 | ((MODE) == SPI_MODE_MASTER)) |
- | |
| 520 | - | ||
| 521 | #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ |
- | |
| 522 | ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \ |
- | |
| 523 | ((MODE) == SPI_DIRECTION_1LINE)) |
- | |
| 524 | - | ||
| 525 | #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES) |
- | |
| 526 | - | ||
| 527 | #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ |
- | |
| 528 | ((MODE) == SPI_DIRECTION_1LINE)) |
- | |
| 529 | - | ||
| 530 | #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ |
- | |
| 531 | ((DATASIZE) == SPI_DATASIZE_8BIT)) |
- | |
| 532 | - | ||
| 533 | #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \ |
- | |
| 534 | ((CPOL) == SPI_POLARITY_HIGH)) |
- | |
| 535 | - | ||
| 536 | #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \ |
- | |
| 537 | ((CPHA) == SPI_PHASE_2EDGE)) |
- | |
| 538 | - | ||
| 539 | #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \ |
- | |
| 540 | ((NSS) == SPI_NSS_HARD_INPUT) || \ |
- | |
| 541 | ((NSS) == SPI_NSS_HARD_OUTPUT)) |
- | |
| 542 | - | ||
| 543 | #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ |
- | |
| 544 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ |
- | |
| 545 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ |
- | |
| 546 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ |
- | |
| 547 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ |
- | |
| 548 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ |
- | |
| 549 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ |
- | |
| 550 | ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) |
- | |
| 551 | - | ||
| 552 | #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ |
- | |
| 553 | ((BIT) == SPI_FIRSTBIT_LSB)) |
- | |
| 554 | - | ||
| 555 | #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLE) || \ |
- | |
| 556 | ((CALCULATION) == SPI_CRCCALCULATION_ENABLE)) |
- | |
| 557 | - | ||
| 558 | #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x01U) && ((POLYNOMIAL) <= 0xFFFFU)) |
- | |
| 559 | - | ||
| 560 | /** |
- | |
| 561 | * @} |
- | |
| 562 | */ |
- | |
| 563 | - | ||
| 564 | /* Private functions ---------------------------------------------------------*/ |
- | |
| 565 | /** @defgroup SPI_Private_Functions SPI Private Functions |
- | |
| 566 | * @{ |
- | |
| 567 | */ |
- | |
| 568 | uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi); |
- | |
| 569 | /** |
- | |
| 570 | * @} |
- | |
| 571 | */ |
- | |
| 572 | - | ||
| 573 | /** |
717 | /** |
| 574 | * @} |
718 | * @} |
| 575 | */ |
719 | */ |
| 576 | 720 | ||
| 577 | /** |
721 | /** |
| Line 580... | Line 724... | ||
| 580 | 724 | ||
| 581 | #ifdef __cplusplus |
725 | #ifdef __cplusplus |
| 582 | } |
726 | } |
| 583 | #endif |
727 | #endif |
| 584 | 728 | ||
| 585 | #endif /* __STM32F1xx_HAL_SPI_H */ |
729 | #endif /* STM32F1xx_HAL_SPI_H */ |
| 586 | 730 | ||
| 587 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
731 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |