2 ******************************************************************************
\r
3 * @file stm32l1xx_spi.c
\r
4 * @author MCD Application Team
\r
6 * @date 05-March-2012
\r
7 * @brief This file provides firmware functions to manage the following
\r
8 * functionalities of the Serial peripheral interface (SPI):
\r
9 * + Initialization and Configuration
\r
10 * + Data transfers functions
\r
11 * + Hardware CRC Calculation
\r
12 * + DMA transfers management
\r
13 * + Interrupts and flags management
\r
16 [..] The I2S feature is not implemented in STM32L1xx Ultra Low Power
\r
17 Medium-density devices and it's supported only STM32L1xx Ultra Low Power
\r
18 Medium-density Plus and High-density devices.
\r
20 ===============================================================================
\r
21 ##### How to use this driver #####
\r
22 ===============================================================================
\r
24 (#) Enable peripheral clock using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE)
\r
25 function for SPI1 or using RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE)
\r
26 function for SPI2 or using RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE)
\r
29 (#) Enable SCK, MOSI, MISO and NSS GPIO clocks using
\r
30 RCC_AHBPeriphClockCmd() function.
\r
32 (#) Peripherals alternate function:
\r
33 (++) Connect the pin to the desired peripherals' Alternate
\r
34 Function (AF) using GPIO_PinAFConfig() function.
\r
35 (++) Configure the desired pin in alternate function by:
\r
36 GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF.
\r
37 (++) Select the type, pull-up/pull-down and output speed via
\r
38 GPIO_PuPd, GPIO_OType and GPIO_Speed members.
\r
39 (++) Call GPIO_Init() function.
\r
41 (#) Program the Polarity, Phase, First Data, Baud Rate Prescaler, Slave
\r
42 Management, Peripheral Mode and CRC Polynomial values using the SPI_Init()
\r
43 function.In I2S mode, program the Mode, Standard, Data Format, MCLK
\r
44 Output, Audio frequency and Polarity using I2S_Init() function.
\r
46 (#) Enable the NVIC and the corresponding interrupt using the function
\r
47 SPI_ITConfig() if you need to use interrupt mode.
\r
49 (#) When using the DMA mode
\r
50 (++) Configure the DMA using DMA_Init() function.
\r
51 (++) Active the needed channel Request using SPI_I2S_DMACmd() function.
\r
53 (#) Enable the SPI using the SPI_Cmd() function or enable the I2S using
\r
56 (#) Enable the DMA using the DMA_Cmd() function when using DMA mode.
\r
58 (#) Optionally, you can enable/configure the following parameters without
\r
59 re-initialization (i.e there is no need to call again SPI_Init() function):
\r
60 (++) When bidirectional mode (SPI_Direction_1Line_Rx or SPI_Direction_1Line_Tx)
\r
61 is programmed as Data direction parameter using the SPI_Init()
\r
62 function it can be possible to switch between SPI_Direction_Tx
\r
63 or SPI_Direction_Rx using the SPI_BiDirectionalLineConfig() function.
\r
64 (++) When SPI_NSS_Soft is selected as Slave Select Management parameter
\r
65 using the SPI_Init() function it can be possible to manage the
\r
66 NSS internal signal using the SPI_NSSInternalSoftwareConfig() function.
\r
67 (++) Reconfigure the data size using the SPI_DataSizeConfig() function.
\r
68 (++) Enable or disable the SS output using the SPI_SSOutputCmd() function.
\r
70 (#) To use the CRC Hardware calculation feature refer to the Peripheral
\r
71 CRC hardware Calculation subsection.
\r
75 ******************************************************************************
\r
78 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
\r
80 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
81 * You may not use this file except in compliance with the License.
\r
82 * You may obtain a copy of the License at:
\r
84 * http://www.st.com/software_license_agreement_liberty_v2
\r
86 * Unless required by applicable law or agreed to in writing, software
\r
87 * distributed under the License is distributed on an "AS IS" BASIS,
\r
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
89 * See the License for the specific language governing permissions and
\r
90 * limitations under the License.
\r
92 ******************************************************************************
\r
95 /* Includes ------------------------------------------------------------------*/
\r
96 #include "stm32l1xx_spi.h"
\r
97 #include "stm32l1xx_rcc.h"
\r
99 /** @addtogroup STM32L1xx_StdPeriph_Driver
\r
104 * @brief SPI driver modules
\r
108 /* Private typedef -----------------------------------------------------------*/
\r
109 /* Private define ------------------------------------------------------------*/
\r
110 /* SPI registers Masks */
\r
111 #define CR1_CLEAR_MASK ((uint16_t)0x3040)
\r
112 #define I2SCFGR_CLEAR_Mask ((uint16_t)0xF040)
\r
114 /* Private macro -------------------------------------------------------------*/
\r
115 /* Private variables ---------------------------------------------------------*/
\r
116 /* Private function prototypes -----------------------------------------------*/
\r
117 /* Private functions ---------------------------------------------------------*/
\r
119 /** @defgroup SPI_Private_Functions
\r
123 /** @defgroup SPI_Group1 Initialization and Configuration functions
\r
124 * @brief Initialization and Configuration functions
\r
127 ===============================================================================
\r
128 ##### Initialization and Configuration functions #####
\r
129 ===============================================================================
\r
130 [..] This section provides a set of functions allowing to initialize the SPI
\r
131 Direction, SPI Mode, SPI Data Size, SPI Polarity, SPI Phase, SPI NSS
\r
132 Management, SPI Baud Rate Prescaler, SPI First Bit and SPI CRC Polynomial.
\r
133 [..] The SPI_Init() function follows the SPI configuration procedures for
\r
134 Master mode and Slave mode (details for these procedures are available
\r
135 in reference manual (RM0038)).
\r
142 * @brief Deinitializes the SPIx peripheral registers to their default
\r
144 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
145 * in SPI mode or 2 or 3 in I2S mode.
\r
148 void SPI_I2S_DeInit(SPI_TypeDef* SPIx)
\r
150 /* Check the parameters */
\r
151 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
155 /* Enable SPI1 reset state */
\r
156 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
\r
157 /* Release SPI1 from reset state */
\r
158 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
\r
160 else if (SPIx == SPI2)
\r
162 /* Enable SPI2 reset state */
\r
163 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
\r
164 /* Release SPI2 from reset state */
\r
165 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
\r
171 /* Enable SPI3 reset state */
\r
172 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);
\r
173 /* Release SPI3 from reset state */
\r
174 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE);
\r
180 * @brief Initializes the SPIx peripheral according to the specified
\r
181 * parameters in the SPI_InitStruct.
\r
182 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
183 * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure that
\r
184 * contains the configuration information for the specified SPI peripheral.
\r
187 void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct)
\r
189 uint16_t tmpreg = 0;
\r
191 /* check the parameters */
\r
192 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
194 /* Check the SPI parameters */
\r
195 assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction));
\r
196 assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
\r
197 assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize));
\r
198 assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
\r
199 assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
\r
200 assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS));
\r
201 assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler));
\r
202 assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
\r
203 assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial));
\r
205 /*---------------------------- SPIx CR1 Configuration ------------------------*/
\r
206 /* Get the SPIx CR1 value */
\r
207 tmpreg = SPIx->CR1;
\r
208 /* Clear BIDIMode, BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits */
\r
209 tmpreg &= CR1_CLEAR_MASK;
\r
210 /* Configure SPIx: direction, NSS management, first transmitted bit, BaudRate prescaler
\r
211 master/salve mode, CPOL and CPHA */
\r
212 /* Set BIDImode, BIDIOE and RxONLY bits according to SPI_Direction value */
\r
213 /* Set SSM, SSI and MSTR bits according to SPI_Mode and SPI_NSS values */
\r
214 /* Set LSBFirst bit according to SPI_FirstBit value */
\r
215 /* Set BR bits according to SPI_BaudRatePrescaler value */
\r
216 /* Set CPOL bit according to SPI_CPOL value */
\r
217 /* Set CPHA bit according to SPI_CPHA value */
\r
218 tmpreg |= (uint16_t)((uint32_t)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode |
\r
219 SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL |
\r
220 SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS |
\r
221 SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit);
\r
222 /* Write to SPIx CR1 */
\r
223 SPIx->CR1 = tmpreg;
\r
225 /* Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) */
\r
226 SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SMOD);
\r
227 /*---------------------------- SPIx CRCPOLY Configuration --------------------*/
\r
228 /* Write to SPIx CRCPOLY */
\r
229 SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
\r
233 * @brief Initializes the SPIx peripheral according to the specified
\r
234 * parameters in the I2S_InitStruct.
\r
235 * @param SPIx: where x can be 2 or 3 to select the SPI peripheral
\r
236 * (configured in I2S mode).
\r
237 * @param I2S_InitStruct: pointer to an I2S_InitTypeDef structure that
\r
238 * contains the configuration information for the specified SPI peripheral
\r
239 * configured in I2S mode.
\r
241 * The function calculates the optimal prescaler needed to obtain the most
\r
242 * accurate audio frequency (depending on the I2S clock source, the PLL values
\r
243 * and the product configuration). But in case the prescaler value is greater
\r
244 * than 511, the default value (0x02) will be configured instead.
\r
247 void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct)
\r
249 uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1;
\r
251 RCC_ClocksTypeDef RCC_Clocks;
\r
252 uint32_t sourceclock = 0;
\r
254 /* Check the I2S parameters */
\r
255 assert_param(IS_SPI_23_PERIPH(SPIx));
\r
256 assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode));
\r
257 assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard));
\r
258 assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat));
\r
259 assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput));
\r
260 assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq));
\r
261 assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL));
\r
263 /*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/
\r
264 /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
\r
265 SPIx->I2SCFGR &= I2SCFGR_CLEAR_Mask;
\r
266 SPIx->I2SPR = 0x0002;
\r
268 /* Get the I2SCFGR register value */
\r
269 tmpreg = SPIx->I2SCFGR;
\r
271 /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/
\r
272 if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default)
\r
274 i2sodd = (uint16_t)0;
\r
275 i2sdiv = (uint16_t)2;
\r
277 /* If the requested audio frequency is not the default, compute the prescaler */
\r
280 /* Check the frame length (For the Prescaler computing) */
\r
281 if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b)
\r
283 /* Packet length is 16 bits */
\r
288 /* Packet length is 32 bits */
\r
292 /* I2S Clock source is System clock: Get System Clock frequency */
\r
293 RCC_GetClocksFreq(&RCC_Clocks);
\r
295 /* Get the source clock value: based on System Clock value */
\r
296 sourceclock = RCC_Clocks.SYSCLK_Frequency;
\r
298 /* Compute the Real divider depending on the MCLK output state with a flaoting point */
\r
299 if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable)
\r
301 /* MCLK output is enabled */
\r
302 tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5);
\r
306 /* MCLK output is disabled */
\r
307 tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5);
\r
310 /* Remove the flaoting point */
\r
313 /* Check the parity of the divider */
\r
314 i2sodd = (uint16_t)(tmp & (uint16_t)0x0001);
\r
316 /* Compute the i2sdiv prescaler */
\r
317 i2sdiv = (uint16_t)((tmp - i2sodd) / 2);
\r
319 /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
\r
320 i2sodd = (uint16_t) (i2sodd << 8);
\r
323 /* Test if the divider is 1 or 0 or greater than 0xFF */
\r
324 if ((i2sdiv < 2) || (i2sdiv > 0xFF))
\r
326 /* Set the default values */
\r
331 /* Write to SPIx I2SPR register the computed value */
\r
332 SPIx->I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput));
\r
334 /* Configure the I2S with the SPI_InitStruct values */
\r
335 tmpreg |= (uint16_t)(SPI_I2SCFGR_I2SMOD | (uint16_t)(I2S_InitStruct->I2S_Mode | \
\r
336 (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \
\r
337 (uint16_t)I2S_InitStruct->I2S_CPOL))));
\r
339 /* Write to SPIx I2SCFGR */
\r
340 SPIx->I2SCFGR = tmpreg;
\r
344 * @brief Fills each SPI_InitStruct member with its default value.
\r
345 * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure which will be initialized.
\r
348 void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
\r
350 /*--------------- Reset SPI init structure parameters values -----------------*/
\r
351 /* Initialize the SPI_Direction member */
\r
352 SPI_InitStruct->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
\r
353 /* initialize the SPI_Mode member */
\r
354 SPI_InitStruct->SPI_Mode = SPI_Mode_Slave;
\r
355 /* initialize the SPI_DataSize member */
\r
356 SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b;
\r
357 /* Initialize the SPI_CPOL member */
\r
358 SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low;
\r
359 /* Initialize the SPI_CPHA member */
\r
360 SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge;
\r
361 /* Initialize the SPI_NSS member */
\r
362 SPI_InitStruct->SPI_NSS = SPI_NSS_Hard;
\r
363 /* Initialize the SPI_BaudRatePrescaler member */
\r
364 SPI_InitStruct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
\r
365 /* Initialize the SPI_FirstBit member */
\r
366 SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB;
\r
367 /* Initialize the SPI_CRCPolynomial member */
\r
368 SPI_InitStruct->SPI_CRCPolynomial = 7;
\r
372 * @brief Fills each I2S_InitStruct member with its default value.
\r
373 * @param I2S_InitStruct: pointer to a I2S_InitTypeDef structure which will be initialized.
\r
376 void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct)
\r
378 /*--------------- Reset I2S init structure parameters values -----------------*/
\r
379 /* Initialize the I2S_Mode member */
\r
380 I2S_InitStruct->I2S_Mode = I2S_Mode_SlaveTx;
\r
382 /* Initialize the I2S_Standard member */
\r
383 I2S_InitStruct->I2S_Standard = I2S_Standard_Phillips;
\r
385 /* Initialize the I2S_DataFormat member */
\r
386 I2S_InitStruct->I2S_DataFormat = I2S_DataFormat_16b;
\r
388 /* Initialize the I2S_MCLKOutput member */
\r
389 I2S_InitStruct->I2S_MCLKOutput = I2S_MCLKOutput_Disable;
\r
391 /* Initialize the I2S_AudioFreq member */
\r
392 I2S_InitStruct->I2S_AudioFreq = I2S_AudioFreq_Default;
\r
394 /* Initialize the I2S_CPOL member */
\r
395 I2S_InitStruct->I2S_CPOL = I2S_CPOL_Low;
\r
399 * @brief Enables or disables the specified SPI peripheral.
\r
400 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
401 * @param NewState: new state of the SPIx peripheral.
\r
402 * This parameter can be: ENABLE or DISABLE.
\r
405 void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
\r
407 /* Check the parameters */
\r
408 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
409 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
410 if (NewState != DISABLE)
\r
412 /* Enable the selected SPI peripheral */
\r
413 SPIx->CR1 |= SPI_CR1_SPE;
\r
417 /* Disable the selected SPI peripheral */
\r
418 SPIx->CR1 &= (uint16_t)~((uint16_t)SPI_CR1_SPE);
\r
423 * @brief Enables or disables the specified SPI peripheral (in I2S mode).
\r
424 * @param SPIx: where x can be 2 or 3 to select the SPI peripheral.
\r
425 * @param NewState: new state of the SPIx peripheral.
\r
426 * This parameter can be: ENABLE or DISABLE.
\r
429 void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
\r
431 /* Check the parameters */
\r
432 assert_param(IS_SPI_23_PERIPH(SPIx));
\r
433 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
435 if (NewState != DISABLE)
\r
437 /* Enable the selected SPI peripheral (in I2S mode) */
\r
438 SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE;
\r
442 /* Disable the selected SPI peripheral in I2S mode */
\r
443 SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE);
\r
448 * @brief Configures the data size for the selected SPI.
\r
449 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
450 * @param SPI_DataSize: specifies the SPI data size.
\r
451 * This parameter can be one of the following values:
\r
452 * @arg SPI_DataSize_16b: Set data frame format to 16bit.
\r
453 * @arg SPI_DataSize_8b: Set data frame format to 8bit.
\r
456 void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize)
\r
458 /* Check the parameters */
\r
459 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
460 assert_param(IS_SPI_DATASIZE(SPI_DataSize));
\r
461 /* Clear DFF bit */
\r
462 SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b;
\r
463 /* Set new DFF bit value */
\r
464 SPIx->CR1 |= SPI_DataSize;
\r
468 * @brief Selects the data transfer direction in bidirectional mode for the specified SPI.
\r
469 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
470 * @param SPI_Direction: specifies the data transfer direction in bidirectional mode.
\r
471 * This parameter can be one of the following values:
\r
472 * @arg SPI_Direction_Tx: Selects Tx transmission direction.
\r
473 * @arg SPI_Direction_Rx: Selects Rx receive direction.
\r
476 void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction)
\r
478 /* Check the parameters */
\r
479 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
480 assert_param(IS_SPI_DIRECTION(SPI_Direction));
\r
481 if (SPI_Direction == SPI_Direction_Tx)
\r
483 /* Set the Tx only mode */
\r
484 SPIx->CR1 |= SPI_Direction_Tx;
\r
488 /* Set the Rx only mode */
\r
489 SPIx->CR1 &= SPI_Direction_Rx;
\r
494 * @brief Configures internally by software the NSS pin for the selected SPI.
\r
495 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
496 * @param SPI_NSSInternalSoft: specifies the SPI NSS internal state.
\r
497 * This parameter can be one of the following values:
\r
498 * @arg SPI_NSSInternalSoft_Set: Set NSS pin internally.
\r
499 * @arg SPI_NSSInternalSoft_Reset: Reset NSS pin internally.
\r
502 void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft)
\r
504 /* Check the parameters */
\r
505 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
506 assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft));
\r
507 if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset)
\r
509 /* Set NSS pin internally by software */
\r
510 SPIx->CR1 |= SPI_NSSInternalSoft_Set;
\r
514 /* Reset NSS pin internally by software */
\r
515 SPIx->CR1 &= SPI_NSSInternalSoft_Reset;
\r
520 * @brief Enables or disables the SS output for the selected SPI.
\r
521 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
522 * @param NewState: new state of the SPIx SS output.
\r
523 * This parameter can be: ENABLE or DISABLE.
\r
526 void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState)
\r
528 /* Check the parameters */
\r
529 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
530 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
531 if (NewState != DISABLE)
\r
533 /* Enable the selected SPI SS output */
\r
534 SPIx->CR2 |= (uint16_t)SPI_CR2_SSOE;
\r
538 /* Disable the selected SPI SS output */
\r
539 SPIx->CR2 &= (uint16_t)~((uint16_t)SPI_CR2_SSOE);
\r
547 /** @defgroup SPI_Group2 Data transfers functions
\r
548 * @brief Data transfers functions
\r
551 ===============================================================================
\r
552 ##### Data transfers functions #####
\r
553 ===============================================================================
\r
554 ....[..] This section provides a set of functions allowing to manage the SPI data
\r
556 ....[..] In reception, data are received and then stored into an internal Rx buffer
\r
557 while In transmission, data are first stored into an internal Tx buffer
\r
558 before being transmitted.
\r
559 ....[..] The read access of the SPI_DR register can be done using the
\r
560 SPI_I2S_ReceiveData() function and returns the Rx buffered value.
\r
561 Whereas a write access to the SPI_DR can be done using SPI_I2S_SendData()
\r
562 function and stores the written data into Tx buffer.
\r
569 * @brief Returns the most recent received data by the SPIx/I2Sx peripheral.
\r
570 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
571 * in SPI mode or 2 or 3 in I2S mode.
\r
572 * @retval The value of the received data.
\r
574 uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx)
\r
576 /* Check the parameters */
\r
577 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
579 /* Return the data in the DR register */
\r
584 * @brief Transmits a Data through the SPIx/I2Sx peripheral.
\r
585 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
586 * in SPI mode or 2 or 3 in I2S mode.
\r
587 * @param Data: Data to be transmitted.
\r
590 void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data)
\r
592 /* Check the parameters */
\r
593 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
595 /* Write in the DR register the data to be sent */
\r
603 /** @defgroup SPI_Group3 Hardware CRC Calculation functions
\r
604 * @brief Hardware CRC Calculation functions
\r
607 ===============================================================================
\r
608 ##### Hardware CRC Calculation functions #####
\r
609 ===============================================================================
\r
610 [..] This section provides a set of functions allowing to manage the SPI CRC
\r
611 hardware calculation SPI communication using CRC is possible through
\r
612 the following procedure:
\r
613 (#) Program the Data direction, Polarity, Phase, First Data, Baud Rate
\r
614 Prescaler, Slave Management, Peripheral Mode and CRC Polynomial
\r
615 values using the SPI_Init() function.
\r
616 (#) Enable the CRC calculation using the SPI_CalculateCRC() function.
\r
617 (#) Enable the SPI using the SPI_Cmd() function.
\r
618 (#) Before writing the last data to the TX buffer, set the CRCNext bit
\r
619 using the SPI_TransmitCRC() function to indicate that after
\r
620 transmission of the last data, the CRC should be transmitted.
\r
621 (#) After transmitting the last data, the SPI transmits the CRC.
\r
622 The SPI_CR1_CRCNEXT bit is reset. The CRC is also received and
\r
623 compared against the SPI_RXCRCR value.
\r
624 If the value does not match, the SPI_FLAG_CRCERR flag is set and an
\r
625 interrupt can be generated when the SPI_I2S_IT_ERR interrupt is enabled.
\r
627 (+@) It is advised to don't read the calculate CRC values during the communication.
\r
628 (+@) When the SPI is in slave mode, be careful to enable CRC calculation only
\r
629 when the clock is stable, that is, when the clock is in the steady state.
\r
630 If not, a wrong CRC calculation may be done. In fact, the CRC is sensitive
\r
631 to the SCK slave input clock as soon as CRCEN is set, and this, whatever
\r
632 the value of the SPE bit.
\r
633 (+@) With high bitrate frequencies, be careful when transmitting the CRC.
\r
634 As the number of used CPU cycles has to be as low as possible in the CRC
\r
635 transfer phase, it is forbidden to call software functions in the CRC
\r
636 transmission sequence to avoid errors in the last data and CRC reception.
\r
637 In fact, CRCNEXT bit has to be written before the end of the transmission/
\r
638 reception of the last data.
\r
639 (+@) For high bit rate frequencies, it is advised to use the DMA mode to avoid the
\r
640 degradation of the SPI speed performance due to CPU accesses impacting the
\r
642 (+@) When the STM32L15xxx are configured as slaves and the NSS hardware mode is
\r
643 used, the NSS pin needs to be kept low between the data phase and the CRC
\r
645 (+@) When the SPI is configured in slave mode with the CRC feature enabled, CRC
\r
646 calculation takes place even if a high level is applied on the NSS pin.
\r
647 This may happen for example in case of a multislave environment where the
\r
648 communication master addresses slaves alternately.
\r
649 (+@) Between a slave deselection (high level on NSS) and a new slave selection
\r
650 (low level on NSS), the CRC value should be cleared on both master and slave
\r
651 sides in order to resynchronize the master and slave for their respective
\r
653 -@- To clear the CRC, follow the procedure below:
\r
654 (#@) Disable SPI using the SPI_Cmd() function
\r
655 (#@) Disable the CRC calculation using the SPI_CalculateCRC() function.
\r
656 (#@) Enable the CRC calculation using the SPI_CalculateCRC() function.
\r
657 (#@) Enable SPI using the SPI_Cmd() function.
\r
664 * @brief Enables or disables the CRC value calculation of the transferred bytes.
\r
665 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
666 * @param NewState: new state of the SPIx CRC value calculation.
\r
667 * This parameter can be: ENABLE or DISABLE.
\r
670 void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState)
\r
672 /* Check the parameters */
\r
673 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
674 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
675 if (NewState != DISABLE)
\r
677 /* Enable the selected SPI CRC calculation */
\r
678 SPIx->CR1 |= SPI_CR1_CRCEN;
\r
682 /* Disable the selected SPI CRC calculation */
\r
683 SPIx->CR1 &= (uint16_t)~((uint16_t)SPI_CR1_CRCEN);
\r
688 * @brief Transmit the SPIx CRC value.
\r
689 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
692 void SPI_TransmitCRC(SPI_TypeDef* SPIx)
\r
694 /* Check the parameters */
\r
695 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
697 /* Enable the selected SPI CRC transmission */
\r
698 SPIx->CR1 |= SPI_CR1_CRCNEXT;
\r
702 * @brief Returns the transmit or the receive CRC register value for the specified SPI.
\r
703 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
704 * @param SPI_CRC: specifies the CRC register to be read.
\r
705 * This parameter can be one of the following values:
\r
706 * @arg SPI_CRC_Tx: Selects Tx CRC register.
\r
707 * @arg SPI_CRC_Rx: Selects Rx CRC register.
\r
708 * @retval The selected CRC register value.
\r
710 uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC)
\r
712 uint16_t crcreg = 0;
\r
713 /* Check the parameters */
\r
714 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
715 assert_param(IS_SPI_CRC(SPI_CRC));
\r
716 if (SPI_CRC != SPI_CRC_Rx)
\r
718 /* Get the Tx CRC register */
\r
719 crcreg = SPIx->TXCRCR;
\r
723 /* Get the Rx CRC register */
\r
724 crcreg = SPIx->RXCRCR;
\r
726 /* Return the selected CRC register */
\r
731 * @brief Returns the CRC Polynomial register value for the specified SPI.
\r
732 * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
\r
733 * @retval The CRC Polynomial register value.
\r
735 uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx)
\r
737 /* Check the parameters */
\r
738 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
740 /* Return the CRC polynomial register */
\r
741 return SPIx->CRCPR;
\r
748 /** @defgroup SPI_Group4 DMA transfers management functions
\r
749 * @brief DMA transfers management functions
\r
752 ===============================================================================
\r
753 ##### DMA transfers management functions #####
\r
754 ===============================================================================
\r
761 * @brief Enables or disables the SPIx/I2Sx DMA interface.
\r
762 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
763 * in SPI mode or 2 or 3 in I2S mode.
\r
764 * @param SPI_I2S_DMAReq: specifies the SPI DMA transfer request to be enabled or disabled.
\r
765 * This parameter can be any combination of the following values:
\r
766 * @arg SPI_I2S_DMAReq_Tx: Tx buffer DMA transfer request.
\r
767 * @arg SPI_I2S_DMAReq_Rx: Rx buffer DMA transfer request.
\r
768 * @param NewState: new state of the selected SPI DMA transfer request.
\r
769 * This parameter can be: ENABLE or DISABLE.
\r
772 void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState)
\r
774 /* Check the parameters */
\r
775 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
776 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
777 assert_param(IS_SPI_I2S_DMAREQ(SPI_I2S_DMAReq));
\r
779 if (NewState != DISABLE)
\r
781 /* Enable the selected SPI DMA requests */
\r
782 SPIx->CR2 |= SPI_I2S_DMAReq;
\r
786 /* Disable the selected SPI DMA requests */
\r
787 SPIx->CR2 &= (uint16_t)~SPI_I2S_DMAReq;
\r
795 /** @defgroup SPI_Group5 Interrupts and flags management functions
\r
796 * @brief Interrupts and flags management functions
\r
799 ===============================================================================
\r
800 ##### Interrupts and flags management functions #####
\r
801 ===============================================================================
\r
802 [..] This section provides a set of functions allowing to configure the SPI
\r
803 Interrupts sources and check or clear the flags or pending bits status.
\r
804 The user should identify which mode will be used in his application to
\r
805 manage the communication: Polling mode, Interrupt mode or DMA mode.
\r
806 *** Polling Mode ***
\r
807 ====================
\r
808 [..] In Polling Mode, the SPI/I2S communication can be managed by 9 flags:
\r
809 (#) SPI_I2S_FLAG_TXE : to indicate the status of the transmit buffer
\r
811 (#) SPI_I2S_FLAG_RXNE : to indicate the status of the receive buffer
\r
813 (#) SPI_I2S_FLAG_BSY : to indicate the state of the communication layer
\r
815 (#) SPI_FLAG_CRCERR : to indicate if a CRC Calculation error occur.
\r
816 (#) SPI_FLAG_MODF : to indicate if a Mode Fault error occur.
\r
817 (#) SPI_I2S_FLAG_OVR : to indicate if an Overrun error occur.
\r
818 (#) SPI_I2S_FLAG_FRE: to indicate a Frame Format error occurs.
\r
819 (#) I2S_FLAG_UDR: to indicate an Underrun error occurs.
\r
820 (#) I2S_FLAG_CHSIDE: to indicate Channel Side.
\r
821 -@- Do not use the BSY flag to handle each data transmission or reception.
\r
822 It is better to use the TXE and RXNE flags instead.
\r
823 [..] In this Mode it is advised to use the following functions:
\r
824 (+) FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG).
\r
825 (+) void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG).
\r
827 *** Interrupt Mode ***
\r
828 ======================
\r
829 [..] In Interrupt Mode, the SPI communication can be managed by 3 interrupt
\r
830 sources and 7 pending bits:
\r
832 (#) SPI_I2S_IT_TXE : to indicate the status of the transmit buffer register.
\r
833 (#) SPI_I2S_IT_RXNE : to indicate the status of the receive buffer register.
\r
834 (#) SPI_IT_CRCERR : to indicate if a CRC Calculation error occur.
\r
835 (#) SPI_IT_MODF : to indicate if a Mode Fault error occur.
\r
836 (#) SPI_I2S_IT_OVR : to indicate if an Overrun error occur.
\r
837 (#) I2S_IT_UDR : to indicate an Underrun Error occurs.
\r
838 (#) SPI_I2S_FLAG_FRE : to indicate a Frame Format error occurs.
\r
839 [..] Interrupt Source:
\r
840 (#) SPI_I2S_IT_TXE: specifies the interrupt source for the Tx buffer empty
\r
842 (#) SPI_I2S_IT_RXNE : specifies the interrupt source for the Rx buffer not
\r
844 (#) SPI_I2S_IT_ERR : specifies the interrupt source for the errors interrupt.
\r
845 [..] In this Mode it is advised to use the following functions:
\r
846 (+) void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT,
\r
847 FunctionalState NewState).
\r
848 (+) ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT).
\r
849 (+) void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT).
\r
853 [..] In DMA Mode, the SPI communication can be managed by 2 DMA Channel
\r
855 (#) SPI_I2S_DMAReq_Tx: specifies the Tx buffer DMA transfer request.
\r
856 (#) SPI_I2S_DMAReq_Rx: specifies the Rx buffer DMA transfer request.
\r
858 [..] In this Mode it is advised to use the following function:
\r
859 (+) void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq,
\r
860 FunctionalState NewState).
\r
867 * @brief Enables or disables the specified SPI/I2S interrupts.
\r
868 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
869 * in SPI mode or 2 or 3 in I2S mode.
\r
871 * @param SPI_I2S_IT: specifies the SPI interrupt source to be enabled or disabled.
\r
872 * This parameter can be one of the following values:
\r
873 * @arg SPI_I2S_IT_TXE: Tx buffer empty interrupt mask.
\r
874 * @arg SPI_I2S_IT_RXNE: Rx buffer not empty interrupt mask.
\r
875 * @arg SPI_I2S_IT_ERR: Error interrupt mask.
\r
876 * @param NewState: new state of the specified SPI interrupt.
\r
877 * This parameter can be: ENABLE or DISABLE.
\r
880 void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState)
\r
882 uint16_t itpos = 0, itmask = 0 ;
\r
884 /* Check the parameters */
\r
885 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
886 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
887 assert_param(IS_SPI_I2S_CONFIG_IT(SPI_I2S_IT));
\r
889 /* Get the SPI IT index */
\r
890 itpos = SPI_I2S_IT >> 4;
\r
892 /* Set the IT mask */
\r
893 itmask = (uint16_t)1 << (uint16_t)itpos;
\r
895 if (NewState != DISABLE)
\r
897 /* Enable the selected SPI interrupt */
\r
898 SPIx->CR2 |= itmask;
\r
902 /* Disable the selected SPI interrupt */
\r
903 SPIx->CR2 &= (uint16_t)~itmask;
\r
908 * @brief Checks whether the specified SPIx/I2Sx flag is set or not.
\r
909 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
910 * in SPI mode or 2 or 3 in I2S mode.
\r
912 * @param SPI_I2S_FLAG: specifies the SPI flag to check.
\r
913 * This parameter can be one of the following values:
\r
914 * @arg SPI_I2S_FLAG_TXE: Transmit buffer empty flag.
\r
915 * @arg SPI_I2S_FLAG_RXNE: Receive buffer not empty flag.
\r
916 * @arg SPI_I2S_FLAG_BSY: Busy flag.
\r
917 * @arg SPI_I2S_FLAG_OVR: Overrun flag.
\r
918 * @arg SPI_FLAG_MODF: Mode Fault flag.
\r
919 * @arg SPI_FLAG_CRCERR: CRC Error flag.
\r
920 * @arg SPI_I2S_FLAG_FRE: Format Error.
\r
921 * @arg I2S_FLAG_UDR: Underrun Error flag.
\r
922 * @arg I2S_FLAG_CHSIDE: Channel Side flag.
\r
923 * @retval The new state of SPI_I2S_FLAG (SET or RESET).
\r
925 FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
\r
927 FlagStatus bitstatus = RESET;
\r
928 /* Check the parameters */
\r
929 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
930 assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG));
\r
932 /* Check the status of the specified SPI flag */
\r
933 if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET)
\r
935 /* SPI_I2S_FLAG is set */
\r
940 /* SPI_I2S_FLAG is reset */
\r
943 /* Return the SPI_I2S_FLAG status */
\r
948 * @brief Clears the SPIx CRC Error (CRCERR) flag.
\r
949 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
950 * in SPI mode or 2 or 3 in I2S mode.
\r
952 * @param SPI_I2S_FLAG: specifies the SPI flag to clear.
\r
953 * This function clears only CRCERR flag.
\r
955 * @note OVR (OverRun error) flag is cleared by software sequence: a read
\r
956 * operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read
\r
957 * operation to SPI_SR register (SPI_I2S_GetFlagStatus()).
\r
958 * @note UDR (UnderRun error) flag is cleared by a read operation to
\r
959 * SPI_SR register (SPI_I2S_GetFlagStatus()).
\r
960 * @note MODF (Mode Fault) flag is cleared by software sequence: a read/write
\r
961 * operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a
\r
962 * write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
\r
965 void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
\r
967 /* Check the parameters */
\r
968 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
969 assert_param(IS_SPI_I2S_CLEAR_FLAG(SPI_I2S_FLAG));
\r
971 /* Clear the selected SPI CRC Error (CRCERR) flag */
\r
972 SPIx->SR = (uint16_t)~SPI_I2S_FLAG;
\r
976 * @brief Checks whether the specified SPIx/I2Sx interrupt has occurred or not.
\r
977 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
978 * in SPI mode or 2 or 3 in I2S mode.
\r
980 * @param SPI_I2S_IT: specifies the SPI interrupt source to check.
\r
981 * This parameter can be one of the following values:
\r
982 * @arg SPI_I2S_IT_TXE: Transmit buffer empty interrupt.
\r
983 * @arg SPI_I2S_IT_RXNE: Receive buffer not empty interrupt.
\r
984 * @arg SPI_I2S_IT_OVR: Overrun interrupt.
\r
985 * @arg SPI_IT_MODF: Mode Fault interrupt.
\r
986 * @arg SPI_IT_CRCERR: CRC Error interrupt.
\r
987 * @arg I2S_IT_UDR: Underrun interrupt.
\r
988 * @arg SPI_I2S_IT_FRE: Format Error interrupt.
\r
989 * @retval The new state of SPI_I2S_IT (SET or RESET).
\r
991 ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
\r
993 ITStatus bitstatus = RESET;
\r
994 uint16_t itpos = 0, itmask = 0, enablestatus = 0;
\r
996 /* Check the parameters */
\r
997 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
998 assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT));
\r
1000 /* Get the SPI_I2S_IT index */
\r
1001 itpos = 0x01 << (SPI_I2S_IT & 0x0F);
\r
1003 /* Get the SPI_I2S_IT IT mask */
\r
1004 itmask = SPI_I2S_IT >> 4;
\r
1006 /* Set the IT mask */
\r
1007 itmask = 0x01 << itmask;
\r
1009 /* Get the SPI_I2S_IT enable bit status */
\r
1010 enablestatus = (SPIx->CR2 & itmask) ;
\r
1012 /* Check the status of the specified SPI interrupt */
\r
1013 if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus)
\r
1015 /* SPI_I2S_IT is set */
\r
1020 /* SPI_I2S_IT is reset */
\r
1021 bitstatus = RESET;
\r
1023 /* Return the SPI_I2S_IT status */
\r
1028 * @brief Clears the SPIx CRC Error (CRCERR) interrupt pending bit.
\r
1029 * @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
\r
1030 * in SPI mode or 2 or 3 in I2S mode.
\r
1032 * @param SPI_I2S_IT: specifies the SPI interrupt pending bit to clear.
\r
1033 * This function clears only CRCERR interrupt pending bit.
\r
1035 * OVR (OverRun Error) interrupt pending bit is cleared by software
\r
1036 * sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData())
\r
1037 * followed by a read operation to SPI_SR register (SPI_I2S_GetITStatus()).
\r
1038 * @note UDR (UnderRun Error) interrupt pending bit is cleared by a read
\r
1039 * operation to SPI_SR register (SPI_I2S_GetITStatus()).
\r
1040 * @note MODF (Mode Fault) interrupt pending bit is cleared by software sequence:
\r
1041 * a read/write operation to SPI_SR register (SPI_I2S_GetITStatus())
\r
1042 * followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable
\r
1046 void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
\r
1048 uint16_t itpos = 0;
\r
1049 /* Check the parameters */
\r
1050 assert_param(IS_SPI_ALL_PERIPH(SPIx));
\r
1051 assert_param(IS_SPI_I2S_CLEAR_IT(SPI_I2S_IT));
\r
1053 /* Get the SPI_I2S IT index */
\r
1054 itpos = 0x01 << (SPI_I2S_IT & 0x0F);
\r
1056 /* Clear the selected SPI CRC Error (CRCERR) interrupt pending bit */
\r
1057 SPIx->SR = (uint16_t)~itpos;
\r
1076 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r