You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

116 lines
3.1 KiB

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