Hi,
Working on the pressure sensor Fxps7400, using I2C, I have download sample code of Fxpss7400 Sensor Driver.
I have some question regarding the initialization.
uint8_t fxps7xxx_init(fxps7xxx_driver_t *pDriver)
{
// Initial the sensor driver handler and interfaces
if(NULL == pDriver){
return SENSOR_INVALIDPARAM_ERR;
}
uint8_t status = SENSOR_SUCCESS;
// initialize the communication channel
status = sensor_comm_init(&pDriver->comHandle);
if(status != SENSOR_SUCCESS){
return status;
}
uint8_t data = 0;
// dummy read to flush the data in communication buffer
sensor_comm_read(&pDriver->comHandle, FXPS7XXX_DEVSTAT, sizeof(data), &data);
status = sensor_comm_read(&pDriver->comHandle, FXPS7XXX_WHO_AM_I, sizeof(data), &data);
if(data != FXPS7XXX_H_WHOAMI_VALUE){
return FXPS7XXX_DEVICE_NOT_FOUND;
}
status = load_region(pDriver, CONFIG_C_REGSITERS);
if(status != SENSOR_SUCCESS){
return status;
}
//read the part information
uint8_t part_data = 0;
uint8_t part_index = 0;
status = sensor_comm_read(&pDriver->comHandle, FXPS7XXX_PN1, sizeof(part_data), &part_data);
if(part_data == 0x16){
part_index = 0;
}else{
part_index = (part_data>>4 & 0x0F);
}
pDriver->pressureOffset = part_tbl[part_index].pabOffSet;
pDriver->pressureSensitivity = part_tbl[part_index].pabSense;
return status;
}
First, it checks if the right part is present, with the good WhoAmI value.
Then is load specific memory region. I think it is necessary to be able to read the PN. Can you firm?
Reading PN register, it uses it as index of a table to obtain some parameters.
// fxps7xxx part information table
const fxps7xxx_part_table_t part_tbl[] = {{0x16, 24939.7, 66.62},
{0x11, 25536.4, 93.34},
{0x25, 28661.6, 30.42},
{0x0, 0, 0}, //dummy
{0x40, 28900, 14},
{0x55, 28990, 14}};
When I execute this on my device, I get over I2C [0x0C;0x40] ...
Can you explain me the link between device part number (normally FXPS7400DIA4) and the one i get from the device?
The part number registers are factory programmed OTP registers that include the
numeric portion of the device part number.
Can you tell me if I shall reuse or update the data from the part_tbl[] according to my device?
thanks in advance
Francois