/** * @brief Stops audio playing and Power down the Audio Codec. * @param Option: could be one of the following parameters * - CODEC_PDWN_HW: completely shut down the codec (physically). * Then need to reconfigure the Codec after power on. * @retval AUDIO_OK if correct communication, else wrong communication */ uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) { /* Call DMA Stop to disable DMA stream before stopping codec */ HAL_I2S_DMAStop(&hAudioOutI2s); /* Call Audio Codec Stop function */ if(pAudioDrv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) { return AUDIO_ERROR; } else { if(Option == CODEC_PDWN_HW) { /* Wait at least 100us */ HAL_Delay(1); /* Power Down the codec */ HAL_GPIO_WritePin(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, GPIO_PIN_RESET); } /* Return AUDIO_OK when all operations are correctly done */ return AUDIO_OK; } }
/** * @brief Stops audio playing and Power down the Audio Codec. * @param Option: could be one of the following parameters * - CODEC_PDWN_SW: for software power off (by writing registers). * Then no need to reconfigure the Codec after power on. * - CODEC_PDWN_HW: completely shut down the codec (physically). * Then need to reconfigure the Codec after power on. * @retval AUDIO_OK if correct communication, else wrong communication */ uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option) { /* Call the Media layer stop function */ HAL_I2S_DMAStop(&haudio_i2s); /* Call Audio Codec Stop function */ if(audio_drv->Stop(AUDIO_I2C_ADDRESS, Option) != 0) { return AUDIO_ERROR; } else { if(Option == CODEC_PDWN_HW) { /* Wait at least 1ms */ HAL_Delay(1); /* Reset the pin */ BSP_IO_WritePin(AUDIO_RESET_PIN, RESET); } /* Return AUDIO_OK when all operations are correctly done */ return AUDIO_OK; } }
/** * @brief Stops sending dummy data as audio stream: function used to stop to generate I2S master clock MCK for audio codec device. * @retval AUDIO_OK if correct communication, else wrong communication */ static uint8_t I2SOUT_SendDummyData_Stop(void) { /* Call DMA Stop to disable DMA stream before stopping codec */ HAL_I2S_DMAStop(&hAudioOutI2s); return AUDIO_OK; }
/** * @brief Stops audio recording. * @param None * @retval None */ uint8_t BSP_AUDIO_IN_Stop(void) { uint32_t ret = AUDIO_ERROR; /* Call the Media layer pause function */ HAL_I2S_DMAStop(&hAudioInI2s); /* Return AUDIO_OK when all operations are correctly done */ ret = AUDIO_OK; return ret; }