Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_hal_sai.c File Reference
SAI HAL module driver. This file provides firmware functions to manage the following functionalities of the Serial Audio Interface (SAI) peripheral: + Initialization/de-initialization functions + I/O operation functions + Peripheral Control functions + Peripheral State functions. More...
Go to the source code of this file.
Functions | |
static void | SAI_FillFifo (SAI_HandleTypeDef *hsai) |
Fill the fifo. | |
static int32_t | SAI_InterruptFlag (SAI_HandleTypeDef *hsai, uint32_t mode) |
Return the interrupt flag to set according the SAI setup. | |
static HAL_StatusTypeDef | SAI_InitI2S (SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot) |
Initialize the SAI I2S protocol according to the specified parameters in the SAI_InitTypeDef and create the associated handle. | |
static HAL_StatusTypeDef | SAI_InitPCM (SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot) |
Initialize the SAI PCM protocol according to the specified parameters in the SAI_InitTypeDef and create the associated handle. | |
static HAL_StatusTypeDef | SAI_Disable (SAI_HandleTypeDef *hsai) |
Disable the SAI and wait for the disabling. | |
static void | SAI_Transmit_IT8Bit (SAI_HandleTypeDef *hsai) |
Tx Handler for Transmit in Interrupt mode 8-bit transfer. | |
static void | SAI_Transmit_IT16Bit (SAI_HandleTypeDef *hsai) |
Tx Handler for Transmit in Interrupt mode for 16-bit transfer. | |
static void | SAI_Transmit_IT32Bit (SAI_HandleTypeDef *hsai) |
Tx Handler for Transmit in Interrupt mode for 32-bit transfer. | |
static void | SAI_Receive_IT8Bit (SAI_HandleTypeDef *hsai) |
Rx Handler for Receive in Interrupt mode 8-bit transfer. | |
static void | SAI_Receive_IT16Bit (SAI_HandleTypeDef *hsai) |
Rx Handler for Receive in Interrupt mode for 16-bit transfer. | |
static void | SAI_Receive_IT32Bit (SAI_HandleTypeDef *hsai) |
Rx Handler for Receive in Interrupt mode for 32-bit transfer. | |
static void | SAI_DMATxCplt (DMA_HandleTypeDef *hdma) |
DMA SAI transmit process complete callback. | |
static void | SAI_DMATxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA SAI transmit process half complete callback. | |
static void | SAI_DMARxCplt (DMA_HandleTypeDef *hdma) |
DMA SAI receive process complete callback. | |
static void | SAI_DMARxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA SAI receive process half complete callback. | |
static void | SAI_DMAError (DMA_HandleTypeDef *hdma) |
DMA SAI communication error callback. | |
HAL_StatusTypeDef | HAL_SAI_InitProtocol (SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot) |
Initialize the structure FrameInit, SlotInit and the low part of Init according to the specified parameters and call the function HAL_SAI_Init to initialize the SAI block. | |
HAL_StatusTypeDef | HAL_SAI_Init (SAI_HandleTypeDef *hsai) |
Initialize the SAI according to the specified parameters in the SAI_InitTypeDef structure and initialize the associated handle. | |
HAL_StatusTypeDef | HAL_SAI_DeInit (SAI_HandleTypeDef *hsai) |
DeInitialize the SAI peripheral. | |
__weak void | HAL_SAI_MspInit (SAI_HandleTypeDef *hsai) |
Initialize the SAI MSP. | |
__weak void | HAL_SAI_MspDeInit (SAI_HandleTypeDef *hsai) |
DeInitialize the SAI MSP. | |
HAL_StatusTypeDef | HAL_SAI_Transmit (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
Transmit an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_SAI_Receive (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
Receive an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_SAI_Transmit_IT (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size) |
Transmit an amount of data in non-blocking mode with Interrupt. | |
HAL_StatusTypeDef | HAL_SAI_Receive_IT (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size) |
Receive an amount of data in non-blocking mode with Interrupt. | |
HAL_StatusTypeDef | HAL_SAI_DMAPause (SAI_HandleTypeDef *hsai) |
Pause the audio stream playing from the Media. | |
HAL_StatusTypeDef | HAL_SAI_DMAResume (SAI_HandleTypeDef *hsai) |
Resume the audio stream playing from the Media. | |
HAL_StatusTypeDef | HAL_SAI_DMAStop (SAI_HandleTypeDef *hsai) |
Stop the audio stream playing from the Media. | |
HAL_StatusTypeDef | HAL_SAI_Abort (SAI_HandleTypeDef *hsai) |
Abort the current transfer and disable the SAI. | |
HAL_StatusTypeDef | HAL_SAI_Transmit_DMA (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size) |
Transmit an amount of data in non-blocking mode with DMA. | |
HAL_StatusTypeDef | HAL_SAI_Receive_DMA (SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size) |
Receive an amount of data in non-blocking mode with DMA. | |
HAL_StatusTypeDef | HAL_SAI_EnableTxMuteMode (SAI_HandleTypeDef *hsai, uint16_t val) |
Enable the Tx mute mode. | |
HAL_StatusTypeDef | HAL_SAI_DisableTxMuteMode (SAI_HandleTypeDef *hsai) |
Disable the Tx mute mode. | |
HAL_StatusTypeDef | HAL_SAI_EnableRxMuteMode (SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter) |
Enable the Rx mute detection. | |
HAL_StatusTypeDef | HAL_SAI_DisableRxMuteMode (SAI_HandleTypeDef *hsai) |
Disable the Rx mute detection. | |
void | HAL_SAI_IRQHandler (SAI_HandleTypeDef *hsai) |
Handle SAI interrupt request. | |
__weak void | HAL_SAI_TxCpltCallback (SAI_HandleTypeDef *hsai) |
Tx Transfer completed callback. | |
__weak void | HAL_SAI_TxHalfCpltCallback (SAI_HandleTypeDef *hsai) |
Tx Transfer Half completed callback. | |
__weak void | HAL_SAI_RxCpltCallback (SAI_HandleTypeDef *hsai) |
Rx Transfer completed callback. | |
__weak void | HAL_SAI_RxHalfCpltCallback (SAI_HandleTypeDef *hsai) |
Rx Transfer half completed callback. | |
__weak void | HAL_SAI_ErrorCallback (SAI_HandleTypeDef *hsai) |
SAI error callback. | |
HAL_SAI_StateTypeDef | HAL_SAI_GetState (SAI_HandleTypeDef *hsai) |
Return the SAI handle state. | |
uint32_t | HAL_SAI_GetError (SAI_HandleTypeDef *hsai) |
Return the SAI error code. |
Detailed Description
SAI HAL module driver. This file provides firmware functions to manage the following functionalities of the Serial Audio Interface (SAI) peripheral: + Initialization/de-initialization functions + I/O operation functions + Peripheral Control functions + Peripheral State functions.
- Version:
- V1.1.0
- Date:
- 16-September-2015
============================================================================== ##### How to use this driver ##### ============================================================================== [..] The SAI HAL driver can be used as follows: (#) Declare a SAI_HandleTypeDef handle structure (eg. SAI_HandleTypeDef hsai). (#) Initialize the SAI low level resources by implementing the HAL_SAI_MspInit() API: (##) Enable the SAI interface clock. (##) SAI pins configuration: (+++) Enable the clock for the SAI GPIOs. (+++) Configure these SAI pins as alternate function pull-up. (##) NVIC configuration if you need to use interrupt process (HAL_SAI_Transmit_IT() and HAL_SAI_Receive_IT() APIs): (+++) Configure the SAI interrupt priority. (+++) Enable the NVIC SAI IRQ handle. (##) DMA Configuration if you need to use DMA process (HAL_SAI_Transmit_DMA() and HAL_SAI_Receive_DMA() APIs): (+++) Declare a DMA handle structure for the Tx/Rx channel. (+++) Enable the DMAx interface clock. (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. (+++) Configure the DMA Tx/Rx Channel. (+++) Associate the initialized DMA handle to the SAI DMA Tx/Rx handle. (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Channel. (#) The initialization can be done by two ways (##) Expert mode : Initialize the structures Init, FrameInit and SlotInit and call HAL_SAI_Init(). (##) Simplified mode : Initialize the high part of Init Structure and call HAL_SAI_InitProtocol(). [..] (@) The specific SAI interrupts (FIFO request and Overrun underrun interrupt) will be managed using the macros __HAL_SAI_ENABLE_IT() and __HAL_SAI_DISABLE_IT() inside the transmit and receive process. [..] (@) Make sure that either: (+@) PLLSAI1CLK output is configured or (+@) PLLSAI2CLK output is configured or (+@) PLLSAI3CLK output is configured or (+@) External clock source is configured after setting correctly the define constant EXTERNAL_SAI1_CLOCK_VALUE or EXTERNAL_SAI2_CLOCK_VALUE in the stm32l4xx_hal_conf.h file. [..] (@) In master Tx mode: enabling the audio block immediately generates the bit clock for the external slaves even if there is no data in the FIFO, However FS signal generation is conditioned by the presence of data in the FIFO. [..] (@) In master Rx mode: enabling the audio block immediately generates the bit clock and FS signal for the external slaves. [..] (@) It is mandatory to respect the following conditions in order to avoid bad SAI behavior: (+@) First bit Offset <= (SLOT size - Data size) (+@) Data size <= SLOT size (+@) Number of SLOT x SLOT size = Frame length (+@) The number of slots should be even when SAI_FS_CHANNEL_IDENTIFICATION is selected. [..] Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= [..] (+) Send an amount of data in blocking mode using HAL_SAI_Transmit() (+) Receive an amount of data in blocking mode using HAL_SAI_Receive() *** Interrupt mode IO operation *** =================================== [..] (+) Send an amount of data in non-blocking mode using HAL_SAI_Transmit_IT() (+) At transmission end of transfer HAL_SAI_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SAI_TxCpltCallback() (+) Receive an amount of data in non-blocking mode using HAL_SAI_Receive_IT() (+) At reception end of transfer HAL_SAI_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SAI_RxCpltCallback() (+) In case of flag error, HAL_SAI_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SAI_ErrorCallback() *** DMA mode IO operation *** ============================== [..] (+) Send an amount of data in non-blocking mode (DMA) using HAL_SAI_Transmit_DMA() (+) At transmission end of transfer HAL_SAI_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SAI_TxCpltCallback() (+) Receive an amount of data in non-blocking mode (DMA) using HAL_SAI_Receive_DMA() (+) At reception end of transfer HAL_SAI_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SAI_RxCpltCallback() (+) In case of flag error, HAL_SAI_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SAI_ErrorCallback() (+) Pause the DMA Transfer using HAL_SAI_DMAPause() (+) Resume the DMA Transfer using HAL_SAI_DMAResume() (+) Stop the DMA Transfer using HAL_SAI_DMAStop() *** SAI HAL driver additional function list *** ================================================= [..] Below the list the others API available SAI HAL driver : (+) HAL_SAI_EnableTxMuteMode(): Enable the mute in tx mode (+) HAL_SAI_DisableTxMuteMode(): Disable the mute in tx mode (+) HAL_SAI_EnableRxMuteMode(): Enable the mute in Rx mode (+) HAL_SAI_DisableRxMuteMode(): Disable the mute in Rx mode (+) HAL_SAI_FlushRxFifo(): Flush the rx fifo. (+) HAL_SAI_Abort(): Abort the current transfer *** SAI HAL driver macros list *** ============================================= [..] Below the list of most used macros in SAI HAL driver : (+) __HAL_SAI_ENABLE(): Enable the SAI peripheral (+) __HAL_SAI_DISABLE(): Disable the SAI peripheral (+) __HAL_SAI_ENABLE_IT(): Enable the specified SAI interrupts (+) __HAL_SAI_DISABLE_IT(): Disable the specified SAI interrupts (+) __HAL_SAI_GET_IT_SOURCE(): Check if the specified SAI interrupt source is enabled or disabled (+) __HAL_SAI_GET_FLAG(): Check whether the specified SAI flag is set or not
- Attention:
© COPYRIGHT(c) 2015 STMicroelectronics
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file stm32l4xx_hal_sai.c.
Generated on Tue Jul 12 2022 11:35:18 by 1.7.2