You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/01/10 22:45:22 UTC

[GitHub] vrahane closed pull request #689: Feature/sensor cfg

vrahane closed pull request #689: Feature/sensor cfg
URL: https://github.com/apache/mynewt-core/pull/689
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/sensors/bmp280/src/bmp280.c b/hw/drivers/sensors/bmp280/src/bmp280.c
index b736e6cab..c3904a9af 100644
--- a/hw/drivers/sensors/bmp280/src/bmp280.c
+++ b/hw/drivers/sensors/bmp280/src/bmp280.c
@@ -74,10 +74,12 @@ static int bmp280_sensor_read(struct sensor *, sensor_type_t,
         sensor_data_func_t, void *, uint32_t);
 static int bmp280_sensor_get_config(struct sensor *, sensor_type_t,
         struct sensor_cfg *);
+static int bmp280_sensor_set_config(struct sensor *, void *);
 
 static const struct sensor_driver g_bmp280_sensor_driver = {
-    bmp280_sensor_read,
-    bmp280_sensor_get_config
+    .sd_read = bmp280_sensor_read,
+    .sd_get_config = bmp280_sensor_get_config,
+    .sd_set_config = bmp280_sensor_set_config,
 };
 
 static int
@@ -467,6 +469,14 @@ bmp280_sensor_get_config(struct sensor *sensor, sensor_type_t type,
     return (rc);
 }
 
+static int
+bmp280_sensor_set_config(struct sensor *sensor, void *cfg)
+{
+    struct bmp280* bmp280 = (struct bmp280 *)SENSOR_GET_DEVICE(sensor);
+    
+    return bmp280_config(bmp280, (struct bmp280_cfg*)cfg);
+}
+
 /**
  * Check status to see if the sensor is  reading calibration
  *
diff --git a/hw/drivers/sensors/ms5837/src/ms5837.c b/hw/drivers/sensors/ms5837/src/ms5837.c
index ff08a7531..1f7fdacfd 100644
--- a/hw/drivers/sensors/ms5837/src/ms5837.c
+++ b/hw/drivers/sensors/ms5837/src/ms5837.c
@@ -72,10 +72,12 @@ static int ms5837_sensor_read(struct sensor *, sensor_type_t,
         sensor_data_func_t, void *, uint32_t);
 static int ms5837_sensor_get_config(struct sensor *, sensor_type_t,
         struct sensor_cfg *);
+static int ms5837_sensor_set_config(struct sensor *, void *);
 
 static const struct sensor_driver g_ms5837_sensor_driver = {
-    ms5837_sensor_read,
-    ms5837_sensor_get_config
+    .sd_read = ms5837_sensor_read,
+    .sd_get_config = ms5837_sensor_get_config,
+    .sd_set_config = ms5837_sensor_set_config,
 };
 
 /**
@@ -266,6 +268,14 @@ ms5837_sensor_get_config(struct sensor *sensor, sensor_type_t type,
     return (rc);
 }
 
+static int
+ms5837_sensor_set_config(struct sensor *sensor, void *cfg)
+{
+    struct ms5837* ms5837 = (struct ms5837 *)SENSOR_GET_DEVICE(sensor);
+    
+    return ms5837_config(ms5837, (struct ms5837_cfg*)cfg);
+}
+
 /**
  * Configure MS5837 sensor
  *
diff --git a/hw/sensor/include/sensor/sensor.h b/hw/sensor/include/sensor/sensor.h
index 1d47a3247..787af7e31 100644
--- a/hw/sensor/include/sensor/sensor.h
+++ b/hw/sensor/include/sensor/sensor.h
@@ -358,6 +358,16 @@ typedef int (*sensor_read_func_t)(struct sensor *, sensor_type_t,
 typedef int (*sensor_get_config_func_t)(struct sensor *, sensor_type_t,
         struct sensor_cfg *);
 
+/** 
+ * Send a new configuration register set to the sensor.
+ *
+ * @param ptr to the sensor-specific stucture
+ * @param ptr to the sensor-specific configuration structure
+ *
+ * @return 0 on success, non-zero error code on failure.
+ */
+typedef int (*sensor_set_config_func_t)(struct sensor *, void *);
+
 /**
  * Set the trigger and threshold values for a specific sensor for the sensor
  * type.
@@ -410,6 +420,7 @@ typedef int (*sensor_handle_interrupt_t)(struct sensor *);
 struct sensor_driver {
     sensor_read_func_t sd_read;
     sensor_get_config_func_t sd_get_config;
+    sensor_set_config_func_t sd_set_config;
     sensor_set_trigger_thresh_t sd_set_trigger_thresh;
     sensor_set_notification_t sd_set_notification;
     sensor_unset_notification_t sd_unset_notification;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services