aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/lib/peripherals/include/hal_sensors.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/lib/peripherals/include/hal_sensors.h')
-rw-r--r--os/hal/lib/peripherals/include/hal_sensors.h67
1 files changed, 55 insertions, 12 deletions
diff --git a/os/hal/lib/peripherals/include/hal_sensors.h b/os/hal/lib/peripherals/include/hal_sensors.h
index b3ed9dd5d..6254f036e 100644
--- a/os/hal/lib/peripherals/include/hal_sensors.h
+++ b/os/hal/lib/peripherals/include/hal_sensors.h
@@ -42,6 +42,17 @@
/*===========================================================================*/
/**
+ * @brief BaseSensor specific methods.
+ */
+#define _base_sensor_methods \
+ /* Get number of axes.*/ \
+ size_t (*get_axes_number)(void *instance); \
+ /* Reads the sensor raw data.*/ \
+ msg_t (*read_raw)(void *instance, int32_t axes[]); \
+ /* Reads the sensor returning normalized data.*/ \
+ msg_t (*read_cooked)(void *instance, float axes[]);
+
+/**
* @brief @p BaseSensor virtual methods table.
*/
struct BaseSensorVMT {
@@ -49,6 +60,13 @@ struct BaseSensorVMT {
};
/**
+ * @brief @p BaseSensor specific data.
+ * @note It is empty because @p BaseSensor is only an interface
+ * without implementation.
+ */
+#define _base_sensor_data
+
+/**
* @brief Base stream class.
* @details This class represents a generic blocking unbuffered sequential
* data stream.
@@ -64,22 +82,47 @@ typedef struct {
/*===========================================================================*/
/**
- * @brief BaseSensor specific methods.
+ * @name Macro Functions (BaseSensor)
+ * @{
*/
-#define _base_sensor_methods \
- /* Get number of axes.*/ \
- size_t (*get_axes_number)(void); \
- /* Reads the sensor raw data.*/ \
- msg_t (*read_raw)(uint32_t axes[]); \
- /* Reads the sensor returning normalized data.*/ \
- msg_t (*read_cooked)(float axes[]);
+/**
+ * @brief Sensors get axes number.
+ *
+ * @param[in] ip pointer to a @p BaseSensor or derived class.
+ * @return The number of axes of the BaseSensor
+ *
+ * @api
+ */
+#define sensorGetAxesNumber(ip) ((ip)->vmt->get_axes_number(ip))
/**
- * @brief @p BaseSensor specific data.
- * @note It is empty because @p BaseSensor is only an interface
- * without implementation.
+ * @brief Sensors read raw data.
+ *
+ * @param[in] ip pointer to a @p BaseSensor or derived class.
+ * @param[in] dp pointer to a data array.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
*/
-#define _base_sensor_data
+#define sensorReadRaw(ip, dp) ((ip)->vmt->read_raw(ip, dp))
+
+/**
+ * @brief Sensors read cooked data.
+ *
+ * @param[in] ip pointer to a @p BaseSensor or derived class.
+ * @param[in] dp pointer to a data array.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
+ */
+#define sensorReadCooked(ip, dp) ((ip)->vmt->read_cooked(ip, dp))
+/** @} */
/*===========================================================================*/
/* External declarations. */