I'm attempting to interface my TMS570LS1114 to a DS1621 via I2C. I have included my send and recieve routines below based on the HAL CoGen drivers. Currently the send routine appears to be working, but I am having trouble with receive since it requires a repeated start. I appreciate any input.
void DS1621::I2CSend(uint8 Cmd, uint32 length, uint8 * data) { //config /* Set mode as Master */ i2cSetMode(i2cREG1, I2C_MASTER); i2cSetDirection(mNode, I2C_TRANSMITTER); i2cSetSlaveAdd(mNode, SlaveAddr); i2cSetCount(mNode, length+1); i2cSetStop(mNode); //send i2cSetStart(mNode); i2cSendByte(mNode, Cmd); i2cSend(mNode, length, data); /* Wait until Bus Busy is cleared */ while(i2cIsBusBusy(mNode) == true); /* Wait until Stop is detected */ while(i2cIsStopDetected(mNode) == 0); /* Clear the Stop condition */ i2cClearSCD(mNode); }
void DS1621::I2CRcv(uint8 Cmd, uint32 length, uint8 * data) { //config i2cSetMode(i2cREG1, I2C_MASTER); i2cSetDirection(mNode, I2C_TRANSMITTER); i2cSetSlaveAdd(mNode, SlaveAddr); i2cSetCount(mNode, length+1); i2cSetStop(mNode); //send i2cSetStart(mNode); i2cSendByte(mNode, Cmd); /* Wait until Bus Busy is cleared */ // while(i2cIsBusBusy(mNode) == true); //reconfig i2cSetDirection(mNode, I2C_RECEIVER); //receive i2cSetStart(mNode); i2cReceive(mNode, length, data); /* Wait until Bus Busy is cleared */ while(i2cIsBusBusy(mNode) == true); /* Wait until Stop is detected */ while(i2cIsStopDetected(mNode) == 0); /* Clear the Stop condition */ i2cClearSCD(mNode); }