hw/drivers/sensors/si1133/src/si1133.c
uint32_t
si1133_measureLuxUvif(struct si1133 *dev, float *lux, float *uvi)
{

    si1133_Samples_TypeDef samples;
    uint32_t retval;
    uint8_t response;

    /* Force measurement */
    retval = si1133_measurementForce(dev);

    /* Go to sleep while the sensor does the conversion */
    os_time_delay(20);

    /* Check if the measurement finished, if not then wait */
    retval += si1133_registerRead(dev, SI1133_REG_IRQ_STATUS, &response);
    while (response != 0x0F) {
        os_time_delay(10);
        retval += si1133_registerRead(dev, SI1133_REG_IRQ_STATUS, &response);
    }

    /* Get the results */
    si1133_measurementGet(dev, &samples);
   
    /* Convert the readings to lux */
    *lux = (float)si1133_getLux(samples.ch1, samples.ch3, samples.ch2, &lk);
    *lux = *lux / (1 << LUX_OUTPUT_FRACTION);

    /* Convert the readings to UV index */
    *uvi = (float)si1133_getUv(samples.ch0, uk);
    *uvi = *uvi / (1 << UV_OUTPUT_FRACTION);

    return retval;
}
/**
 * @brief get a measurement from SI1133
 * @param lux, ptr to where to put lux measurement
 * @param uvi, ptr to where to put uv measurement
 */
@brief get a measurement from SI1133
@param lux, ptr to where to put lux measurement
@param uvi, ptr to where to put uv measurement
@brief get a measurement from SI1133 @param lux ptr to where to put lux measurement @param uvi ptr to where to put uv measurement
uint32_t
si1133_measureLuxUvif(struct si1133 *dev, float *lux, float *uvi)
{
    si1133_Samples_TypeDef samples;
    uint32_t retval;
    uint8_t response;
    retval = si1133_measurementForce(dev);
    os_time_delay(20);
    retval += si1133_registerRead(dev, SI1133_REG_IRQ_STATUS, &response);
    while (response != 0x0F) {
        os_time_delay(10);
        retval += si1133_registerRead(dev, SI1133_REG_IRQ_STATUS, &response);
    }
    si1133_measurementGet(dev, &samples);
    *lux = (float)si1133_getLux(samples.ch1, samples.ch3, samples.ch2, &lk);
    *lux = *lux / (1 << LUX_OUTPUT_FRACTION);
    *uvi = (float)si1133_getUv(samples.ch0, uk);
    *uvi = *uvi / (1 << UV_OUTPUT_FRACTION);
    return retval;
}
uint32_t si1133_measureLuxUvif ( struct si1133 * dev , float * lux , float * uvi ) { si1133_Samples_TypeDef samples ; uint32_t retval ; uint8_t response ; retval = si1133_measurementForce ( dev ) ; os_time_delay ( 20 ) ; retval += si1133_registerRead ( dev , SI1133_REG_IRQ_STATUS , & response ) ; while ( response != 0x0F ) { os_time_delay ( 10 ) ; retval += si1133_registerRead ( dev , SI1133_REG_IRQ_STATUS , & response ) ; } si1133_measurementGet ( dev , & samples ) ; * lux = ( float ) si1133_getLux ( samples . ch1 , samples . ch3 , samples . ch2 , & lk ) ; * lux = * lux / ( 1 << LUX_OUTPUT_FRACTION ) ; * uvi = ( float ) si1133_getUv ( samples . ch0 , uk ) ; * uvi = * uvi / ( 1 << UV_OUTPUT_FRACTION ) ; return retval ; }
@brief get a measurement from SI1133
 @param lux, ptr to where to put lux measurement
 @param uvi, ptr to where to put uv measurement
@brief get a measurement from SI1133 @param lux ptr to where to put lux measurement @param uvi ptr to where to put uv measurement
/* Force measurement */ /* Go to sleep while the sensor does the conversion */ /* Check if the measurement finished, if not then wait */ /* Get the results */ /* Convert the readings to lux */ /* Convert the readings to UV index */