uint8_t imu_read(uint8_t reg) { uint8_t data; MSS_I2C_write ( &g_mss_i2c1, IMU_ADDRESS_WRITE, ®, sizeof(reg), MSS_I2C_RELEASE_BUS ); MSS_I2C_wait_complete(&g_mss_i2c1); MSS_I2C_read ( &g_mss_i2c1, IMU_ADDRESS_READ, &data, sizeof(data), MSS_I2C_RELEASE_BUS ); MSS_I2C_wait_complete(&g_mss_i2c1); return data; }
uint8_t wireReadDataBlock(uint8_t reg, uint8_t* val, unsigned int len){ MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, ®, sizeof(reg), MSS_I2C_RELEASE_BUS); MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT); MSS_I2C_read(&g_mss_i2c1, APDS9960_I2C_ADDR, val, len, MSS_I2C_RELEASE_BUS); MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT); return len; }
void wireReadDataByte(uint8_t reg, uint8_t* val) { MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, ®, sizeof(reg), MSS_I2C_RELEASE_BUS); MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT); uint8_t recieve_buf; MSS_I2C_read(&g_mss_i2c1, APDS9960_I2C_ADDR, &recieve_buf, sizeof(recieve_buf), MSS_I2C_RELEASE_BUS); MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT); *val = recieve_buf; }