diff options
author | Stephane D'Alu <sdalu@sdalu.com> | 2016-02-08 12:13:15 +0100 |
---|---|---|
committer | Stephane D'Alu <sdalu@sdalu.com> | 2016-02-08 12:13:15 +0100 |
commit | 08fa41749ed577e71f04854e5176ae61fd7c036b (patch) | |
tree | 481e9f5556c73aa14288ec5a4429b6e9d713930f /os/various/devices_lib/sensors/sensor.h | |
parent | d124d1144fc6e8234a8579a09fac314ed35074e6 (diff) | |
download | ChibiOS-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/sensors/sensor.h')
-rw-r--r-- | os/various/devices_lib/sensors/sensor.h | 66 |
1 files changed, 66 insertions, 0 deletions
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 + + |