![]() |
|
|||
File indexing completed on 2025-05-11 08:23:09
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_hal_sai_ex.c 0004 * @author MCD Application Team 0005 * @brief SAI Extended HAL module driver. 0006 * This file provides firmware functions to manage the following 0007 * functionality of the SAI Peripheral Controller: 0008 * + Modify PDM microphone delays. 0009 * 0010 ****************************************************************************** 0011 * @attention 0012 * 0013 * Copyright (c) 2017 STMicroelectronics. 0014 * All rights reserved. 0015 * 0016 * This software is licensed under terms that can be found in the LICENSE file 0017 * in the root directory of this software component. 0018 * If no LICENSE file comes with this software, it is provided AS-IS. 0019 * 0020 ****************************************************************************** 0021 */ 0022 0023 /* Includes ------------------------------------------------------------------*/ 0024 #include "stm32h7xx_hal.h" 0025 0026 /** @addtogroup STM32H7xx_HAL_Driver 0027 * @{ 0028 */ 0029 #ifdef HAL_SAI_MODULE_ENABLED 0030 0031 /** @defgroup SAIEx SAIEx 0032 * @ingroup RTEMSBSPsARMSTM32H7 0033 * @brief SAI Extended HAL module driver 0034 * @{ 0035 */ 0036 0037 /* Private types -------------------------------------------------------------*/ 0038 /* Private variables ---------------------------------------------------------*/ 0039 /* Private constants ---------------------------------------------------------*/ 0040 #define SAI_PDM_DELAY_MASK 0x77U 0041 #define SAI_PDM_DELAY_OFFSET 8U 0042 #define SAI_PDM_RIGHT_DELAY_OFFSET 4U 0043 0044 /* Private macros ------------------------------------------------------------*/ 0045 /* Private functions ---------------------------------------------------------*/ 0046 /* Exported functions --------------------------------------------------------*/ 0047 /** @defgroup SAIEx_Exported_Functions SAIEx Extended Exported Functions 0048 * @ingroup RTEMSBSPsARMSTM32H7 0049 * @{ 0050 */ 0051 0052 /** @defgroup SAIEx_Exported_Functions_Group1 Peripheral Control functions 0053 * @ingroup RTEMSBSPsARMSTM32H7 0054 * @brief SAIEx control functions 0055 * 0056 @verbatim 0057 =============================================================================== 0058 ##### Extended features functions ##### 0059 =============================================================================== 0060 [..] This section provides functions allowing to: 0061 (+) Modify PDM microphone delays 0062 0063 @endverbatim 0064 * @{ 0065 */ 0066 0067 /** 0068 * @brief Configure PDM microphone delays. 0069 * @param hsai SAI handle. 0070 * @param pdmMicDelay Microphone delays configuration. 0071 * @retval HAL status 0072 */ 0073 HAL_StatusTypeDef HAL_SAIEx_ConfigPdmMicDelay(const SAI_HandleTypeDef *hsai, 0074 const SAIEx_PdmMicDelayParamTypeDef *pdmMicDelay) 0075 { 0076 HAL_StatusTypeDef status = HAL_OK; 0077 uint32_t offset; 0078 SAI_TypeDef *SaiBaseAddress; 0079 0080 /* Get the SAI base address according to the SAI handle */ 0081 #if defined(SAI4) 0082 SaiBaseAddress = ((hsai->Instance == SAI1_Block_A) ? SAI1 : \ 0083 (hsai->Instance == SAI4_Block_A) ? SAI4 : \ 0084 NULL); 0085 #else 0086 SaiBaseAddress = ((hsai->Instance == SAI1_Block_A) ? SAI1 : NULL); 0087 #endif /* SAI4 */ 0088 0089 /* Check that SAI sub-block is SAI sub-block A */ 0090 if (SaiBaseAddress == NULL) 0091 { 0092 status = HAL_ERROR; 0093 } 0094 else 0095 { 0096 /* Check microphone delay parameters */ 0097 assert_param(IS_SAI_PDM_MIC_PAIRS_NUMBER(pdmMicDelay->MicPair)); 0098 assert_param(IS_SAI_PDM_MIC_DELAY(pdmMicDelay->LeftDelay)); 0099 assert_param(IS_SAI_PDM_MIC_DELAY(pdmMicDelay->RightDelay)); 0100 0101 /* Compute offset on PDMDLY register according mic pair number */ 0102 offset = SAI_PDM_DELAY_OFFSET * (pdmMicDelay->MicPair - 1U); 0103 0104 /* Check SAI state and offset */ 0105 if ((hsai->State != HAL_SAI_STATE_RESET) && (offset <= 24U)) 0106 { 0107 /* Reset current delays for specified microphone */ 0108 SaiBaseAddress->PDMDLY &= ~(SAI_PDM_DELAY_MASK << offset); 0109 0110 /* Apply new microphone delays */ 0111 SaiBaseAddress->PDMDLY |= (((pdmMicDelay->RightDelay << SAI_PDM_RIGHT_DELAY_OFFSET) | pdmMicDelay->LeftDelay) << offset); 0112 } 0113 else 0114 { 0115 status = HAL_ERROR; 0116 } 0117 } 0118 return status; 0119 } 0120 0121 /** 0122 * @} 0123 */ 0124 0125 /** 0126 * @} 0127 */ 0128 0129 /** 0130 * @} 0131 */ 0132 0133 #endif /* HAL_SAI_MODULE_ENABLED */ 0134 /** 0135 * @} 0136 */ 0137
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |