/** * @brief Pauses and resumes playing on the audio codec. * @param Cmd: AUDIO_PAUSE (or 0) to pause, AUDIO_RESUME (or any value different * from 0) to resume. * @retval o if correct communication, else wrong communication */ uint32_t Codec_PauseResume(uint32_t Cmd) { uint32_t counter = 0; /* Pause the audio file playing */ if (Cmd == AUDIO_PAUSE) { /* Mute the output first */ counter += Codec_Mute(AUDIO_MUTE_ON); /* Put the Codec in Power save mode */ counter += Codec_WriteRegister(0x02, 0x01); } else /* AUDIO_RESUME */ { /* Unmute the output first */ counter += Codec_Mute(AUDIO_MUTE_OFF); counter += Codec_WriteRegister(0x04, OutputDev); /* Exit the Power save mode */ counter += Codec_WriteRegister(0x02, 0x9E); } return counter; }
/** * @brief Stops audio Codec playing. It powers down the codec. * @param CodecPdwnMode: selects the power down mode. * @arg CODEC_PDWN_SW: only mutes the audio codec. When resuming from this * mode the codec keeps the prvious initialization (no need to re-Initialize * the codec registers). * @arg CODEC_PDWN_HW: Physically power down the codec. When resuming from this * mode, the codec is set to default configuration (user should re-Initialize * the codec in order to play again the audio stream). * @retval o if correct communication, else wrong communication */ uint32_t Codec_Stop(uint32_t CodecPdwnMode) { uint32_t counter = 0; /* Mute the output first */ Codec_Mute(AUDIO_MUTE_ON); if (CodecPdwnMode == CODEC_PDWN_SW) { /* Power down the DAC and the speaker (PMDAC and PMSPK bits)*/ counter += Codec_WriteRegister(0x02, 0x9F); } else /* CODEC_PDWN_HW */ { /* Power down the DAC components */ counter += Codec_WriteRegister(0x02, 0x9F); /* Wait at least 100ms */ Delay(0xFFF); /* Reset The pin */ IOE_WriteIOPin(AUDIO_RESET_PIN, BitReset); } return counter; }
/** * @brief Stops audio Codec playing. It powers down the codec. * @param CodecPdwnMode: selects the power down mode. * - CODEC_PDWN_SW: only mutes the audio codec. When resuming from this * mode the codec keeps the previous initialization * (no need to re-Initialize the codec registers). * - CODEC_PDWN_HW: Physically power down the codec. When resuming from this * mode, the codec is set to default configuration * (user should re-Initialize the codec in order to * play again the audio stream). * @retval 0 if correct communication, else wrong communication */ static uint32_t Codec_Stop(uint32_t CodecPdwnMode) { uint32_t counter = 0; /* Mute the output first */ Codec_Mute(AUDIO_MUTE_ON); if (CodecPdwnMode == CODEC_PDWN_SW) { /* Power down the speaker (PMSPK bits) */ counter += Codec_WriteRegister(0x02, 0x9F); } else { /* CODEC_PDWN_HW */ /* Power down the components */ counter += Codec_WriteRegister(0x02, 0x9F); /* Wait at least 100us */ Delay(0xFFF); /* Reset The pin */ GPIO_WriteBit(AUDIO_RESET_GPIO, AUDIO_RESET_PIN, Bit_RESET); } return counter; }
/** * @brief Enable or disable the MUTE mode by software * @param Command: could be AUDIO_MUTE_ON to mute sound or AUDIO_MUTE_OFF to * unmute the codec and restore previous volume level. * @retval o if correct communication, else wrong communication */ uint32_t EVAL_AUDIO_Mute(uint32_t Cmd) { /* Call the Codec Mute function */ return (Codec_Mute(Cmd)); }