/******************************************************************************* * Function Name: I2S_Wakeup ******************************************************************************** * * Summary: * Prepares I2S to wake up. * * Parameters: * None. * * Return: * None. * * Global Variables: * I2S_backup - used when non-retention registers are restored. * * Reentrant: * Yes. * *******************************************************************************/ void I2S_Wakeup(void) { /* Restore registers values */ I2S_RestoreConfig(); if(0u != I2S_backup.enableState) { /* Enable component's operation */ I2S_Enable(); /* Enable Tx/Rx direction if they were enabled before sleep */ #if(I2S_TX_DIRECTION_ENABLE) if(0u != (I2S_backup.CtrlReg & I2S_TX_EN)) { I2S_EnableTx(); } #endif /* (I2S_TX_DIRECTION_ENABLE) */ #if(I2S_RX_DIRECTION_ENABLE) if(0u != (I2S_backup.CtrlReg & I2S_RX_EN)) { I2S_EnableRx(); } #endif /* (I2S_RX_DIRECTION_ENABLE) */ } }
/******************************************************************************* * Function Name: I2S_Start ******************************************************************************** * * Summary: * Starts the I2S interface. * * Parameters: * None. * * Return: * None. * * Global Variables: * I2S_initVar - used to check initial configuration, modified on * first function call. * * Reentrant: * No. * *******************************************************************************/ void I2S_Start(void) { /* Writes Tx and/or Rx interrupt source values provided for customizer */ if(0u == I2S_initVar) { I2S_Init(); I2S_initVar = 1u; } I2S_Enable(); }
void I2S_RxEnable(I2S_Type *base, bool enable) { if (enable) { I2S_EnableInterrupts(base, kI2S_RxErrorFlag | kI2S_RxLevelFlag); I2S_Enable(base); } else { I2S_DisableInterrupts(base, kI2S_RxErrorFlag | kI2S_RxLevelFlag); I2S_Disable(base); base->FIFOCFG |= I2S_FIFOCFG_EMPTYRX_MASK; } }
void CodecController::start(){ // setPin(GPIOA, GPIO_Pin_7); // DEBUG setActive(true); if(isMaster()){ /* The I2S peripheral must be enabled when the external master sets the WS line at: */ if(getProtocol() == I2S_PROTOCOL_PHILIPS){ while(getPin(CODEC_I2S_GPIO, CODEC_I2S_WS_PIN)); // wait for low /* High level when the I2S protocol is selected. */ while(!getPin(CODEC_I2S_GPIO, CODEC_I2S_WS_PIN)); // wait for high }else{ while(!getPin(CODEC_I2S_GPIO, CODEC_I2S_WS_PIN)); // wait for high /* Low level when the LSB or MSB-justified mode is selected. */ while(getPin(CODEC_I2S_GPIO, CODEC_I2S_WS_PIN)); // wait for low } } I2S_Enable(); I2S_Run(); }