inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_i2s_ex.h
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief Header file of I2S HAL module.
NYX 0:85b3fd62ea1a 8 ******************************************************************************
NYX 0:85b3fd62ea1a 9 * @attention
NYX 0:85b3fd62ea1a 10 *
NYX 0:85b3fd62ea1a 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 14 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 15 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 16 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 18 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 19 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 21 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 22 * without specific prior written permission.
NYX 0:85b3fd62ea1a 23 *
NYX 0:85b3fd62ea1a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 34 *
NYX 0:85b3fd62ea1a 35 ******************************************************************************
NYX 0:85b3fd62ea1a 36 */
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 /* Define to prevent recursive inclusion -------------------------------------*/
NYX 0:85b3fd62ea1a 39 #ifndef __STM32F4xx_HAL_I2S_EX_H
NYX 0:85b3fd62ea1a 40 #define __STM32F4xx_HAL_I2S_EX_H
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 43 extern "C" {
NYX 0:85b3fd62ea1a 44 #endif
NYX 0:85b3fd62ea1a 45
NYX 0:85b3fd62ea1a 46 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 47 #include "stm32f4xx_hal_def.h"
NYX 0:85b3fd62ea1a 48
NYX 0:85b3fd62ea1a 49 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 50 * @{
NYX 0:85b3fd62ea1a 51 */
NYX 0:85b3fd62ea1a 52 #if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
NYX 0:85b3fd62ea1a 53 /** @addtogroup I2SEx I2SEx
NYX 0:85b3fd62ea1a 54 * @{
NYX 0:85b3fd62ea1a 55 */
NYX 0:85b3fd62ea1a 56
NYX 0:85b3fd62ea1a 57 /* Exported types ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 58 /* Exported constants --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 59 /* Exported macros -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 60 /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
NYX 0:85b3fd62ea1a 61 * @{
NYX 0:85b3fd62ea1a 62 */
NYX 0:85b3fd62ea1a 63
NYX 0:85b3fd62ea1a 64 #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
NYX 0:85b3fd62ea1a 65
NYX 0:85b3fd62ea1a 66 /** @brief Enable or disable the specified I2SExt peripheral.
NYX 0:85b3fd62ea1a 67 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 68 * @retval None
NYX 0:85b3fd62ea1a 69 */
NYX 0:85b3fd62ea1a 70 #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
NYX 0:85b3fd62ea1a 71 #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
NYX 0:85b3fd62ea1a 72
NYX 0:85b3fd62ea1a 73 /** @brief Enable or disable the specified I2SExt interrupts.
NYX 0:85b3fd62ea1a 74 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 75 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
NYX 0:85b3fd62ea1a 76 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 77 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
NYX 0:85b3fd62ea1a 78 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
NYX 0:85b3fd62ea1a 79 * @arg I2S_IT_ERR: Error interrupt enable
NYX 0:85b3fd62ea1a 80 * @retval None
NYX 0:85b3fd62ea1a 81 */
NYX 0:85b3fd62ea1a 82 #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
NYX 0:85b3fd62ea1a 83 #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
NYX 0:85b3fd62ea1a 84
NYX 0:85b3fd62ea1a 85 /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled.
NYX 0:85b3fd62ea1a 86 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 87 * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
NYX 0:85b3fd62ea1a 88 * @param __INTERRUPT__: specifies the I2S interrupt source to check.
NYX 0:85b3fd62ea1a 89 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 90 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
NYX 0:85b3fd62ea1a 91 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
NYX 0:85b3fd62ea1a 92 * @arg I2S_IT_ERR: Error interrupt enable
NYX 0:85b3fd62ea1a 93 * @retval The new state of __IT__ (TRUE or FALSE).
NYX 0:85b3fd62ea1a 94 */
NYX 0:85b3fd62ea1a 95 #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
NYX 0:85b3fd62ea1a 96
NYX 0:85b3fd62ea1a 97 /** @brief Checks whether the specified I2SExt flag is set or not.
NYX 0:85b3fd62ea1a 98 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 99 * @param __FLAG__: specifies the flag to check.
NYX 0:85b3fd62ea1a 100 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 101 * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
NYX 0:85b3fd62ea1a 102 * @arg I2S_FLAG_TXE: Transmit buffer empty flag
NYX 0:85b3fd62ea1a 103 * @arg I2S_FLAG_UDR: Underrun flag
NYX 0:85b3fd62ea1a 104 * @arg I2S_FLAG_OVR: Overrun flag
NYX 0:85b3fd62ea1a 105 * @arg I2S_FLAG_FRE: Frame error flag
NYX 0:85b3fd62ea1a 106 * @arg I2S_FLAG_CHSIDE: Channel Side flag
NYX 0:85b3fd62ea1a 107 * @arg I2S_FLAG_BSY: Busy flag
NYX 0:85b3fd62ea1a 108 * @retval The new state of __FLAG__ (TRUE or FALSE).
NYX 0:85b3fd62ea1a 109 */
NYX 0:85b3fd62ea1a 110 #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
NYX 0:85b3fd62ea1a 111
NYX 0:85b3fd62ea1a 112 /** @brief Clears the I2SExt OVR pending flag.
NYX 0:85b3fd62ea1a 113 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 114 * @retval None
NYX 0:85b3fd62ea1a 115 */
NYX 0:85b3fd62ea1a 116 #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \
NYX 0:85b3fd62ea1a 117 __IO uint32_t tmpreg_ovr = 0x00U; \
NYX 0:85b3fd62ea1a 118 tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
NYX 0:85b3fd62ea1a 119 tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
NYX 0:85b3fd62ea1a 120 UNUSED(tmpreg_ovr); \
NYX 0:85b3fd62ea1a 121 }while(0U)
NYX 0:85b3fd62ea1a 122 /** @brief Clears the I2SExt UDR pending flag.
NYX 0:85b3fd62ea1a 123 * @param __HANDLE__: specifies the I2S Handle.
NYX 0:85b3fd62ea1a 124 * @retval None
NYX 0:85b3fd62ea1a 125 */
NYX 0:85b3fd62ea1a 126 #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \
NYX 0:85b3fd62ea1a 127 __IO uint32_t tmpreg_udr = 0x00U; \
NYX 0:85b3fd62ea1a 128 tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
NYX 0:85b3fd62ea1a 129 UNUSED(tmpreg_udr); \
NYX 0:85b3fd62ea1a 130 }while(0U)
NYX 0:85b3fd62ea1a 131 /**
NYX 0:85b3fd62ea1a 132 * @}
NYX 0:85b3fd62ea1a 133 */
NYX 0:85b3fd62ea1a 134
NYX 0:85b3fd62ea1a 135 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 136 /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
NYX 0:85b3fd62ea1a 137 * @{
NYX 0:85b3fd62ea1a 138 */
NYX 0:85b3fd62ea1a 139
NYX 0:85b3fd62ea1a 140 /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
NYX 0:85b3fd62ea1a 141 * @{
NYX 0:85b3fd62ea1a 142 */
NYX 0:85b3fd62ea1a 143
NYX 0:85b3fd62ea1a 144 /* Extended features functions *************************************************/
NYX 0:85b3fd62ea1a 145 /* Blocking mode: Polling */
NYX 0:85b3fd62ea1a 146 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
NYX 0:85b3fd62ea1a 147 uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 148 /* Non-Blocking mode: Interrupt */
NYX 0:85b3fd62ea1a 149 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
NYX 0:85b3fd62ea1a 150 uint16_t Size);
NYX 0:85b3fd62ea1a 151 /* Non-Blocking mode: DMA */
NYX 0:85b3fd62ea1a 152 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
NYX 0:85b3fd62ea1a 153 uint16_t Size);
NYX 0:85b3fd62ea1a 154 /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
NYX 0:85b3fd62ea1a 155 void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
NYX 0:85b3fd62ea1a 156 void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
NYX 0:85b3fd62ea1a 157 /**
NYX 0:85b3fd62ea1a 158 * @}
NYX 0:85b3fd62ea1a 159 */
NYX 0:85b3fd62ea1a 160
NYX 0:85b3fd62ea1a 161 /**
NYX 0:85b3fd62ea1a 162 * @}
NYX 0:85b3fd62ea1a 163 */
NYX 0:85b3fd62ea1a 164 /* Private types -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 165 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 166 /* Private constants ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 167 /* Private macros ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 168
NYX 0:85b3fd62ea1a 169 /**
NYX 0:85b3fd62ea1a 170 * @}
NYX 0:85b3fd62ea1a 171 */
NYX 0:85b3fd62ea1a 172
NYX 0:85b3fd62ea1a 173 /* Private functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 174
NYX 0:85b3fd62ea1a 175 /**
NYX 0:85b3fd62ea1a 176 * @}
NYX 0:85b3fd62ea1a 177 */
NYX 0:85b3fd62ea1a 178
NYX 0:85b3fd62ea1a 179 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
NYX 0:85b3fd62ea1a 180 /**
NYX 0:85b3fd62ea1a 181 * @}
NYX 0:85b3fd62ea1a 182 */
NYX 0:85b3fd62ea1a 183
NYX 0:85b3fd62ea1a 184 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 185 }
NYX 0:85b3fd62ea1a 186 #endif
NYX 0:85b3fd62ea1a 187
NYX 0:85b3fd62ea1a 188
NYX 0:85b3fd62ea1a 189 #endif /* __STM32F4xx_HAL_I2S_EX_H */
NYX 0:85b3fd62ea1a 190
NYX 0:85b3fd62ea1a 191 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/