product/juno/module/juno_pvt/src/mod_juno_pvt.c
static int process_osc_calibration(struct pvt_sub_dev_ctx *sensor_ctx,
                                   uint16_t cal_810,
                                   uint16_t cal_900)
{
    unsigned int freq_810;
    unsigned int freq_900;
    unsigned int freq_fs;
    unsigned int freq_b;
    unsigned int sample_window;
    unsigned int slope_m;

    if ((cal_810 == 0) || (cal_900 == 0)) {
        return FWK_E_PARAM;
    }

    /* Convert into kHz */
    freq_810 = (unsigned int)(cal_810 * 20);
    freq_900 = (unsigned int)(cal_900 * 20);

    /* Find the slope */
    slope_m = (freq_900 - freq_810) / (900 - 810);

    /* Find the intercept of the line */
    freq_b = freq_900 - (slope_m * 900);

    /* Use line equation to find full-scale frequency */
    freq_fs = (slope_m * FULL_SCALE_MVOLT) + freq_b;

    /*
     * freq_fs must be always bigger than or equal to REFCLK_KHZ or
     * sample_window calculation won't work.
     */
    if (freq_fs < REFCLK_KHZ) {
        return FWK_E_RANGE;
    }

    /* Calculate sample window to fit the full scale reading */
    sample_window = (SAMPLE_WINDOW_MASK * REFCLK_KHZ) / freq_fs;
    if (sample_window > SAMPLE_WINDOW_MASK) {
        return FWK_E_PARAM;
    }

    /* Store constants for the run-time calculations */
    sensor_ctx->slope_m = (int)slope_m;
    sensor_ctx->freq_b = (int)freq_b;
    sensor_ctx->sample_window = sample_window;

    return FWK_SUCCESS;
}
/*
 * For the ring oscillator based sensors, there are two calibration points:
 * 810mV and 900mV
 *
 * The maths in this function considers mV on the X-axis and sensor readings
 * on the Y-axis.
 */
For the ring oscillator based sensors, there are two calibration points:
810mV and 900mV

The maths in this function considers mV on the X-axis and sensor readings
on the Y-axis.
For the ring oscillator based sensors there are two calibration points : 810mV and 900mV The maths in this function considers mV on the X - axis and sensor readings on the Y - axis .
static int process_osc_calibration(struct pvt_sub_dev_ctx *sensor_ctx,
                                   uint16_t cal_810,
                                   uint16_t cal_900)
{
    unsigned int freq_810;
    unsigned int freq_900;
    unsigned int freq_fs;
    unsigned int freq_b;
    unsigned int sample_window;
    unsigned int slope_m;
    if ((cal_810 == 0) || (cal_900 == 0)) {
        return FWK_E_PARAM;
    }
    freq_810 = (unsigned int)(cal_810 * 20);
    freq_900 = (unsigned int)(cal_900 * 20);
    slope_m = (freq_900 - freq_810) / (900 - 810);
    freq_b = freq_900 - (slope_m * 900);
    freq_fs = (slope_m * FULL_SCALE_MVOLT) + freq_b;
    if (freq_fs < REFCLK_KHZ) {
        return FWK_E_RANGE;
    }
    sample_window = (SAMPLE_WINDOW_MASK * REFCLK_KHZ) / freq_fs;
    if (sample_window > SAMPLE_WINDOW_MASK) {
        return FWK_E_PARAM;
    }
    sensor_ctx->slope_m = (int)slope_m;
    sensor_ctx->freq_b = (int)freq_b;
    sensor_ctx->sample_window = sample_window;
    return FWK_SUCCESS;
}
static int process_osc_calibration ( struct pvt_sub_dev_ctx * sensor_ctx , uint16_t cal_810 , uint16_t cal_900 ) { unsigned int freq_810 ; unsigned int freq_900 ; unsigned int freq_fs ; unsigned int freq_b ; unsigned int sample_window ; unsigned int slope_m ; if ( ( cal_810 == 0 ) || ( cal_900 == 0 ) ) { return FWK_E_PARAM ; } freq_810 = ( unsigned int ) ( cal_810 * 20 ) ; freq_900 = ( unsigned int ) ( cal_900 * 20 ) ; slope_m = ( freq_900 - freq_810 ) / ( 900 - 810 ) ; freq_b = freq_900 - ( slope_m * 900 ) ; freq_fs = ( slope_m * FULL_SCALE_MVOLT ) + freq_b ; if ( freq_fs < REFCLK_KHZ ) { return FWK_E_RANGE ; } sample_window = ( SAMPLE_WINDOW_MASK * REFCLK_KHZ ) / freq_fs ; if ( sample_window > SAMPLE_WINDOW_MASK ) { return FWK_E_PARAM ; } sensor_ctx -> slope_m = ( int ) slope_m ; sensor_ctx -> freq_b = ( int ) freq_b ; sensor_ctx -> sample_window = sample_window ; return FWK_SUCCESS ; }
For the ring oscillator based sensors, there are two calibration points:
 810mV and 900mV
For the ring oscillator based sensors there are two calibration points : 810mV and 900mV
/* Convert into kHz */ /* Find the slope */ /* Find the intercept of the line */ /* Use line equation to find full-scale frequency */ /*
     * freq_fs must be always bigger than or equal to REFCLK_KHZ or
     * sample_window calculation won't work.
     */ /* Calculate sample window to fit the full scale reading */ /* Store constants for the run-time calculations */