Hi BSTRobin, I've studied the API in search of the calibration state in the BSX Algorithm Parameters. The function that gets the BSX State Exchange Structure is the following: /**
* @brief Function to get the calibration profile of a BSX virtual sensor
* @param[in] sensor_id : Sensor ID of the virtual sensor
* @param[out] calib_prof : Reference to the data buffer to store the calibration profile
* @param[in] prof_len : Length of the data buffer
* @param[out] actual_len : Actual length of the calibration profile
* @param[in] dev : Device reference
* @return API error codes
*/
int8_t bhy2_get_calibration_profile(uint8_t sensor_id,
uint8_t *calib_prof,
uint16_t prof_len,
uint32_t *actual_len,
struct bhy2_dev *dev); The implementation is the following: int8_t bhy2_get_calibration_profile(uint8_t sensor_id,
uint8_t *calib_prof,
uint16_t prof_len,
uint32_t *actual_len,
struct bhy2_dev *dev)
{
int8_t rslt = BHY2_OK;
if ((dev == NULL) || (calib_prof == NULL) || (actual_len == NULL))
{
rslt = BHY2_E_NULL_PTR;
}
else
{
rslt = bhy2_hif_get_bsx_state((uint16_t)(BHY2_PARAM_CALIB_STATE_BASE | sensor_id),
calib_prof,
prof_len,
actual_len,
&dev->hif);
}
return rslt;
} It calls the bhy2_hif_get_bsx_state function. Below are the details about that function: /**
* @brief Function to get the BSX state of a BSX parameter
* @param[in] param_id : Parameter ID of the BSX parameter
* @param[out] bsx_state : Reference to teh data buffer to store the BSX state
* @param[in] state_len : Length of the buffer
* @param[out] actual_len : Actual length of the BSX state
* @param[in] hif : HIF device reference
* @return API error codes
*/
int8_t bhy2_hif_get_bsx_state(uint16_t param_id,
uint8_t *bsx_state,
uint32_t state_len,
uint32_t *actual_len,
struct bhy2_hif_dev *hif); The implementation: int8_t bhy2_hif_get_bsx_state(uint16_t param_id,
uint8_t *bsx_state,
uint32_t state_len,
uint32_t *actual_len,
struct bhy2_hif_dev *hif)
{
uint8_t complete_flag = 0;
uint8_t section_num = 0;
uint16_t tmp_state_len = 0;
uint32_t read_len;
int8_t rslt;
uint8_t tmp_bsx_state_buf[BHY2_BSX_STATE_STRUCT_LEN];
while (complete_flag == 0)
{
rslt = bhy2_hif_get_parameter(param_id, tmp_bsx_state_buf, BHY2_BSX_STATE_STRUCT_LEN, &read_len, hif);
if (rslt != BHY2_OK)
{
break;
}
if (read_len != BHY2_BSX_STATE_STRUCT_LEN)
{
rslt = BHY2_E_INVALID_PARAM;
break;
}
complete_flag = tmp_bsx_state_buf[0] & BHY2_BSX_STATE_TRANSFER_COMPLETE;
section_num = tmp_bsx_state_buf[0] & 0x7F;
tmp_state_len = BHY2_LE2U16(&tmp_bsx_state_buf[2]);
if (tmp_state_len == 0)
{
rslt = BHY2_E_INVALID_PARAM;
break;
}
*actual_len = tmp_state_len; /* Report actual length, in case of invalid buffer */
if (state_len < tmp_state_len)
{
rslt = BHY2_E_BUFFER;
break;
}
memcpy(&bsx_state[section_num * BHY2_BSX_STATE_BLOCK_LEN], &tmp_bsx_state_buf[4], tmp_bsx_state_buf[1]);
}
return rslt;
} As you can see, in the end, it copies (using the memcpy function) the raw blocks of data taken from the BSX State Exchange Structure into the given buffer (in this case the bsx_state buffer). But the problem is that it doesn't parse the final buffer. So I can't see how it should be done. And again, it's not explained on the datasheet. Please, if it's necessary, elevate this question to reach a deeper level of support, since it seems to be some information missing. In addition, if you have some code example that uses the bhy2_get_calibration_profile() function and that parses the returned buffer of data, it would be useful as well.
... View more