AnsweredAssumed Answered

I2C code ADuCM360

Question asked by danielc@nexsens.com on Jan 8, 2013
Latest reply on Jan 15, 2013 by AudeR

Hi,

I use I2C library for I2C communication. I use I2cTx function and I2cRx function. I am wondering if the library function will deal with the Start and Stop for I2C command?

 

Another thing is I do not want to use interrupt for MASTER receive and sending. So I want to know if the following code will work and for master read, do I need to indicate the slave address use function I2cMWrCfg.

void I2C_Master_Byte_Tx(unsigned char ucTxByte)

{

    unsigned int uiStatus;

    I2cTx(MASTER, ucTxByte);                    // send 1st data

    I2cMWrCfg(0xA0);

    do{

        uiStatus = I2cSta(MASTER);

    }while( (uiStatus & I2CMSTA_TXREQ) != I2CMSTA_TXREQ);

}

 

void I2C_Master_Byte_Rx(unsigned char *ucRxByte)

{

    unsigned char uiStatus;

    do{

        uiStatus = I2cSta(MASTER);

    }while((uiStatus & I2CMSTA_TXREQ) != I2CMSTA_RXREQ);

    *ucRxByte = I2cRx(MASTER);

}

 

 

Thank you.

Outcomes