/* This API reads the error status from the sensor.  */
uint16_t bma4_get_error_status(struct bma4_err_reg *err_reg, struct bma4_dev *dev)
/* This API reads the error status from the sensor.  */
uint16_t bma4_get_error_status(struct bma4_err_reg *err_reg, struct bma4_dev *dev)
{
    uint16_t rslt = 0;
    uint8_t data = 0;
    if (dev == NULL) {
        rslt |= BMA4_E_NULL_PTR;
    } else {
        rslt |= bma4_read_regs(BMA4_ERROR_ADDR, &data, 1, dev);
        if (rslt == BMA4_OK) {
            err_reg->fatal_err = BMA4_GET_BITS_POS_0(data, BMA4_FATAL_ERR);
            err_reg->cmd_err = BMA4_GET_BITSLICE(data, BMA4_CMD_ERR);
            err_reg->err_code = BMA4_GET_BITSLICE(data, BMA4_ERR_CODE);
            err_reg->fifo_err = BMA4_GET_BITSLICE(data, BMA4_FIFO_ERR);
            err_reg->aux_err = BMA4_GET_BITSLICE(data, BMA4_AUX_ERR);
        }
    }
    return rslt;
}