/* Sends a start to begin i2c transaction (with no strings attached) */ void sendStart(I2C_MODULE i2c){ while( ! I2CBusIsIdle(i2c)); DelayMs(2); // timing for ADXL345 I2CStart(i2c); while( ! (I2CGetStatus(i2c) & I2C_START) ); I2CClearStatus(i2c, I2C_START); }
/************************************************************************************************** Function: void I2CShared_ResetBus(const I2C_MODULE i2c) Author(s): mkobit Summary: Resets the I2C bus on a failure Description: Disables and reenables the bus, and then clears all status bits if it can Preconditions: None Parameters: const I2C_MODULE i2c - I2C module to be reset Returns: void Example: <code> I2CShared_ResetBus(I2C1) </code> Conditions at Exit: I2C enabled and cleared of all statuses **************************************************************************************************/ void I2CShared_ResetBus(const I2C_MODULE i2c) { I2CEnable(i2c, FALSE); I2CEnable(i2c, TRUE); I2CClearStatus(i2c, I2C_TRANSMITTER_FULL | I2C_DATA_AVAILABLE | \ I2C_SLAVE_READ | I2C_START | I2C_STOP | I2C_SLAVE_DATA | I2C_RECEIVER_OVERFLOW | I2C_TRANSMITTER_OVERFLOW | \ I2C_10BIT_ADDRESS | I2C_GENERAL_CALL | I2C_ARBITRATION_LOSS | I2C_TRANSMITTER_BUSY | I2C_BYTE_ACKNOWLEDGED); }
/* Sends a start inside i2c transaction (with no strings attached) */ void repeatStart(I2C_MODULE I2C){ I2CRepeatStart(I2C); while( ! (I2CGetStatus(I2C) & I2C_START) ); I2CClearStatus(I2C, I2C_START); }