Esempio n. 1
0
uint8_t imu_read(uint8_t reg)
{
	uint8_t data;

	MSS_I2C_write
	(
		&g_mss_i2c1,
		IMU_ADDRESS_WRITE,
		&reg,
		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;
}
Esempio n. 2
0
uint8_t wireReadDataBlock(uint8_t reg, uint8_t* val, unsigned int len){
	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, &reg, 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;
}
Esempio n. 3
0
void wireReadDataByte(uint8_t reg, uint8_t* val) {

	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, &reg, 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;
}