aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/lib/peripherals
diff options
context:
space:
mode:
authorroccomarco <roccomarco@35acf78f-673a-0410-8e92-d51de3d6d3f4>2016-03-05 19:57:15 +0000
committerroccomarco <roccomarco@35acf78f-673a-0410-8e92-d51de3d6d3f4>2016-03-05 19:57:15 +0000
commitb20d445f4af15433e18b9c4507ceb00d297fbd66 (patch)
tree6bcacefba9ccebd0f7287ab1185cf2fef8385a2e /os/hal/lib/peripherals
parent8208bfeeaafcbf4c911baf1fd94d3b6e1a957e99 (diff)
downloadChibiOS-b20d445f4af15433e18b9c4507ceb00d297fbd66.tar.gz
ChibiOS-b20d445f4af15433e18b9c4507ceb00d297fbd66.tar.bz2
ChibiOS-b20d445f4af15433e18b9c4507ceb00d297fbd66.zip
Updated peripheral interface headers
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9027 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/lib/peripherals')
-rw-r--r--os/hal/lib/peripherals/include/hal_accelerometer.h62
-rw-r--r--os/hal/lib/peripherals/include/hal_compass.h88
-rw-r--r--os/hal/lib/peripherals/include/hal_gyroscope.h92
-rw-r--r--os/hal/lib/peripherals/include/hal_sensors.h67
4 files changed, 262 insertions, 47 deletions
diff --git a/os/hal/lib/peripherals/include/hal_accelerometer.h b/os/hal/lib/peripherals/include/hal_accelerometer.h
index b4d8cfb40..f6b4229af 100644
--- a/os/hal/lib/peripherals/include/hal_accelerometer.h
+++ b/os/hal/lib/peripherals/include/hal_accelerometer.h
@@ -25,6 +25,8 @@
#ifndef _HAL_ACCELEROMETER_H_
#define _HAL_ACCELEROMETER_H_
+#include "hal_sensors.h"
+
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
@@ -42,6 +44,12 @@
/*===========================================================================*/
/**
+ * @brief BaseAccelerometer specific methods.
+ */
+#define _base_accelerometer_methods \
+ _base_sensor_methods
+
+/**
* @brief @p BaseAccelerometer virtual methods table.
*/
struct BaseAccelerometerVMT {
@@ -49,6 +57,12 @@ struct BaseAccelerometerVMT {
};
/**
+ * @brief @p BaseAccelerometer specific data.
+ */
+#define _base_accelerometer_data \
+ _base_sensor_data
+
+/**
* @brief Base accelerometer class.
* @details This class represents a generic a generic accelerometer.
*/
@@ -63,21 +77,47 @@ typedef struct {
/*===========================================================================*/
/**
- * @brief BaseAccelerometer specific methods.
+ * @name Macro Functions (BaseAccelerometer)
+ * @{
*/
-#define _base_accelerometer_methods \
- _base_sensor_methods \
- /* Remove the calibration data.*/ \
- msg_t (*reset_calibration)(void); \
- /* Invokes the calibration procedure.*/ \
- msg_t (*calibrate)(void);
+/**
+ * @brief Accelerometer get axes number.
+ *
+ * @param[in] ip pointer to a @p BaseAccelerometer class.
+ * @return The number of axes of the BaseSensor
+ *
+ * @api
+ */
+#define accelerometerGetAxesNumber(ip) sensorGetAxesNumber(ip)
/**
- * @brief @p BaseAccelerometer specific data.
- * @note It is empty because @p BaseAccelerometer is only an interface
- * without implementation.
+ * @brief Accelerometer read raw data.
+ *
+ * @param[in] ip pointer to a @p BaseAccelerometer 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_accelerometer_data
+#define accelerometerReadRaw(ip, dp) sensorReadRaw(ip, dp)
+
+/**
+ * @brief Accelerometer read cooked data.
+ *
+ * @param[in] ip pointer to a @p BaseAccelerometer 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 accelerometerReadCooked(ip, dp) sensorReadCooked(ip, dp)
+/** @} */
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/lib/peripherals/include/hal_compass.h b/os/hal/lib/peripherals/include/hal_compass.h
index 53899953a..22bf22844 100644
--- a/os/hal/lib/peripherals/include/hal_compass.h
+++ b/os/hal/lib/peripherals/include/hal_compass.h
@@ -25,6 +25,8 @@
#ifndef _HAL_COMPASS_H_
#define _HAL_COMPASS_H_
+#include "hal_sensors.h"
+
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
@@ -42,14 +44,25 @@
/*===========================================================================*/
/**
+ * @brief BaseCompass specific methods.
+ */
+#define _base_compass_methods \
+ _base_sensor_methods
+
+/**
* @brief @p BaseCompass virtual methods table.
*/
-
struct BaseCompassVMT {
_base_compass_methods
};
/**
+ * @brief @p BaseCompass specific data.
+ */
+#define _base_compass_data \
+ _base_sensor_data
+
+/**
* @brief Base compass class.
* @details This class represents a generic compass.
*/
@@ -57,30 +70,79 @@ typedef struct {
/** @brief Virtual Methods Table.*/
const struct BaseCompassVMT *vmt;
_base_compass_data
-
} BaseCompass;
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
+/**
+ * @name Macro Functions (BaseCompass)
+ * @{
+ */
+/**
+ * @brief Compass get axes number.
+ *
+ * @param[in] ip pointer to a @p BaseCompass class.
+ * @return The number of axes of the BaseSensor
+ *
+ * @api
+ */
+#define compassGetAxesNumber(ip) sensorGetAxesNumber(ip)
/**
- * @brief BaseCompass specific methods.
+ * @brief Compass read raw data.
+ *
+ * @param[in] ip pointer to a @p BaseCompass 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 compassReadRaw(ip, dp) sensorReadRaw(ip, dp)
-#define _base_compass_methods \
- _base_sensor_methods \
- /* Remove the calibration data.*/ \
- msg_t (*reset_calibration)(void); \
- /* Invokes the calibration procedure.*/ \
- msg_t (*calibrate)(void);
+/**
+ * @brief Compass read cooked data.
+ *
+ * @param[in] ip pointer to a @p BaseCompass 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 compassReadCooked(ip, dp) sensorReadCooked(ip, dp)
/**
- * @brief @p BaseCompass specific data.
- * @note It is empty because @p BaseCompass is only an interface
- * without implementation.
+ * @brief Delete calibration data.
+ *
+ * @param[in] ip pointer to a @p BaseCompass class.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
+ */
+#define compassResetCalibration(ip) ((ip)->vmt->reset_calibration(ip))
+
+/**
+ * @brief Compass calibration procedure.
+ *
+ * @param[in] ip pointer to a @p BaseCompass class.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
*/
-#define _base_compass_data
+#define compassCalibrate(ip) ((ip)->vmt->calibrate(ip))
+/** @} */
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/lib/peripherals/include/hal_gyroscope.h b/os/hal/lib/peripherals/include/hal_gyroscope.h
index c593f8fe6..142832094 100644
--- a/os/hal/lib/peripherals/include/hal_gyroscope.h
+++ b/os/hal/lib/peripherals/include/hal_gyroscope.h
@@ -25,6 +25,8 @@
#ifndef _HAL_GYROSCOPE_H_
#define _HAL_GYROSCOPE_H_
+#include "hal_sensors.h"
+
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
@@ -42,6 +44,16 @@
/*===========================================================================*/
/**
+ * @brief BaseGyroscope specific methods.
+ */
+#define _base_gyroscope_methods \
+ _base_sensor_methods \
+ /* Remove the calibration data.*/ \
+ msg_t (*reset_calibration)(void *instance); \
+ /* Invokes the calibration procedure.*/ \
+ msg_t (*calibrate)(void *instance);
+
+/**
* @brief @p BaseGyroscope virtual methods table.
*/
struct BaseGyroscopeVMT {
@@ -49,6 +61,12 @@ struct BaseGyroscopeVMT {
};
/**
+ * @brief @p BaseGyroscope specific data.
+ */
+#define _base_gyroscope_data \
+ _base_sensor_data
+
+/**
* @brief Base gyroscope class.
* @details This class represents a generic gyroscope.
*/
@@ -63,21 +81,73 @@ typedef struct {
/*===========================================================================*/
/**
- * @brief BaseGyroscope specific methods.
+ * @name Macro Functions (BaseGyroscope)
+ * @{
*/
-#define _base_gyroscope_methods \
- _base_sensor_methods \
- /* Remove the calibration data.*/ \
- msg_t (*reset_calibration)(void); \
- /* Invokes the calibration procedure.*/ \
- msg_t (*calibrate)(void);
+/**
+ * @brief Gyroscope get axes number.
+ *
+ * @param[in] ip pointer to a @p BaseGyroscope class.
+ * @return The number of axes of the BaseSensor
+ *
+ * @api
+ */
+#define gyroscopeGetAxesNumber(ip) sensorGetAxesNumber(ip)
/**
- * @brief @p BaseGyroscope specific data.
- * @note It is empty because @p BaseGyroscope is only an interface
- * without implementation.
+ * @brief Gyroscope read raw data.
+ *
+ * @param[in] ip pointer to a @p BaseGyroscope 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_gyroscope_data
+#define gyroscopeReadRaw(ip, dp) sensorReadRaw(ip, dp)
+
+/**
+ * @brief Gyroscope read cooked data.
+ *
+ * @param[in] ip pointer to a @p BaseGyroscope 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 gyroscopeReadCooked(ip, dp) sensorReadCooked(ip, dp)
+
+/**
+ * @brief Delete calibration data.
+ *
+ * @param[in] ip pointer to a @p BaseGyroscope class.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
+ */
+#define gyroscopeResetCalibration(ip) ((ip)->vmt->reset_calibration(ip))
+
+/**
+ * @brief Gyroscope calibration procedure.
+ *
+ * @param[in] ip pointer to a @p BaseGyroscope class.
+ *
+ * @return The operation status.
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more errors occurred.
+ *
+ * @api
+ */
+#define gyroscopeCalibrate(ip) ((ip)->vmt->calibrate(ip))
+/** @} */
/*===========================================================================*/
/* External declarations. */
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. */