From b20d445f4af15433e18b9c4507ceb00d297fbd66 Mon Sep 17 00:00:00 2001 From: roccomarco Date: Sat, 5 Mar 2016 19:57:15 +0000 Subject: Updated peripheral interface headers git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9027 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/lib/peripherals/include/hal_accelerometer.h | 62 ++++++++++++--- os/hal/lib/peripherals/include/hal_compass.h | 88 ++++++++++++++++++--- os/hal/lib/peripherals/include/hal_gyroscope.h | 92 +++++++++++++++++++--- os/hal/lib/peripherals/include/hal_sensors.h | 67 +++++++++++++--- 4 files changed, 262 insertions(+), 47 deletions(-) (limited to 'os/hal/lib/peripherals') 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. */ /*===========================================================================*/ @@ -41,6 +43,12 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/** + * @brief BaseAccelerometer specific methods. + */ +#define _base_accelerometer_methods \ + _base_sensor_methods + /** * @brief @p BaseAccelerometer virtual methods table. */ @@ -48,6 +56,12 @@ struct BaseAccelerometerVMT { _base_accelerometer_methods }; +/** + * @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. */ /*===========================================================================*/ @@ -41,14 +43,25 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/** + * @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. */ /*===========================================================================*/ @@ -41,6 +43,16 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/** + * @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. */ @@ -48,6 +60,12 @@ struct BaseGyroscopeVMT { _base_gyroscope_methods }; +/** + * @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 @@ -41,6 +41,17 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/** + * @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. */ @@ -48,6 +59,13 @@ struct BaseSensorVMT { _base_sensor_methods }; +/** + * @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 @@ -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. */ -- cgit v1.2.3