Ejemplo n.º 1
0
// Read value from register
uint8_t readReg(uint8_t regAddr)
{
	uint8_t txBuff[1];
	uint8_t rxBuff[1];
	txBuff[0] = regAddr;
	Chip_I2C_MasterSend(i2cDev, LSM303D_ADDR, txBuff, 1);
	Chip_I2C_MasterRead(i2cDev, LSM303D_ADDR, rxBuff, 1);
	return rxBuff[0];
}
Ejemplo n.º 2
0
int8_t LSM_read_reg_mag(uint8_t reg_addr) {
    // Write the register we want to read
    // - Make a transmit buffer
    uint8_t tx_size = 1;
    uint8_t tx_buf[tx_size];
    // - Set the register address
    tx_buf[0] = reg_addr;
    // - Write the register value
    Chip_I2C_MasterSend(LSM_i2c_id, LSM_mag_address, tx_buf, tx_size);

    // Read the register value
    // - Make a receive buffer
    uint8_t rx_size = 1;
    uint8_t rx_buf[rx_size];
    // - Read the register value
    Chip_I2C_MasterRead(LSM_i2c_id, LSM_mag_address, rx_buf, rx_size);

    return rx_buf[0];
}
Ejemplo n.º 3
0
/* Function that probes all available slaves connected to an I2C bus */
static void i2c_probe_slaves(I2C_ID_T i2c)
{
	int i;
	uint8_t ch[2];

	DEBUGOUT("Probing available I2C devices...\r\n");
	DEBUGOUT("\r\n     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
	DEBUGOUT("\r\n====================================================");
	for (i = 0; i <= 0x7F; i++) {
		if (!(i & 0x0F)) {
			DEBUGOUT("\r\n%02X  ", i >> 4);
		}
		if ((i <= 7) || (i > 0x78)) {
			DEBUGOUT("   ");
			continue;
		}
		/* Address 0x48 points to LM75AIM device which needs 2 bytes be read */
		if (Chip_I2C_MasterRead(i2c, i, ch, 1 + (i == 0x48)) > 0) {
			DEBUGOUT(" %02X", i);
		}
		else {
			DEBUGOUT(" --");
		}
	}
Ejemplo n.º 4
0
uint32_t Board_I2C_Master_Read(uint8_t slaveAddr, uint8_t *buff, int len)
{
	return Chip_I2C_MasterRead(I2C0, slaveAddr, buff, len);
}