]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube/ST_Code/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c
Make vSetupTimerInterrupt weak in the RVDS M4 MPU port to give the
[freertos] / FreeRTOS / Demo / CORTEX_MPU_STM32L4_Discovery_Keil_STM32Cube / ST_Code / Drivers / STM32L4xx_HAL_Driver / Src / stm32l4xx_hal_spi_ex.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l4xx_hal_spi_ex.c\r
4   * @author  MCD Application Team\r
5   * @brief   Extended SPI HAL module driver.\r
6   *          This file provides firmware functions to manage the following\r
7   *          SPI peripheral extended functionalities :\r
8   *           + IO operation functions\r
9   *\r
10   ******************************************************************************\r
11   * @attention\r
12   *\r
13   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.\r
14   * All rights reserved.</center></h2>\r
15   *\r
16   * This software component is licensed by ST under BSD 3-Clause license,\r
17   * the "License"; You may not use this file except in compliance with the\r
18   * License. You may obtain a copy of the License at:\r
19   *                        opensource.org/licenses/BSD-3-Clause\r
20   *\r
21   ******************************************************************************\r
22   */\r
23 \r
24 /* Includes ------------------------------------------------------------------*/\r
25 #include "stm32l4xx_hal.h"\r
26 \r
27 /** @addtogroup STM32L4xx_HAL_Driver\r
28   * @{\r
29   */\r
30 \r
31 /** @defgroup SPIEx SPIEx\r
32   * @brief SPI Extended HAL module driver\r
33   * @{\r
34   */\r
35 #ifdef HAL_SPI_MODULE_ENABLED\r
36 \r
37 /* Private typedef -----------------------------------------------------------*/\r
38 /* Private defines -----------------------------------------------------------*/\r
39 /** @defgroup SPIEx_Private_Constants SPIEx Private Constants\r
40   * @{\r
41   */\r
42 #define SPI_FIFO_SIZE       4UL\r
43 /**\r
44   * @}\r
45   */\r
46 \r
47 /* Private macros ------------------------------------------------------------*/\r
48 /* Private variables ---------------------------------------------------------*/\r
49 /* Private function prototypes -----------------------------------------------*/\r
50 /* Exported functions --------------------------------------------------------*/\r
51 \r
52 /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions\r
53   * @{\r
54   */\r
55 \r
56 /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions\r
57   *  @brief   Data transfers functions\r
58   *\r
59 @verbatim\r
60   ==============================================================================\r
61                       ##### IO operation functions #####\r
62  ===============================================================================\r
63  [..]\r
64     This subsection provides a set of extended functions to manage the SPI\r
65     data transfers.\r
66 \r
67     (#) Rx data flush function:\r
68         (++) HAL_SPIEx_FlushRxFifo()\r
69 \r
70 @endverbatim\r
71   * @{\r
72   */\r
73 \r
74 /**\r
75   * @brief  Flush the RX fifo.\r
76   * @param  hspi pointer to a SPI_HandleTypeDef structure that contains\r
77   *               the configuration information for the specified SPI module.\r
78   * @retval HAL status\r
79   */\r
80 HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi)\r
81 {\r
82   __IO uint32_t tmpreg;\r
83   uint8_t  count = 0U;\r
84   while ((hspi->Instance->SR & SPI_FLAG_FRLVL) !=  SPI_FRLVL_EMPTY)\r
85   {\r
86     count++;\r
87     tmpreg = hspi->Instance->DR;\r
88     UNUSED(tmpreg); /* To avoid GCC warning */\r
89     if (count == SPI_FIFO_SIZE)\r
90     {\r
91       return HAL_TIMEOUT;\r
92     }\r
93   }\r
94   return HAL_OK;\r
95 }\r
96 \r
97 /**\r
98   * @}\r
99   */\r
100 \r
101 /**\r
102   * @}\r
103   */\r
104 \r
105 #endif /* HAL_SPI_MODULE_ENABLED */\r
106 \r
107 /**\r
108   * @}\r
109   */\r
110 \r
111 /**\r
112   * @}\r
113   */\r
114 \r
115 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r