drivers: sensor: Add sensor_value_from_double

Add helper function to convert double to struct sensor_value.

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
diff --git a/include/drivers/sensor.h b/include/drivers/sensor.h
index 9d852ba..20b2458 100644
--- a/include/drivers/sensor.h
+++ b/include/drivers/sensor.h
@@ -649,6 +649,18 @@
 }
 
 /**
+ * @brief Helper function for converting double to struct sensor_value.
+ *
+ * @param val A pointer to a sensor_value struct.
+ * @param inp The converted value.
+ */
+static inline void sensor_value_from_double(struct sensor_value *val, double inp)
+{
+	val->val1 = (int32_t) inp;
+	val->val2 = (int32_t)(inp * 1000000) % 1000000;
+}
+
+/**
  * @}
  */