1 /**
2   ******************************************************************************
3   * @file    stm32wbaxx_ll_spi.c
4   * @author  MCD Application Team
5   * @brief   SPI LL module driver.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2022 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 #if defined(USE_FULL_LL_DRIVER)
19 
20 /* Includes ------------------------------------------------------------------*/
21 #include "stm32wbaxx_ll_spi.h"
22 #include "stm32wbaxx_ll_bus.h"
23 #ifdef  USE_FULL_ASSERT
24 #include "stm32_assert.h"
25 #else
26 #define assert_param(expr) ((void)0U)
27 #endif /* USE_FULL_ASSERT */
28 
29 /** @addtogroup STM32WBAxx_LL_Driver
30   * @{
31   */
32 
33 #if defined(SPI1) || defined(SPI3)
34 
35 /** @addtogroup SPI_LL
36   * @{
37   */
38 
39 /* Private types -------------------------------------------------------------*/
40 /* Private variables ---------------------------------------------------------*/
41 /* Private constants ---------------------------------------------------------*/
42 /* Private macros ------------------------------------------------------------*/
43 /** @addtogroup SPI_LL_Private_Macros
44   * @{
45   */
46 
47 #define IS_LL_SPI_MODE(__VALUE__)                   (((__VALUE__) == LL_SPI_MODE_MASTER)         || \
48                                                      ((__VALUE__) == LL_SPI_MODE_SLAVE))
49 
50 #define IS_LL_SPI_SS_IDLENESS(__VALUE__)            (((__VALUE__) == LL_SPI_SS_IDLENESS_00CYCLE) || \
51                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_01CYCLE) || \
52                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_02CYCLE) || \
53                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_03CYCLE) || \
54                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_04CYCLE) || \
55                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_05CYCLE) || \
56                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_06CYCLE) || \
57                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_07CYCLE) || \
58                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_08CYCLE) || \
59                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_09CYCLE) || \
60                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_10CYCLE) || \
61                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_11CYCLE) || \
62                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_12CYCLE) || \
63                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_13CYCLE) || \
64                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_14CYCLE) || \
65                                                      ((__VALUE__) == LL_SPI_SS_IDLENESS_15CYCLE))
66 
67 #define IS_LL_SPI_ID_IDLENESS(__VALUE__)            (((__VALUE__) == LL_SPI_ID_IDLENESS_00CYCLE) || \
68                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_01CYCLE) || \
69                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_02CYCLE) || \
70                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_03CYCLE) || \
71                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_04CYCLE) || \
72                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_05CYCLE) || \
73                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_06CYCLE) || \
74                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_07CYCLE) || \
75                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_08CYCLE) || \
76                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_09CYCLE) || \
77                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_10CYCLE) || \
78                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_11CYCLE) || \
79                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_12CYCLE) || \
80                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_13CYCLE) || \
81                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_14CYCLE) || \
82                                                      ((__VALUE__) == LL_SPI_ID_IDLENESS_15CYCLE))
83 
84 #define IS_LL_SPI_TXCRCINIT_PATTERN(__VALUE__)      (((__VALUE__) == LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN) || \
85                                                      ((__VALUE__) == LL_SPI_TXCRCINIT_ALL_ONES_PATTERN))
86 
87 #define IS_LL_SPI_RXCRCINIT_PATTERN(__VALUE__)      (((__VALUE__) == LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN) || \
88                                                      ((__VALUE__) == LL_SPI_RXCRCINIT_ALL_ONES_PATTERN))
89 
90 #define IS_LL_SPI_UDR_CONFIG_REGISTER(__VALUE__)    (((__VALUE__) == LL_SPI_UDR_CONFIG_REGISTER_PATTERN) || \
91                                                      ((__VALUE__) == LL_SPI_UDR_CONFIG_LAST_RECEIVED)    || \
92                                                      ((__VALUE__) == LL_SPI_UDR_CONFIG_LAST_TRANSMITTED))
93 
94 #define IS_LL_SPI_UDR_DETECT_BEGIN_DATA(__VALUE__)  (((__VALUE__) == LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME) || \
95                                                      ((__VALUE__) == LL_SPI_UDR_DETECT_END_DATA_FRAME)   || \
96                                                      ((__VALUE__) == LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS))
97 
98 #define IS_LL_SPI_PROTOCOL(__VALUE__)               (((__VALUE__) == LL_SPI_PROTOCOL_MOTOROLA)           || \
99                                                      ((__VALUE__) == LL_SPI_PROTOCOL_TI))
100 
101 #define IS_LL_SPI_PHASE(__VALUE__)                  (((__VALUE__) == LL_SPI_PHASE_1EDGE)                 || \
102                                                      ((__VALUE__) == LL_SPI_PHASE_2EDGE))
103 
104 #define IS_LL_SPI_POLARITY(__VALUE__)               (((__VALUE__) == LL_SPI_POLARITY_LOW)                || \
105                                                      ((__VALUE__) == LL_SPI_POLARITY_HIGH))
106 
107 #define IS_LL_SPI_BAUDRATEPRESCALER(__VALUE__)      (((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_BYPASS)    || \
108                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV2)      || \
109                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV4)      || \
110                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV8)      || \
111                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV16)     || \
112                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV32)     || \
113                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV64)     || \
114                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV128)    || \
115                                                      ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV256))
116 
117 #define IS_LL_SPI_BITORDER(__VALUE__)               (((__VALUE__) == LL_SPI_LSB_FIRST)                   || \
118                                                      ((__VALUE__) == LL_SPI_MSB_FIRST))
119 
120 #define IS_LL_SPI_TRANSFER_DIRECTION(__VALUE__)     (((__VALUE__) == LL_SPI_FULL_DUPLEX)                 || \
121                                                      ((__VALUE__) == LL_SPI_SIMPLEX_TX)                  || \
122                                                      ((__VALUE__) == LL_SPI_SIMPLEX_RX)                  || \
123                                                      ((__VALUE__) == LL_SPI_HALF_DUPLEX_RX)              || \
124                                                      ((__VALUE__) == LL_SPI_HALF_DUPLEX_TX))
125 
126 #define IS_LL_SPI_DATAWIDTH(__VALUE__)              (((__VALUE__) == LL_SPI_DATAWIDTH_4BIT)              || \
127                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_5BIT)              || \
128                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_6BIT)              || \
129                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_7BIT)              || \
130                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_8BIT)              || \
131                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_9BIT)              || \
132                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_10BIT)             || \
133                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_11BIT)             || \
134                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_12BIT)             || \
135                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_13BIT)             || \
136                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_14BIT)             || \
137                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_15BIT)             || \
138                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_16BIT)             || \
139                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_17BIT)             || \
140                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_18BIT)             || \
141                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_19BIT)             || \
142                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_20BIT)             || \
143                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_21BIT)             || \
144                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_22BIT)             || \
145                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_23BIT)             || \
146                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_24BIT)             || \
147                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_25BIT)             || \
148                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_26BIT)             || \
149                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_27BIT)             || \
150                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_28BIT)             || \
151                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_29BIT)             || \
152                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_30BIT)             || \
153                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_31BIT)             || \
154                                                      ((__VALUE__) == LL_SPI_DATAWIDTH_32BIT))
155 
156 #define IS_LL_SPI_FIFO_TH(__VALUE__)                (((__VALUE__) == LL_SPI_FIFO_TH_01DATA)              || \
157                                                      ((__VALUE__) == LL_SPI_FIFO_TH_02DATA)              || \
158                                                      ((__VALUE__) == LL_SPI_FIFO_TH_03DATA)              || \
159                                                      ((__VALUE__) == LL_SPI_FIFO_TH_04DATA)              || \
160                                                      ((__VALUE__) == LL_SPI_FIFO_TH_05DATA)              || \
161                                                      ((__VALUE__) == LL_SPI_FIFO_TH_06DATA)              || \
162                                                      ((__VALUE__) == LL_SPI_FIFO_TH_07DATA)              || \
163                                                      ((__VALUE__) == LL_SPI_FIFO_TH_08DATA)              || \
164                                                      ((__VALUE__) == LL_SPI_FIFO_TH_09DATA)              || \
165                                                      ((__VALUE__) == LL_SPI_FIFO_TH_10DATA)              || \
166                                                      ((__VALUE__) == LL_SPI_FIFO_TH_11DATA)              || \
167                                                      ((__VALUE__) == LL_SPI_FIFO_TH_12DATA)              || \
168                                                      ((__VALUE__) == LL_SPI_FIFO_TH_13DATA)              || \
169                                                      ((__VALUE__) == LL_SPI_FIFO_TH_14DATA)              || \
170                                                      ((__VALUE__) == LL_SPI_FIFO_TH_15DATA)              || \
171                                                      ((__VALUE__) == LL_SPI_FIFO_TH_16DATA))
172 
173 #define IS_LL_SPI_CRC(__VALUE__)                    (((__VALUE__) == LL_SPI_CRC_4BIT)                    || \
174                                                      ((__VALUE__) == LL_SPI_CRC_5BIT)                    || \
175                                                      ((__VALUE__) == LL_SPI_CRC_6BIT)                    || \
176                                                      ((__VALUE__) == LL_SPI_CRC_7BIT)                    || \
177                                                      ((__VALUE__) == LL_SPI_CRC_8BIT)                    || \
178                                                      ((__VALUE__) == LL_SPI_CRC_9BIT)                    || \
179                                                      ((__VALUE__) == LL_SPI_CRC_10BIT)                   || \
180                                                      ((__VALUE__) == LL_SPI_CRC_11BIT)                   || \
181                                                      ((__VALUE__) == LL_SPI_CRC_12BIT)                   || \
182                                                      ((__VALUE__) == LL_SPI_CRC_13BIT)                   || \
183                                                      ((__VALUE__) == LL_SPI_CRC_14BIT)                   || \
184                                                      ((__VALUE__) == LL_SPI_CRC_15BIT)                   || \
185                                                      ((__VALUE__) == LL_SPI_CRC_16BIT)                   || \
186                                                      ((__VALUE__) == LL_SPI_CRC_17BIT)                   || \
187                                                      ((__VALUE__) == LL_SPI_CRC_18BIT)                   || \
188                                                      ((__VALUE__) == LL_SPI_CRC_19BIT)                   || \
189                                                      ((__VALUE__) == LL_SPI_CRC_20BIT)                   || \
190                                                      ((__VALUE__) == LL_SPI_CRC_21BIT)                   || \
191                                                      ((__VALUE__) == LL_SPI_CRC_22BIT)                   || \
192                                                      ((__VALUE__) == LL_SPI_CRC_23BIT)                   || \
193                                                      ((__VALUE__) == LL_SPI_CRC_24BIT)                   || \
194                                                      ((__VALUE__) == LL_SPI_CRC_25BIT)                   || \
195                                                      ((__VALUE__) == LL_SPI_CRC_26BIT)                   || \
196                                                      ((__VALUE__) == LL_SPI_CRC_27BIT)                   || \
197                                                      ((__VALUE__) == LL_SPI_CRC_28BIT)                   || \
198                                                      ((__VALUE__) == LL_SPI_CRC_29BIT)                   || \
199                                                      ((__VALUE__) == LL_SPI_CRC_30BIT)                   || \
200                                                      ((__VALUE__) == LL_SPI_CRC_31BIT)                   || \
201                                                      ((__VALUE__) == LL_SPI_CRC_32BIT))
202 
203 #define IS_LL_SPI_NSS(__VALUE__)                    (((__VALUE__) == LL_SPI_NSS_SOFT)                    || \
204                                                      ((__VALUE__) == LL_SPI_NSS_HARD_INPUT)              || \
205                                                      ((__VALUE__) == LL_SPI_NSS_HARD_OUTPUT))
206 
207 #define IS_LL_SPI_RX_FIFO(__VALUE__)                (((__VALUE__) == LL_SPI_RX_FIFO_0PACKET)             || \
208                                                      ((__VALUE__) == LL_SPI_RX_FIFO_1PACKET)             || \
209                                                      ((__VALUE__) == LL_SPI_RX_FIFO_2PACKET)             || \
210                                                      ((__VALUE__) == LL_SPI_RX_FIFO_3PACKET))
211 
212 #define IS_LL_SPI_CRCCALCULATION(__VALUE__)         (((__VALUE__) == LL_SPI_CRCCALCULATION_ENABLE)       || \
213                                                      ((__VALUE__) == LL_SPI_CRCCALCULATION_DISABLE))
214 
215 #define IS_LL_SPI_CRC_POLYNOMIAL(__VALUE__)          ((__VALUE__) >= 0x1UL)
216 
217 /**
218   * @}
219   */
220 
221 /* Private function prototypes -----------------------------------------------*/
222 
223 /* Exported functions --------------------------------------------------------*/
224 /** @addtogroup SPI_LL_Exported_Functions
225   * @{
226   */
227 
228 /** @addtogroup SPI_LL_EF_Init
229   * @{
230   */
231 
232 /**
233   * @brief  De-initialize the SPI registers to their default reset values.
234   * @param  SPIx SPI Instance
235   * @retval An ErrorStatus enumeration value:
236   *          - SUCCESS: SPI registers are de-initialized
237   *          - ERROR: SPI registers are not de-initialized
238   */
LL_SPI_DeInit(const SPI_TypeDef * SPIx)239 ErrorStatus LL_SPI_DeInit(const SPI_TypeDef *SPIx)
240 {
241   ErrorStatus status = ERROR;
242 
243   /* Check the parameters */
244   assert_param(IS_SPI_ALL_INSTANCE(SPIx));
245 
246 #if defined(SPI1)
247   if (SPIx == SPI1)
248   {
249     /* Force reset of SPI clock */
250     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
251 
252     /* Release reset of SPI clock */
253     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_SPI1);
254 
255     /* Update the return status */
256     status = SUCCESS;
257   }
258 #endif /* SPI1 */
259 #if defined(SPI3)
260   if (SPIx == SPI3)
261   {
262     /* Force reset of SPI clock */
263     LL_APB7_GRP1_ForceReset(LL_APB7_GRP1_PERIPH_SPI3);
264 
265     /* Release reset of SPI clock */
266     LL_APB7_GRP1_ReleaseReset(LL_APB7_GRP1_PERIPH_SPI3);
267 
268     /* Update the return status */
269     status = SUCCESS;
270   }
271 #endif /* SPI3 */
272 
273   return status;
274 }
275 
276 /**
277   * @brief  Initialize the SPI registers according to the specified parameters in SPI_InitStruct.
278   * @note   As some bits in SPI configuration registers can only be written when the SPI is disabled
279   *         (SPI_CR1_SPE bit =0), SPI IP should be in disabled state prior calling this function.
280   *         Otherwise, ERROR result will be returned.
281   * @param  SPIx SPI Instance
282   * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
283   * @retval An ErrorStatus enumeration value. (Return always SUCCESS)
284   */
LL_SPI_Init(SPI_TypeDef * SPIx,LL_SPI_InitTypeDef * SPI_InitStruct)285 ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct)
286 {
287   ErrorStatus status = ERROR;
288   uint32_t tmp_nss;
289   uint32_t tmp_mode;
290   uint32_t tmp_nss_polarity;
291 
292   /* Check the SPI Instance SPIx*/
293   assert_param(IS_SPI_ALL_INSTANCE(SPIx));
294 
295   /* Check the SPI parameters from SPI_InitStruct*/
296   assert_param(IS_LL_SPI_TRANSFER_DIRECTION(SPI_InitStruct->TransferDirection));
297   assert_param(IS_LL_SPI_MODE(SPI_InitStruct->Mode));
298   assert_param(IS_LL_SPI_DATAWIDTH(SPI_InitStruct->DataWidth));
299   assert_param(IS_LL_SPI_POLARITY(SPI_InitStruct->ClockPolarity));
300   assert_param(IS_LL_SPI_PHASE(SPI_InitStruct->ClockPhase));
301   assert_param(IS_LL_SPI_NSS(SPI_InitStruct->NSS));
302   assert_param(IS_LL_SPI_BAUDRATEPRESCALER(SPI_InitStruct->BaudRate));
303   assert_param(IS_LL_SPI_BITORDER(SPI_InitStruct->BitOrder));
304   assert_param(IS_LL_SPI_CRCCALCULATION(SPI_InitStruct->CRCCalculation));
305 
306   /* Check the SPI instance is not enabled */
307   if (LL_SPI_IsEnabled(SPIx) == 0x00000000UL)
308   {
309     /*---------------------------- SPIx CFG1 Configuration ------------------------
310        * Configure SPIx CFG1 with parameters:
311        * - Master Baud Rate       : SPI_CFG1_MBR[2:0] bits & SPI_CFG1_BPASS bit
312        * - CRC Computation Enable : SPI_CFG1_CRCEN bit
313        * - Length of data frame   : SPI_CFG1_DSIZE[4:0] bits
314        */
315     MODIFY_REG(SPIx->CFG1, SPI_CFG1_BPASS | SPI_CFG1_MBR | SPI_CFG1_CRCEN | SPI_CFG1_DSIZE,
316                SPI_InitStruct->BaudRate  | SPI_InitStruct->CRCCalculation | SPI_InitStruct->DataWidth);
317 
318     tmp_nss  = SPI_InitStruct->NSS;
319     tmp_mode = SPI_InitStruct->Mode;
320     tmp_nss_polarity = LL_SPI_GetNSSPolarity(SPIx);
321 
322     /* Checks to setup Internal SS signal level and avoid a MODF Error */
323     if ((tmp_nss == LL_SPI_NSS_SOFT) && (((tmp_nss_polarity == LL_SPI_NSS_POLARITY_LOW)  && \
324                                           (tmp_mode == LL_SPI_MODE_MASTER))              || \
325                                          ((tmp_nss_polarity == LL_SPI_NSS_POLARITY_HIGH) && \
326                                           (tmp_mode == LL_SPI_MODE_SLAVE))))
327     {
328       LL_SPI_SetInternalSSLevel(SPIx, LL_SPI_SS_LEVEL_HIGH);
329     }
330 
331     /*---------------------------- SPIx CFG2 Configuration ------------------------
332        * Configure SPIx CFG2 with parameters:
333        * - NSS management         : SPI_CFG2_SSM, SPI_CFG2_SSOE bits
334        * - ClockPolarity          : SPI_CFG2_CPOL bit
335        * - ClockPhase             : SPI_CFG2_CPHA bit
336        * - BitOrder               : SPI_CFG2_LSBFRST bit
337        * - Master/Slave Mode      : SPI_CFG2_MASTER bit
338        * - SPI Mode               : SPI_CFG2_COMM[1:0] bits
339        */
340     MODIFY_REG(SPIx->CFG2, SPI_CFG2_SSM   | SPI_CFG2_SSOE    |
341                SPI_CFG2_CPOL              | SPI_CFG2_CPHA    |
342                SPI_CFG2_LSBFRST           | SPI_CFG2_MASTER  | SPI_CFG2_COMM,
343                SPI_InitStruct->NSS        | SPI_InitStruct->ClockPolarity                    |
344                SPI_InitStruct->ClockPhase | SPI_InitStruct->BitOrder                         |
345                SPI_InitStruct->Mode       | (SPI_InitStruct->TransferDirection & SPI_CFG2_COMM));
346 
347     /*---------------------------- SPIx CR1 Configuration ------------------------
348        * Configure SPIx CR1 with parameter:
349        * - Half Duplex Direction  : SPI_CR1_HDDIR bit
350        */
351     MODIFY_REG(SPIx->CR1, SPI_CR1_HDDIR, SPI_InitStruct->TransferDirection & SPI_CR1_HDDIR);
352 
353     /*---------------------------- SPIx CRCPOLY Configuration ----------------------
354        * Configure SPIx CRCPOLY with parameter:
355        * - CRCPoly                : CRCPOLY[31:0] bits
356        */
357     if (SPI_InitStruct->CRCCalculation == LL_SPI_CRCCALCULATION_ENABLE)
358     {
359       assert_param(IS_LL_SPI_CRC_POLYNOMIAL(SPI_InitStruct->CRCPoly));
360       LL_SPI_SetCRCPolynomial(SPIx, SPI_InitStruct->CRCPoly);
361     }
362 
363 
364     status = SUCCESS;
365   }
366 
367   return status;
368 }
369 
370 /**
371   * @brief  Set each @ref LL_SPI_InitTypeDef field to default value.
372   * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
373   * whose fields will be set to default values.
374   * @retval None
375   */
LL_SPI_StructInit(LL_SPI_InitTypeDef * SPI_InitStruct)376 void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct)
377 {
378   /* Set SPI_InitStruct fields to default values */
379   SPI_InitStruct->TransferDirection = LL_SPI_FULL_DUPLEX;
380   SPI_InitStruct->Mode              = LL_SPI_MODE_SLAVE;
381   SPI_InitStruct->DataWidth         = LL_SPI_DATAWIDTH_8BIT;
382   SPI_InitStruct->ClockPolarity     = LL_SPI_POLARITY_LOW;
383   SPI_InitStruct->ClockPhase        = LL_SPI_PHASE_1EDGE;
384   SPI_InitStruct->NSS               = LL_SPI_NSS_HARD_INPUT;
385   SPI_InitStruct->BaudRate          = LL_SPI_BAUDRATEPRESCALER_DIV2;
386   SPI_InitStruct->BitOrder          = LL_SPI_MSB_FIRST;
387   SPI_InitStruct->CRCCalculation    = LL_SPI_CRCCALCULATION_DISABLE;
388   SPI_InitStruct->CRCPoly           = 7UL;
389 }
390 
391 /**
392   * @}
393   */
394 
395 /**
396   * @}
397   */
398 
399 /**
400   * @}
401   */
402 
403 #endif /* defined(SPI1) || defined(SPI3) */
404 
405 /**
406   * @}
407   */
408 #endif /* USE_FULL_LL_DRIVER */
409