Platform/ECM3532/M3/hw/csp/ecm3532/m3/csp/src/eta_csp_i2c.c
/***************************************************************************/
/**
 *
 * EtaCspI2cDonePoll - Poll for done.
 *
 * @param iNum I2C instance number
 * @return Return the status.
 *
 ******************************************************************************/
Poll for done.
@param iNum I2C instance number
@return Return the status.
Poll for done . @param iNum I2C instance number @return Return the status .
tEtaStatus
EtaCspI2cDonePoll(tI2cNum iNum)
{
    uint32_t ui32Timeout = 1000000;
    while((--ui32Timeout) && (REG_I2C_STATUS(iNum).BF.START_BUSY == 1) && (REG_I2C_STATUS(iNum).BF.SM_IN_NACK_HOLD == 0))
    {
    }
    if(ui32Timeout <= 0)
    {
#ifdef ETA_CSP_I2C_DEBUG
        ETA_DIAGS_PRINTF("ERROR: Timed out waiting for I2C%d CMD (SR=%x)\r\n",
                          iNum, REG_I2C_STATUS(iNum).V);
#endif
        return(eEtaI2cDoneTimeout);
    }
    else
    {
        if (REG_I2C_STATUS(iNum).BF.SM_IN_NACK_HOLD == 1) 
        {
            REG_I2C_CONFIG2(iNum).BF.SOFT_RST = 1;
            REG_GPIO_DEBUG1_READ_ONLY.V = REG_I2C_CONFIG2(iNum).V;
            REG_I2C_CONFIG2(iNum).BF.SOFT_RST = 0;
            return(eEtaI2cUnexpectedNack);
        }
        else
            return(eEtaSuccess);
    }
}
tEtaStatus EtaCspI2cDonePoll ( tI2cNum iNum ) { uint32_t ui32Timeout = 1000000 ; while ( ( -- ui32Timeout ) && ( REG_I2C_STATUS ( iNum ) . BF . START_BUSY == 1 ) && ( REG_I2C_STATUS ( iNum ) . BF . SM_IN_NACK_HOLD == 0 ) ) { } if ( ui32Timeout <= 0 ) { #ifdef ETA_CSP_I2C_DEBUG ETA_DIAGS_PRINTF ( " \r \n " , iNum , REG_I2C_STATUS ( iNum ) . V ) ; #endif return ( eEtaI2cDoneTimeout ) ; } else { if ( REG_I2C_STATUS ( iNum ) . BF . SM_IN_NACK_HOLD == 1 ) { REG_I2C_CONFIG2 ( iNum ) . BF . SOFT_RST = 1 ; REG_GPIO_DEBUG1_READ_ONLY . V = REG_I2C_CONFIG2 ( iNum ) . V ; REG_I2C_CONFIG2 ( iNum ) . BF . SOFT_RST = 0 ; return ( eEtaI2cUnexpectedNack ) ; } else return ( eEtaSuccess ) ; } }
EtaCspI2cDonePoll - Poll for done.
EtaCspI2cDonePoll - Poll for done .
// We encountered a NACK, stop command, report back. // FENCE TO MAKE SURE ALL WRITES GET FLUSHED