From 46133587396a2c6c47f09bbcdd229ae10090f5de Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Mon, 5 Feb 2018 10:27:13 +0000 Subject: Added instance getter macros (Fixing Bug #915). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11438 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/lib/peripherals/sensors/hal_accelerometer.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_barometer.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_compass.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_gyroscope.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_hygrometer.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_sensors.h | 7 +++++++ os/hal/lib/peripherals/sensors/hal_thermometer.h | 7 +++++++ 7 files changed, 49 insertions(+) (limited to 'os/hal/lib') diff --git a/os/hal/lib/peripherals/sensors/hal_accelerometer.h b/os/hal/lib/peripherals/sensors/hal_accelerometer.h index 31e12637e..91bc6fd0a 100644 --- a/os/hal/lib/peripherals/sensors/hal_accelerometer.h +++ b/os/hal/lib/peripherals/sensors/hal_accelerometer.h @@ -94,6 +94,13 @@ typedef struct { * @name Macro Functions (BaseAccelerometer) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseAccelerometer(ip) ((BaseAccelerometer *)&(ip)->vmt_accelerometer) + /** * @brief Accelerometer get axes number. * diff --git a/os/hal/lib/peripherals/sensors/hal_barometer.h b/os/hal/lib/peripherals/sensors/hal_barometer.h index 079d569ac..1ab4552cb 100644 --- a/os/hal/lib/peripherals/sensors/hal_barometer.h +++ b/os/hal/lib/peripherals/sensors/hal_barometer.h @@ -94,6 +94,13 @@ typedef struct { * @name Macro Functions (BaseBarometer) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseBarometer(ip) ((BaseBarometer *)&(ip)->vmt_barometer) + /** * @brief Barometer get channels number. * diff --git a/os/hal/lib/peripherals/sensors/hal_compass.h b/os/hal/lib/peripherals/sensors/hal_compass.h index 34473e04a..83ab8b2ab 100644 --- a/os/hal/lib/peripherals/sensors/hal_compass.h +++ b/os/hal/lib/peripherals/sensors/hal_compass.h @@ -94,6 +94,13 @@ typedef struct { * @name Macro Functions (BaseCompass) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseCompass(ip) ((BaseCompass *)&(ip)->vmt_compass) + /** * @brief Compass get axes number. * diff --git a/os/hal/lib/peripherals/sensors/hal_gyroscope.h b/os/hal/lib/peripherals/sensors/hal_gyroscope.h index 00786607e..47b3708c8 100644 --- a/os/hal/lib/peripherals/sensors/hal_gyroscope.h +++ b/os/hal/lib/peripherals/sensors/hal_gyroscope.h @@ -97,6 +97,13 @@ typedef struct { * @name Macro Functions (BaseGyroscope) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseGyroscope(ip) ((BaseGyroscope *)&(ip)->vmt_gyroscope) + /** * @brief Gyroscope get axes number. * diff --git a/os/hal/lib/peripherals/sensors/hal_hygrometer.h b/os/hal/lib/peripherals/sensors/hal_hygrometer.h index 6cf5eef21..3feace0bc 100644 --- a/os/hal/lib/peripherals/sensors/hal_hygrometer.h +++ b/os/hal/lib/peripherals/sensors/hal_hygrometer.h @@ -94,6 +94,13 @@ typedef struct { * @name Macro Functions (BaseHygrometer) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseHygrometer(ip) ((BaseHygrometer *)&(ip)->vmt_hygrometer) + /** * @brief Hygrometer get channels number. * diff --git a/os/hal/lib/peripherals/sensors/hal_sensors.h b/os/hal/lib/peripherals/sensors/hal_sensors.h index 6a97ddaed..0a09a3b21 100644 --- a/os/hal/lib/peripherals/sensors/hal_sensors.h +++ b/os/hal/lib/peripherals/sensors/hal_sensors.h @@ -91,6 +91,13 @@ typedef struct { * @name Macro Functions (BaseSensor) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseSensor(ip) ((BaseSensor *)&(ip)->vmt_sensor) + /** * @brief Sensors get channels number. * diff --git a/os/hal/lib/peripherals/sensors/hal_thermometer.h b/os/hal/lib/peripherals/sensors/hal_thermometer.h index 4620cbd0a..2094d9c0a 100644 --- a/os/hal/lib/peripherals/sensors/hal_thermometer.h +++ b/os/hal/lib/peripherals/sensors/hal_thermometer.h @@ -94,6 +94,13 @@ typedef struct { * @name Macro Functions (BaseThermometer) * @{ */ +/** + * @brief Instance getter. + * @details This special method is used to get the instance of this class + * object from a derived class. + */ +#define getBaseThermometer(ip) ((BaseThermometer *)&(ip)->vmt_thermometer) + /** * @brief Thermometer get channels number. * -- cgit v1.2.3