Hello, thank you for sharing and helping me!
Hi,
after lots of trouble I'm making progress.
Now, the problem is about the getting new data. Indeed, the output is this:
I2C InterfaceAPI name [bme68x_interface_init]: Tutto ok
API name [bme68x_init]: Tutto ok
API name [bme68x_set_conf]: Tutto ok
API name [bme68x_set_heatr_conf]: Tutto ok
Sample, TimeStamp(ms), Temperature(deg C), Pressure(Pa), Humidity(%), Gas resistance(ohm), Status
API name [bme68x_set_op_mode]: Tutto ok
API name [bme68x_get_data] Warning [2] : No new data found
API name [bme68x_set_op_mode]: Tutto ok
API name [bme68x_get_data] Warning [2] : No new data found
From another issue of Bosch community, I understood that the problem is probably related to the I2C write and read functions I have implemented in the common.c file.
I have implemented the functions in this way, is it correct?
BME68X_INTF_RET_TYPE bme68x_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
uint8_t dev_addr = *(uint8_t*)intf_ptr;
ret_code_t ret_code;
ret_code = nrf_drv_twi_tx(&i2c_instance, dev_addr, ®_addr,1,false);
if(ret_code != NRF_SUCCESS)
{
return ret_code;
}
ret_code = nrf_drv_twi_rx(&i2c_instance,dev_addr, reg_data, len);
if (ret_code == NRF_SUCCESS)
return BME68X_OK;
else
return 1;
}
BME68X_INTF_RET_TYPE bme68x_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
uint8_t dev_addr = *(uint8_t*)intf_ptr;
ret_code_t ret_code;
uint8_t send_tmp[10] = {0};
send_tmp[0] = reg_addr;
memcpy(send_tmp+1, reg_data, len);
ret_code = nrf_drv_twi_tx(&i2c_instance, dev_addr, send_tmp, len , false);
if (ret_code == NRF_SUCCESS)
return BME68X_OK;
else
return 1;
}
If the logic of the function is not correct, please could you tell me how I have to make it (the logic of the functions I mean)?
Thanks
It looks okay.
Our i2c functions are simple.
Reg_addr is target register, and reg_data is the data you are going to read and write, and len is data length.
As long as you implement correctly, it will work.
Thank you.
Thanks for looking at my functions.
The code still has the same problem
API name [bme68x_get_data] Warning [2] : No new data found
What can I do or try to do to solve the problem? I have no more idea. I attach my common.c file to let you see if it is all correct, if you would like to give it a look.
Thanks again