You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2017/02/24 19:38:28 UTC

[33/50] incubator-mynewt-core git commit: Cleaning up, adding comments for public APIs

Cleaning up, adding comments for public APIs


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1b0f3757
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1b0f3757
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1b0f3757

Branch: refs/heads/develop
Commit: 1b0f3757634caeb7e8a6615cefa6732c0dee9f2a
Parents: e5c20c8
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Feb 6 18:22:26 2017 -0800
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Feb 6 18:42:00 2017 -0800

----------------------------------------------------------------------
 hw/drivers/sensors/tsl2561/src/tsl2561.c | 17 +++++++++--
 hw/sensor/src/sensor.c                   | 43 ++++++++++++++++++++-------
 2 files changed, 46 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1b0f3757/hw/drivers/sensors/tsl2561/src/tsl2561.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tsl2561/src/tsl2561.c b/hw/drivers/sensors/tsl2561/src/tsl2561.c
index 1fbf905..b3c7d2d 100644
--- a/hw/drivers/sensors/tsl2561/src/tsl2561.c
+++ b/hw/drivers/sensors/tsl2561/src/tsl2561.c
@@ -347,7 +347,8 @@ err:
     return rc;
 }
 
-int tsl2561_setup_interrupt (uint8_t rate, uint16_t lower, uint16_t upper)
+int
+tsl2561_setup_interrupt (uint8_t rate, uint16_t lower, uint16_t upper)
 {
     int rc;
     uint8_t intval;
@@ -383,7 +384,8 @@ err:
     return rc;
 }
 
-int tsl2561_enable_interrupt (uint8_t enable)
+int
+tsl2561_enable_interrupt (uint8_t enable)
 {
     int rc;
     uint8_t persist_val;
@@ -412,7 +414,8 @@ err:
     return rc;
 }
 
-int tsl2561_clear_interrupt (void)
+int
+tsl2561_clear_interrupt (void)
 {
     int rc;
     uint8_t payload = { TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT };
@@ -438,6 +441,14 @@ err:
     return rc;
 }
 
+/**
+ * Expects to be called back through os_dev_create().
+ *
+ * @param The device object associated with this accellerometer
+ * @param Argument passed to OS device init, unused
+ *
+ * @return 0 on success, non-zero error on failure.
+ */
 int
 tsl2561_init(struct os_dev *dev, void *arg)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1b0f3757/hw/sensor/src/sensor.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor.c b/hw/sensor/src/sensor.c
index 897b7be..102c0fe 100644
--- a/hw/sensor/src/sensor.c
+++ b/hw/sensor/src/sensor.c
@@ -37,6 +37,14 @@ struct {
     TAILQ_HEAD(, sensor) mgr_sensor_list;
 } sensor_mgr;
 
+struct sensor_read_ctx {
+    sensor_data_func_t user_func;
+    void *user_arg;
+};
+
+/**
+ * Lock sensor manager to access the list of sensors
+ */
 int
 sensor_mgr_lock(void)
 {
@@ -49,6 +57,9 @@ sensor_mgr_lock(void)
     return (rc);
 }
 
+/**
+ * Unlock sensor manager once the list of sensors has been accessed
+ */
 void
 sensor_mgr_unlock(void)
 {
@@ -85,7 +96,7 @@ sensor_mgr_insert(struct sensor *sensor)
 }
 
 /**
- * Register the sensor with the global sensor list.   This makes the sensor
+ * Register the sensor with the global sensor list. This makes the sensor
  * searchable by other packages, who may want to look it up by type.
  *
  * @param The sensor to register
@@ -136,10 +147,10 @@ sensor_mgr_poll_one(struct sensor *sensor, os_time_t now)
      */
     sensor_read(sensor, SENSOR_TYPE_ALL, NULL, NULL, OS_TIMEOUT_NEVER);
 
-    /* Remove the sensor from the sensor list for insertion sort. */
+    /* Remove the sensor from the sensor list for insert. */
     sensor_mgr_remove(sensor);
 
-    /* Set next wakeup, and insertion sort the sensor back into the
+    /* Set next wakeup, and insert the sensor back into the
      * list.
      */
     os_time_ms_to_ticks(sensor->s_poll_rate, &sensor_ticks);
@@ -160,6 +171,8 @@ err:
 /**
  * Event that wakes up the sensor manager, this goes through the sensor
  * list and polls any active sensors.
+ *
+ * @param OS event
  */
 static void
 sensor_mgr_wakeup_event(struct os_event *ev)
@@ -214,6 +227,10 @@ done:
     os_callout_reset(&sensor_mgr.mgr_wakeup_callout, task_next_wakeup);
 }
 
+/**
+ * Get the current eventq, the system is misconfigured if there is still
+ * no parent eventq.
+ */
 struct os_eventq *
 sensor_mgr_evq_get(void)
 {
@@ -348,7 +365,7 @@ sensor_mgr_match_bydevname(struct sensor *sensor, void *arg)
 
 
 /**
- * Search teh sensor list, and find the next sensor that correspondes
+ * Search the sensor list and find the next sensor that corresponds
  * to a given device name.
  *
  * @param The device name to search for
@@ -437,7 +454,7 @@ err:
 
 
 /**
- * Register a sensor listener.  This allows a calling application to receive
+ * Register a sensor listener. This allows a calling application to receive
  * callbacks for data from a given sensor object.
  *
  * For more information on the type of callbacks available, see the documentation
@@ -468,6 +485,16 @@ err:
     return (rc);
 }
 
+/**
+ * Un-register a sensor listener. This allows a calling application to unset
+ * callbacks for a given sensor object.
+ *
+ * @param The sensor object
+ * @param The listener to remove from the sensor listener list
+ *
+ * @return 0 on success, non-zero error code on failure.
+ */
+
 int
 sensor_unregister_listener(struct sensor *sensor,
         struct sensor_listener *listener)
@@ -490,12 +517,6 @@ err:
     return (rc);
 }
 
-
-struct sensor_read_ctx {
-    sensor_data_func_t user_func;
-    void *user_arg;
-};
-
 static int
 sensor_read_data_func(struct sensor *sensor, void *arg, void *data)
 {