u8 i2c_read_register(u8 mem_address, u8 *data_read)
{
u8 temp = 0;
u8 ack = 0;
u8 device_address = (IQS_ADDR << 1);
u8 polling_attempt = 0;
// send address
ack = i2c_send_byte(device_address);
#ifdef POLLING
while ((ack) && (polling_attempt < POLLING_ATTEMPTS))
{
i2c_wait();
i2c_wait();
i2c_start();
ack = i2c_send_byte(device_address);
polling_attempt++;
}
#endif
if (!ack)
{
i2c_send_byte(mem_address);
i2c_repeat_start();
device_address = (IQS_ADDR << 1) | 0x01;
ack = i2c_send_byte(device_address);
temp = i2c_read_byte(1);
(*data_read) = temp;
}
return ack;
}
- Notes
In order to read two Byes I need to call the function Like This:
i2c_read_register(DEBUGGING_EVENTS, &data_buffer[1], 2);
With (2) representing the Number of Bytes.
But as the function stand it only takes two arguments not three.