/* This API sets the auxiliary Mag(BMM150 or AKM9916) output data rate and offset.  */
uint16_t bma4_set_aux_mag_config(const struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev)
/* This API sets the auxiliary Mag(BMM150 or AKM9916) output data rate and offset.  */
uint16_t bma4_set_aux_mag_config(const struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev)
{
    uint16_t rslt = 0;
    uint8_t data = 0;
    if (dev == NULL) {
        rslt |= BMA4_E_NULL_PTR;
    } else {
        if ((aux_mag->odr >= BMA4_OUTPUT_DATA_RATE_0_78HZ) &&
                (aux_mag->odr <= BMA4_OUTPUT_DATA_RATE_1600HZ)
                && ((aux_mag->offset & BMA4_MAG_CONFIG_OFFSET_MSK) == 0x00)) {
            data = (uint8_t)(aux_mag->odr |
                             ((aux_mag->offset <<
                               BMA4_MAG_CONFIG_OFFSET_POS)));
            rslt |= bma4_write_regs(BMA4_AUX_CONFIG_ADDR, &data, 1, dev);
        } else {
            rslt |= BMA4_E_OUT_OF_RANGE;
        }
    }
    return rslt;
}