Lines Matching +full:double +full:- +full:output +full:- +full:range
10 * SPDX-License-Identifier: Apache-2.0
42 * and can be obtained using the formula val1 + val2 * 10^(-6). Negative
47 * -0.5: val1 = 0, val2 = -500000
48 * -1.0: val1 = -1, val2 = 0
49 * -1.5: val1 = -1, val2 = -500000
54 /** Fractional part of the value (in one-millionth parts). */
101 /** Illuminance in infra-red spectrum, in lux. */
112 /** 1.0 micro-meters Particulate Matter, in ug/m^3 */
114 /** 2.5 micro-meters Particulate Matter, in ug/m^3 */
116 /** 10 micro-meters Particulate Matter, in ug/m^3 */
133 /** Current Shunt Voltage in milli-volts **/
230 * Timer-based trigger, useful when the sensor does not have an
238 * This includes any-motion detection when the channel is
258 /** Trigger fires when a double tap is detected. */
315 /** Threshold for any-motion (slope) trigger. */
326 /** Sensor range, in SI units. */
346 /** Free-fall duration represented in milliseconds.
483 * @return -ENOTSUP if the channel/channel_idx aren't found
498 * @return -ENOTSUP if the channel is not supported
512 * decoder->decode(buffer, SENSOR_CHAN_DISTANCE, 0, &fit, 5, out);
516 * decoder->decode(buffer, SENSOR_CHAN_DISTANCE, 1, &fit, 5, out);
587 * @param[out] out The output buffer
593 return ctx->decoder->decode(ctx->buffer, ctx->channel, &ctx->fit, max_count, out); in sensor_decode()
743 (const struct sensor_driver_api *)dev->api; in z_impl_sensor_attr_set()
745 if (api->attr_set == NULL) { in z_impl_sensor_attr_set()
746 return -ENOSYS; in z_impl_sensor_attr_set()
749 return api->attr_set(dev, chan, attr, val); in z_impl_sensor_attr_set()
775 (const struct sensor_driver_api *)dev->api; in z_impl_sensor_attr_get()
777 if (api->attr_get == NULL) { in z_impl_sensor_attr_get()
778 return -ENOSYS; in z_impl_sensor_attr_get()
781 return api->attr_get(dev, chan, attr, val); in z_impl_sensor_attr_get()
792 * The user-allocated trigger will be stored by the driver as a pointer, rather
811 (const struct sensor_driver_api *)dev->api; in sensor_trigger_set()
813 if (api->trigger_set == NULL) { in sensor_trigger_set()
814 return -ENOSYS; in sensor_trigger_set()
817 return api->trigger_set(dev, trig, handler); in sensor_trigger_set()
843 (const struct sensor_driver_api *)dev->api; in z_impl_sensor_sample_fetch()
845 return api->sample_fetch(dev, SENSOR_CHAN_ALL); in z_impl_sensor_sample_fetch()
876 (const struct sensor_driver_api *)dev->api; in z_impl_sensor_sample_fetch_chan()
878 return api->sample_fetch(dev, type); in z_impl_sensor_sample_fetch_chan()
911 (const struct sensor_driver_api *)dev->api; in z_impl_sensor_channel_get()
913 return api->channel_get(dev, chan, val); in z_impl_sensor_channel_get()
935 int8_t _padding[sizeof(struct sensor_chan_spec) - 1];
942 * @brief checks if a given channel is a 3-axis channel
991 const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; in z_impl_sensor_get_decoder()
995 if (api->get_decoder == NULL) { in z_impl_sensor_get_decoder()
1000 return api->get_decoder(dev, decoder); in z_impl_sensor_get_decoder()
1030 struct sensor_read_config *cfg = (struct sensor_read_config *)iodev->data; in z_impl_sensor_reconfigure_read_iodev()
1032 if (cfg->max < num_channels || cfg->is_streaming) { in z_impl_sensor_reconfigure_read_iodev()
1033 return -ENOMEM; in z_impl_sensor_reconfigure_read_iodev()
1036 cfg->sensor = sensor; in z_impl_sensor_reconfigure_read_iodev()
1037 memcpy(cfg->channels, channels, num_channels * sizeof(struct sensor_chan_spec)); in z_impl_sensor_reconfigure_read_iodev()
1038 cfg->count = num_channels; in z_impl_sensor_reconfigure_read_iodev()
1054 return -ENOMEM; in sensor_stream()
1091 return -ENOMEM; in sensor_read()
1098 int res = cqe->result; in sensor_read()
1100 __ASSERT(cqe->userdata == buf, in sensor_read()
1101 "consumed non-matching completion for sensor read into buffer %p\n", buf); in sensor_read()
1109 * @brief One shot non-blocking read with pool allocated buffer
1133 return -ENOMEM; in sensor_read_async_mempool()
1190 int64_t micro_ms2 = ms2->val1 * 1000000LL + ms2->val2; in sensor_ms2_to_g()
1195 return (micro_ms2 - SENSOR_G / 2) / SENSOR_G; in sensor_ms2_to_g()
1207 ms2->val1 = ((int64_t)g * SENSOR_G) / 1000000LL; in sensor_g_to_ms2()
1208 ms2->val2 = ((int64_t)g * SENSOR_G) % 1000000LL; in sensor_g_to_ms2()
1221 int64_t nano_ms2 = (ms2->val1 * 1000000LL + ms2->val2) * 1000LL; in sensor_ms2_to_mg()
1226 return (nano_ms2 - SENSOR_G / 2) / SENSOR_G; in sensor_ms2_to_mg()
1240 int64_t micro_ms2 = (ms2->val1 * INT64_C(1000000)) + ms2->val2; in sensor_ms2_to_ug()
1253 ms2->val1 = ((int64_t)ug * SENSOR_G / 1000000LL) / 1000000LL; in sensor_ug_to_ms2()
1254 ms2->val2 = ((int64_t)ug * SENSOR_G / 1000000LL) % 1000000LL; in sensor_ug_to_ms2()
1266 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2; in sensor_rad_to_degrees()
1271 return (micro_rad_s * 180LL - SENSOR_PI / 2) / SENSOR_PI; in sensor_rad_to_degrees()
1283 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL) / 1000000LL; in sensor_degrees_to_rad()
1284 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL) % 1000000LL; in sensor_degrees_to_rad()
1290 * When the unit is 1 micro degree, the range that the int32_t can represent is
1291 * +/-2147.483 degrees. In order to increase this range, here we use 10 micro
1300 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2; in sensor_rad_to_10udegrees()
1313 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) / 1000000LL; in sensor_10udegrees_to_rad()
1314 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) % 1000000LL; in sensor_10udegrees_to_rad()
1318 * @brief Helper function for converting struct sensor_value to double.
1323 static inline double sensor_value_to_double(const struct sensor_value *val) in sensor_value_to_double()
1325 return (double)val->val1 + (double)val->val2 / 1000000; in sensor_value_to_double()
1336 return (float)val->val1 + (float)val->val2 / 1000000; in sensor_value_to_float()
1340 * @brief Helper function for converting double to struct sensor_value.
1346 static inline int sensor_value_from_double(struct sensor_value *val, double inp) in sensor_value_from_double()
1349 return -ERANGE; in sensor_value_from_double()
1352 double val2 = (inp - (int32_t)inp) * 1000000.0; in sensor_value_from_double()
1355 return -ERANGE; in sensor_value_from_double()
1358 val->val1 = (int32_t)inp; in sensor_value_from_double()
1359 val->val2 = (int32_t)val2; in sensor_value_from_double()
1373 float val2 = (inp - (int32_t)inp) * 1000000.0f; in sensor_value_from_float()
1375 if (val2 < INT32_MIN || val2 > (float)(INT32_MAX - 1)) { in sensor_value_from_float()
1376 return -ERANGE; in sensor_value_from_float()
1379 val->val1 = (int32_t)inp; in sensor_value_from_float()
1380 val->val2 = (int32_t)val2; in sensor_value_from_float()
1479 return ((int64_t)val->val1 * 1000) + val->val2 / 1000; in sensor_value_to_milli()
1490 return ((int64_t)val->val1 * 1000000) + val->val2; in sensor_value_to_micro()
1502 if (milli < ((int64_t)INT32_MIN - 1) * 1000LL || in sensor_value_from_milli()
1504 return -ERANGE; in sensor_value_from_milli()
1507 val->val1 = (int32_t)(milli / 1000); in sensor_value_from_milli()
1508 val->val2 = (int32_t)(milli % 1000) * 1000; in sensor_value_from_milli()
1522 if (micro < ((int64_t)INT32_MIN - 1) * 1000000LL || in sensor_value_from_micro()
1524 return -ERANGE; in sensor_value_from_micro()
1527 val->val1 = (int32_t)(micro / 1000000LL); in sensor_value_from_micro()
1528 val->val2 = (int32_t)(micro % 1000000LL); in sensor_value_from_micro()