Subversion Repositories FuelGauge

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32f0xx_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) 2016 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
 
24
/* Includes ------------------------------------------------------------------*/
25
#include "stm32f0xx_hal.h"
26
 
27
/** @addtogroup STM32F0xx_HAL_Driver
28
  * @{
29
  */
30
 
31
/** @defgroup SPIEx SPIEx
32
  * @brief SPI Extended HAL module driver
33
  * @{
34
  */
35
#ifdef HAL_SPI_MODULE_ENABLED
36
 
37
/* Private typedef -----------------------------------------------------------*/
38
/* Private defines -----------------------------------------------------------*/
39
/** @defgroup SPIEx_Private_Constants SPIEx Private Constants
40
  * @{
41
  */
42
#define SPI_FIFO_SIZE       4UL
43
/**
44
  * @}
45
  */
46
 
47
/* Private macros ------------------------------------------------------------*/
48
/* Private variables ---------------------------------------------------------*/
49
/* Private function prototypes -----------------------------------------------*/
50
/* Exported functions --------------------------------------------------------*/
51
 
52
/** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions
53
  * @{
54
  */
55
 
56
/** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions
57
  *  @brief   Data transfers functions
58
  *
59
@verbatim
60
  ==============================================================================
61
                      ##### IO operation functions #####
62
 ===============================================================================
63
 [..]
64
    This subsection provides a set of extended functions to manage the SPI
65
    data transfers.
66
 
67
    (#) Rx data flush function:
68
        (++) HAL_SPIEx_FlushRxFifo()
69
 
70
@endverbatim
71
  * @{
72
  */
73
 
74
/**
75
  * @brief  Flush the RX fifo.
76
  * @param  hspi pointer to a SPI_HandleTypeDef structure that contains
77
  *               the configuration information for the specified SPI module.
78
  * @retval HAL status
79
  */
80
HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi)
81
{
82
  __IO uint32_t tmpreg;
83
  uint8_t  count = 0U;
84
  while ((hspi->Instance->SR & SPI_FLAG_FRLVL) !=  SPI_FRLVL_EMPTY)
85
  {
86
    count++;
87
    tmpreg = hspi->Instance->DR;
88
    UNUSED(tmpreg); /* To avoid GCC warning */
89
    if (count == SPI_FIFO_SIZE)
90
    {
91
      return HAL_TIMEOUT;
92
    }
93
  }
94
  return HAL_OK;
95
}
96
 
97
/**
98
  * @}
99
  */
100
 
101
/**
102
  * @}
103
  */
104
 
105
#endif /* HAL_SPI_MODULE_ENABLED */
106
 
107
/**
108
  * @}
109
  */
110
 
111
/**
112
  * @}
113
  */
114
 
115
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/