STM32L4xx_HAL_Driver  1.14.0

SAIEx control functions. More...

Functions

HAL_StatusTypeDef HAL_SAIEx_ConfigPdmMicDelay (SAI_HandleTypeDef *hsai, SAIEx_PdmMicDelayParamTypeDef *pdmMicDelay)
 Configure PDM microphone delays. More...
 

Detailed Description

SAIEx control functions.

 ===============================================================================
                 ##### Extended features functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Modify PDM microphone delays

Function Documentation

◆ HAL_SAIEx_ConfigPdmMicDelay()

HAL_StatusTypeDef HAL_SAIEx_ConfigPdmMicDelay ( SAI_HandleTypeDef hsai,
SAIEx_PdmMicDelayParamTypeDef pdmMicDelay 
)

Configure PDM microphone delays.

Parameters
hsaiSAI handle.
pdmMicDelayMicrophone delays configuration.
Return values
HALstatus

Definition at line 78 of file stm32l4xx_hal_sai_ex.c.

79 {
80  HAL_StatusTypeDef status = HAL_OK;
81  uint32_t offset;
82 
83  /* Check that SAI sub-block is SAI1 sub-block A */
84  if (hsai->Instance != SAI1_Block_A)
85  {
86  status = HAL_ERROR;
87  }
88  else
89  {
90  /* Check microphone delay parameters */
91  assert_param(IS_SAI_PDM_MIC_PAIRS_NUMBER(pdmMicDelay->MicPair));
92  assert_param(IS_SAI_PDM_MIC_DELAY(pdmMicDelay->LeftDelay));
93  assert_param(IS_SAI_PDM_MIC_DELAY(pdmMicDelay->RightDelay));
94 
95  /* Compute offset on PDMDLY register according mic pair number */
96  offset = SAI_PDM_DELAY_OFFSET * (pdmMicDelay->MicPair - 1U);
97 
98  /* Check SAI state and offset */
99  if ((hsai->State != HAL_SAI_STATE_RESET) && (offset <= 24U))
100  {
101  /* Reset current delays for specified microphone */
102  SAI1->PDMDLY &= ~(SAI_PDM_DELAY_MASK << offset);
103 
104  /* Apply new microphone delays */
105  SAI1->PDMDLY |= (((pdmMicDelay->RightDelay << SAI_PDM_RIGHT_DELAY_OFFSET) | pdmMicDelay->LeftDelay) << offset);
106  }
107  else
108  {
109  status = HAL_ERROR;
110  }
111  }
112  return status;
113 }
SAI_Block_TypeDef * Instance
__IO HAL_SAI_StateTypeDef State
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))