2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_sai_ex.c
\r
4 * @author MCD Application Team
\r
6 * @date 06-March-2015
\r
7 * @brief SAI Extension HAL module driver.
\r
8 * This file provides firmware functions to manage the following
\r
9 * functionalities of SAI extension peripheral:
\r
10 * + Extension features functions
\r
13 ==============================================================================
\r
14 ##### SAI peripheral extension features #####
\r
15 ==============================================================================
\r
17 ##### How to use this driver #####
\r
18 ==============================================================================
\r
19 [..] This driver provides functions to manage several sources to clock SAI
\r
22 ******************************************************************************
\r
25 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
27 * Redistribution and use in source and binary forms, with or without modification,
\r
28 * are permitted provided that the following conditions are met:
\r
29 * 1. Redistributions of source code must retain the above copyright notice,
\r
30 * this list of conditions and the following disclaimer.
\r
31 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
32 * this list of conditions and the following disclaimer in the documentation
\r
33 * and/or other materials provided with the distribution.
\r
34 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
35 * may be used to endorse or promote products derived from this software
\r
36 * without specific prior written permission.
\r
38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
39 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
41 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
44 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
45 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
47 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
49 ******************************************************************************
\r
52 /* Includes ------------------------------------------------------------------*/
\r
53 #include "stm32f7xx_hal.h"
\r
55 /** @addtogroup STM32F7xx_HAL_Driver
\r
59 /** @defgroup SAIEx SAIEx
\r
60 * @brief SAI Extension HAL module driver
\r
64 #ifdef HAL_SAI_MODULE_ENABLED
\r
66 /* Private typedef -----------------------------------------------------------*/
\r
67 /* Private define ------------------------------------------------------------*/
\r
68 /* SAI registers Masks */
\r
69 /* Private macro -------------------------------------------------------------*/
\r
70 /* Private variables ---------------------------------------------------------*/
\r
71 /* Private function prototypes -----------------------------------------------*/
\r
72 /* Private functions ---------------------------------------------------------*/
\r
74 /** @defgroup SAI_Private_Functions SAI Private Functions
\r
81 /* Exported functions --------------------------------------------------------*/
\r
82 /** @defgroup SAIEx_Exported_Functions SAI Extended Exported Functions
\r
86 /** @defgroup SAIEx_Exported_Functions_Group1 Extension features functions
\r
87 * @brief Extension features functions
\r
90 ===============================================================================
\r
91 ##### Extension features Functions #####
\r
92 ===============================================================================
\r
94 This subsection provides a set of functions allowing to manage the possible
\r
102 * @brief Configure SAI Block synchronization mode
\r
103 * @param hsai: pointer to a SAI_HandleTypeDef structure that contains
\r
104 * the configuration information for SAI module.
\r
105 * @retval SAI Clock Input
\r
107 void SAI_BlockSynchroConfig(SAI_HandleTypeDef *hsai)
\r
109 uint32_t tmpregisterGCR = 0;
\r
111 /* This setting must be done with both audio block (A & B) disabled */
\r
112 switch(hsai->Init.SynchroExt)
\r
114 case SAI_SYNCEXT_DISABLE :
\r
115 tmpregisterGCR = 0;
\r
117 case SAI_SYNCEXT_IN_ENABLE :
\r
118 tmpregisterGCR = SAI_GCR_SYNCIN_0;
\r
120 case SAI_SYNCEXT_OUTBLOCKA_ENABLE :
\r
121 tmpregisterGCR = SAI_GCR_SYNCOUT_0;
\r
123 case SAI_SYNCEXT_OUTBLOCKB_ENABLE :
\r
124 tmpregisterGCR = SAI_GCR_SYNCOUT_1;
\r
130 if((hsai->Instance == SAI1_Block_A) || (hsai->Instance == SAI1_Block_B))
\r
132 SAI1->GCR = tmpregisterGCR;
\r
136 SAI2->GCR = tmpregisterGCR;
\r
140 * @brief Get SAI Input Clock based on SAI source clock selection
\r
141 * @param hsai: pointer to a SAI_HandleTypeDef structure that contains
\r
142 * the configuration information for SAI module.
\r
143 * @retval SAI Clock Input
\r
145 uint32_t SAI_GetInputClock(SAI_HandleTypeDef *hsai)
\r
147 /* This variable used to store the SAI_CK_x (value in Hz) */
\r
148 uint32_t saiclocksource = 0;
\r
150 if ((hsai->Instance == SAI1_Block_A) || (hsai->Instance == SAI1_Block_B))
\r
152 saiclocksource = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SAI1);
\r
154 else /* SAI2_Block_A || SAI2_Block_B*/
\r
156 saiclocksource = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SAI2);
\r
158 /* the return result is the value of SAI clock */
\r
159 return saiclocksource;
\r
170 #endif /* HAL_SAI_MODULE_ENABLED */
\r
179 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r