HI,
I am working on NRF52832 SOC. with SDK 15. where i need to read the SENSOR data from twi protocol.
Common Write and Read Register function has been created
ret_code_t read_register(nrf_drv_twi_t twi_instance, uint8_t device_addr, uint8_t register_addr, uint8_t *p_data, uint8_t bytes, bool no_stop)
{
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&twi_instance, device_addr, ®ister_addr, 1, no_stop);
APP_ERROR_CHECK(err_code);
if(err_code != NRF_SUCCESS) {
return err_code;
}
err_code = nrf_drv_twi_rx(&twi_instance, device_addr, p_data, bytes);
return err_code;
}
ret_code_t Write_register(nrf_drv_twi_t twi_instance, uint8_t device_a, uint8_t register_a, uint8_t siz)
{
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&twi_instance, device_a, ®ister_a, siz, false);
APP_ERROR_CHECK(err_code);
if(err_code != NRF_SUCCESS) {
return err_code;
}
}
I receive some warnings like IMPLICIT DECLARATION, INCOMPATIBLE POINTERS
Write_register call function:
uint8_t tx_data[2]; tx_data[0] = CTRL3_C; tx_data[1] = 0x04; err_code = Write_register(p_twi_sensors, LSM6DS0_ADDR, &tx_data, sizeof(tx_data)); APP_ERROR_CHECK(err_code);
Read_register call function
uint8_t tx_data[2] = {CTRL1_XL, 0};
// read CTRL1_XL register to obtain current parameters.
err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, CTRL1_XL, &rx_data, sizeof(rx_data), false);
APP_ERROR_CHECK(err_code);
// This call function works fine no error warning show
ret_code_t err_code;
uint8_t status = 0;
uint8_t data[6];
LSM6DS0_set_accel_high_performance_mode(settings.accel_samplerate);
do {
err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, STATUS_REG, &status, sizeof(status), false);
} while(!(status & 0x01));
err_code = read_register(p_twi_sensors, LSM6DS0_ADDR, OUTX_L_XL, &data, sizeof(data), true);
APP_ERROR_CHECK(err_code);
LSM6DS0_set_accel_power_down_mode();
*x_axis = (data[1] << 8) | data[0];
*y_axis = (data[3] << 8) | data[2];
*z_axis = (data[5] << 8) | data[4];
/* In this function
there is no warning on &status
but the incompatible pointer on &data */

please guide me clear this warning