aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/devices_lib
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-02-08 12:13:15 +0100
committerStephane D'Alu <sdalu@sdalu.com>2016-02-08 12:13:15 +0100
commit08fa41749ed577e71f04854e5176ae61fd7c036b (patch)
tree481e9f5556c73aa14288ec5a4429b6e9d713930f /os/various/devices_lib
parentd124d1144fc6e8234a8579a09fac314ed35074e6 (diff)
downloadChibiOS-Contrib-08fa41749ed577e71f04854e5176ae61fd7c036b.tar.gz
ChibiOS-Contrib-08fa41749ed577e71f04854e5176ae61fd7c036b.tar.bz2
ChibiOS-Contrib-08fa41749ed577e71f04854e5176ae61fd7c036b.zip
changed file layout, move startup/bootup time to #define
Diffstat (limited to 'os/various/devices_lib')
-rw-r--r--os/various/devices_lib/sensors/hdc1000.c (renamed from os/various/devices_lib/sensors/hdc1000/hdc1000.c)0
-rw-r--r--os/various/devices_lib/sensors/hdc1000.h (renamed from os/various/devices_lib/sensors/hdc1000/hdc1000.h)0
-rw-r--r--os/various/devices_lib/sensors/mcp9808.c (renamed from os/various/devices_lib/sensors/mcp9808/mcp9808.c)0
-rw-r--r--os/various/devices_lib/sensors/mcp9808.h (renamed from os/various/devices_lib/sensors/mcp9808/mcp9808.h)38
-rw-r--r--os/various/devices_lib/sensors/sensor.h66
-rw-r--r--os/various/devices_lib/sensors/tsl2561.c (renamed from os/various/devices_lib/sensors/tsl2561/tsl2561.c)3
-rw-r--r--os/various/devices_lib/sensors/tsl2561.h (renamed from os/various/devices_lib/sensors/tsl2561/tsl2561.h)12
7 files changed, 88 insertions, 31 deletions
diff --git a/os/various/devices_lib/sensors/hdc1000/hdc1000.c b/os/various/devices_lib/sensors/hdc1000.c
index 218450d..218450d 100644
--- a/os/various/devices_lib/sensors/hdc1000/hdc1000.c
+++ b/os/various/devices_lib/sensors/hdc1000.c
diff --git a/os/various/devices_lib/sensors/hdc1000/hdc1000.h b/os/various/devices_lib/sensors/hdc1000.h
index 9533060..9533060 100644
--- a/os/various/devices_lib/sensors/hdc1000/hdc1000.h
+++ b/os/various/devices_lib/sensors/hdc1000.h
diff --git a/os/various/devices_lib/sensors/mcp9808/mcp9808.c b/os/various/devices_lib/sensors/mcp9808.c
index 296c2f1..296c2f1 100644
--- a/os/various/devices_lib/sensors/mcp9808/mcp9808.c
+++ b/os/various/devices_lib/sensors/mcp9808.c
diff --git a/os/various/devices_lib/sensors/mcp9808/mcp9808.h b/os/various/devices_lib/sensors/mcp9808.h
index 2d488d7..3bae5d2 100644
--- a/os/various/devices_lib/sensors/mcp9808/mcp9808.h
+++ b/os/various/devices_lib/sensors/mcp9808.h
@@ -16,8 +16,17 @@
#define MCP9808_CONTINUOUS_ACQUISITION_SUPPORTED TRUE
-#define MCP9808_I2CADDR 0x18
+#define MCP9808_I2CADDR_FIXED 0x18
+/**
+ * @brief Time necessary for the sensor to boot
+ */
+#define MCP9808_BOOTUP_TIME 0
+
+/**
+ * @brief Time necessary for the sensor to start
+ */
+#define MCP9808_STARTUP_TIME 0
/*===========================================================================*/
/* Driver pre-compile time settings. */
@@ -27,7 +36,7 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#define MCP9808_I2CADDR_DEFAULT MCP9808_I2CADDR
+#define MCP9808_I2CADDR_DEFAULT MCP9808_I2CADDR_FIXED
/*===========================================================================*/
/* Driver data structures and types. */
@@ -111,31 +120,6 @@ MCP9808_setResolution(MCP9808_drv *drv,
MCP9808_resolution_t res);
/**
- * @brief Time necessary for the sensor to boot
- *
- * @returns
- * unsigned int time in millis-seconds
- */
-
-static inline unsigned int
-MCP9808_getBootupTime(MCP9808_drv *drv) {
- (void)drv;
- return 0; /* no info found */
-};
-
-/**
- * @brief Time necessary the sensor to for starting
- *
- * @returns
- * unsigned int time in millis-seconds
- */
-static inline unsigned int
-MCP9808_getStartupTime(MCP9808_drv *drv) {
- (void)drv;
- return 0; /* no info found */
-};
-
-/**
* @brief Time in milli-seconds necessary for acquiring a naw measure
*
* @returns
diff --git a/os/various/devices_lib/sensors/sensor.h b/os/various/devices_lib/sensors/sensor.h
new file mode 100644
index 0000000..6ffa5a4
--- /dev/null
+++ b/os/various/devices_lib/sensors/sensor.h
@@ -0,0 +1,66 @@
+/**
+ *
+ * Example of function calls.
+ *
+ * @code
+ * static SENSOR_config sensor_config = {
+ * };
+ * static SENSOR_drv sensor_drv;
+ * @endcode
+ *
+ *
+ * @code
+ * osalThreadSleepMilliseconds(SENSOR_BOOTUP_TIME);
+ * SENSOR_init(&sensor_drv);
+ * @endcode
+ *
+ * @code
+ * SENSOR_start(&sensor_drv, &sensor_config);
+ * osalThreadSleepMilliseconds(SENSOR_STARTUP_TIME);
+ * @endcode
+ *
+ * If using SENSOR_startMeasure()/SENSOR_readMeasure()
+ * @code
+ * while(true) {
+ * SENSOR_startMeasure(&sensor_drv);
+ * osalThreadSleepMilliseconds(SENSOR_getAcquisitionTime());
+ * SENSOR_readMeasure(&sensor_drv, ...);
+ * }
+ * @endcode
+ *
+ * If using SENSOR_readValue() or SENSOR_getValue()
+ * @code
+ * #if SENSOR_CONTINUOUS_ACQUISITION_SUPPORTED == TRUE
+ * osalThreadSleepMilliseconds(SENSOR_getAcquisitionTime())
+ * #endif
+ *
+ * while(true) {
+ * SENSOR_readValue(&sensor_drv, ...);
+ * }
+ * @encode
+ */
+#ifndef _SENSOR_H_
+#define _SENSOR_H_
+
+#define SENSOR_OK MSG_OK /**< @brief Operation successful. */
+#define SENSOR_TIMEOUT MSG_TIMEOUT /**< @brief Communication timeout */
+#define SENSOR_RESET MSG_REST /**< @brief Communication error. */
+#define SENSOR_NOTFOUND (msg_t)-20 /**< @brief Sensor not found. */
+
+
+/**
+ * @brief Driver state machine possible states.
+ */
+typedef enum __attribute__ ((__packed__)) {
+ SENSOR_UNINIT = 0, /**< Not initialized. */
+ SENSOR_INIT = 1, /**< Initialized. */
+ SENSOR_STARTED = 2, /**< Started. */
+ SENSOR_MEASURING = 4, /**< Measuring. */
+ SENSOR_READY = 3, /**< Ready. */
+ SENSOR_STOPPED = 5, /**< Stopped. */
+ SENSOR_ERROR = 6, /**< Error. */
+} sensor_state_t;
+
+#endif
+
+
diff --git a/os/various/devices_lib/sensors/tsl2561/tsl2561.c b/os/various/devices_lib/sensors/tsl2561.c
index e8372c0..f67823a 100644
--- a/os/various/devices_lib/sensors/tsl2561/tsl2561.c
+++ b/os/various/devices_lib/sensors/tsl2561.c
@@ -249,9 +249,6 @@ _readChannel(TSL2561_drv *drv, uint16_t *broadband, uint16_t *ir) {
TSL2561_REG_CHAN1_LOW,
ir )) < MSG_OK))
return msg;
-
-
- chprintf(&SD1, "CHANNELS : %x, %x\r\n", *broadband, *ir);
return MSG_OK;
}
diff --git a/os/various/devices_lib/sensors/tsl2561/tsl2561.h b/os/various/devices_lib/sensors/tsl2561.h
index 16e63d3..d91fb4a 100644
--- a/os/various/devices_lib/sensors/tsl2561/tsl2561.h
+++ b/os/various/devices_lib/sensors/tsl2561.h
@@ -26,11 +26,21 @@
#define TSL2561_OVERLOADED (-1)
-// I2C address
+/* I2C address */
#define TSL2561_I2CADDR_LOW (0x29)
#define TSL2561_I2CADDR_FLOAT (0x39)
#define TSL2561_I2CADDR_HIGH (0x49)
+/**
+ * @brief Time necessary for the sensor to boot
+ */
+#define TSL2561_BOOTUP_TIME 0
+
+/**
+ * @brief Time necessary for the sensor to start
+ */
+#define TSL2561_STARTUP_TIME 0
+
/*===========================================================================*/