Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_hal_spi_ex.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_spi_ex.c 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Extended SPI HAL module driver. 00008 * This file provides firmware functions to manage the following 00009 * SPI peripheral extended functionalities : 00010 * + IO operation functions 00011 * 00012 ****************************************************************************** 00013 * @attention 00014 * 00015 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00016 * 00017 * Redistribution and use in source and binary forms, with or without modification, 00018 * are permitted provided that the following conditions are met: 00019 * 1. Redistributions of source code must retain the above copyright notice, 00020 * this list of conditions and the following disclaimer. 00021 * 2. Redistributions in binary form must reproduce the above copyright notice, 00022 * this list of conditions and the following disclaimer in the documentation 00023 * and/or other materials provided with the distribution. 00024 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00025 * may be used to endorse or promote products derived from this software 00026 * without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00029 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00030 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00031 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00032 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00033 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00034 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00036 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00037 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 * 00039 ****************************************************************************** 00040 */ 00041 00042 /* Includes ------------------------------------------------------------------*/ 00043 #include "stm32l4xx_hal.h" 00044 00045 /** @addtogroup STM32L4xx_HAL_Driver 00046 * @{ 00047 */ 00048 00049 /** @defgroup SPIEx SPIEx 00050 * @brief SPI Extended HAL module driver 00051 * @{ 00052 */ 00053 #ifdef HAL_SPI_MODULE_ENABLED 00054 00055 /* Private typedef -----------------------------------------------------------*/ 00056 /* Private defines -----------------------------------------------------------*/ 00057 /** @defgroup SPIEx_Private_Constants SPIEx Private Constants 00058 * @{ 00059 */ 00060 #define SPI_FIFO_SIZE 4 00061 /** 00062 * @} 00063 */ 00064 00065 /* Private macros ------------------------------------------------------------*/ 00066 /* Private variables ---------------------------------------------------------*/ 00067 /* Private function prototypes -----------------------------------------------*/ 00068 /* Exported functions ---------------------------------------------------------*/ 00069 00070 /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions 00071 * @{ 00072 */ 00073 00074 /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions 00075 * @brief Data transfers functions 00076 * 00077 @verbatim 00078 ============================================================================== 00079 ##### IO operation functions ##### 00080 =============================================================================== 00081 [..] 00082 This subsection provides a set of extended functions to manage the SPI 00083 data transfers. 00084 00085 (#) Rx data flush function: 00086 (++) HAL_SPIEx_FlushRxFifo() 00087 00088 @endverbatim 00089 * @{ 00090 */ 00091 00092 /** 00093 * @brief Flush the RX fifo. 00094 * @param hspi: pointer to a SPI_HandleTypeDef structure that contains 00095 * the configuration information for the specified SPI module. 00096 * @retval HAL status 00097 */ 00098 HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi) 00099 { 00100 __IO uint32_t tmpreg; 00101 uint8_t count = 0; 00102 while((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY) 00103 { 00104 count++; 00105 tmpreg = hspi->Instance->DR; 00106 UNUSED(tmpreg); /* To avoid GCC warning */ 00107 if(count == SPI_FIFO_SIZE) 00108 { 00109 return HAL_TIMEOUT; 00110 } 00111 } 00112 return HAL_OK; 00113 } 00114 00115 /** 00116 * @} 00117 */ 00118 00119 /** 00120 * @} 00121 */ 00122 00123 #endif /* HAL_SPI_MODULE_ENABLED */ 00124 00125 /** 00126 * @} 00127 */ 00128 00129 /** 00130 * @} 00131 */ 00132 00133 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00134
Generated on Tue Jul 12 2022 11:35:15 by 1.7.2