Moved files from HAL and renamed.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12722 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
a853d27a6d
commit
de0e42cfef
|
@ -50,7 +50,7 @@
|
|||
/**
|
||||
* @brief EX version string.
|
||||
*/
|
||||
#define CH_EX_VERSION "1.1.0"
|
||||
#define CH_EX_VERSION "1.2.0"
|
||||
|
||||
/**
|
||||
* @brief EX version major number.
|
||||
|
@ -60,7 +60,7 @@
|
|||
/**
|
||||
* @brief EX version minor number.
|
||||
*/
|
||||
#define CH_EX_MINOR 1
|
||||
#define CH_EX_MINOR 2
|
||||
|
||||
/**
|
||||
* @brief EX version patch number.
|
||||
|
@ -92,6 +92,16 @@
|
|||
/* Late inclusions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#include "ex_sensors.h"
|
||||
#include "ex_accelerometer.h"
|
||||
#include "ex_barometer.h"
|
||||
#include "ex_compass.h"
|
||||
#include "ex_displays.h"
|
||||
#include "ex_gyroscope.h"
|
||||
#include "ex_hygrometer.h"
|
||||
#include "ex_rangefinder.h"
|
||||
#include "ex_thermometer.h"
|
||||
|
||||
#endif /* EX_H */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_accelerometer.h
|
||||
* @brief Generic accelerometer interface header.
|
||||
*
|
||||
* @addtogroup EX_ACCELEROMETER
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_ACCELEROMETER_H
|
||||
#define EX_ACCELEROMETER_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseAccelerometer specific methods.
|
||||
*/
|
||||
#define _base_accelerometer_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
/**
|
||||
* @brief BaseAccelerometer specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_accelerometer_methods \
|
||||
_base_sensor_methods \
|
||||
_base_accelerometer_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseAccelerometer virtual methods table.
|
||||
*/
|
||||
struct BaseAccelerometerVMT {
|
||||
_base_accelerometer_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseAccelerometer specific data.
|
||||
*/
|
||||
#define _base_accelerometer_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base accelerometer class.
|
||||
* @details This class represents a generic a generic accelerometer.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseAccelerometerVMT *vmt;
|
||||
_base_accelerometer_data
|
||||
} BaseAccelerometer;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Macro Functions (BaseAccelerometer)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Accelerometer get axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||
* @return The number of axes of the BaseAccelerometer
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define accelerometerGetAxesNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @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 accelerometerReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(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) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates accelerometer bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the accelerometer axes number.
|
||||
*
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define accelerometerSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset accelerometer bias data restoring it to zero.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define accelerometerResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates accelerometer sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the accelerometer axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define accelerometerSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset accelerometer sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAccelerometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define accelerometerResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_ACCELEROMETER_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_barometer.h
|
||||
* @brief Generic barometer interface header.
|
||||
*
|
||||
* @addtogroup EX_BAROMETER
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_BAROMETER_H
|
||||
#define EX_BAROMETER_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseBarometer specific methods.
|
||||
*/
|
||||
#define _base_barometer_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseBarometer specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_barometer_methods \
|
||||
_base_sensor_methods \
|
||||
_base_barometer_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseBarometer virtual methods table.
|
||||
*/
|
||||
struct BaseBarometerVMT {
|
||||
_base_barometer_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseBarometer specific data.
|
||||
*/
|
||||
#define _base_barometer_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base barometer class.
|
||||
* @details This class represents a generic barometer.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseBarometerVMT *vmt;
|
||||
_base_barometer_data
|
||||
} BaseBarometer;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Macro Functions (BaseBarometer)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Barometer get channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer class.
|
||||
* @return The number of channels of the BaseBarometer
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define barometerGetChannelsNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @brief Barometer read raw data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer 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 barometerReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Barometer read cooked data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer 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 barometerReadCooked(ip, dp) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates barometer bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the barometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define barometerSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset barometer bias data restoring it to zero.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define barometerResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates barometer sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the barometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define barometerSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset barometer sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseBarometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define barometerResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_BAROMETER_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_compass.h
|
||||
* @brief Generic compass interface header.
|
||||
*
|
||||
* @addtogroup EX_COMPASS
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_COMPASS_H
|
||||
#define EX_COMPASS_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseCompass specific methods.
|
||||
*/
|
||||
#define _base_compass_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseCompass specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_compass_methods \
|
||||
_base_sensor_methods \
|
||||
_base_compass_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseCompass virtual methods table.
|
||||
*/
|
||||
struct BaseCompassVMT {
|
||||
_base_compass_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseCompass specific data.
|
||||
*/
|
||||
#define _base_compass_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base compass class.
|
||||
* @details This class represents a generic compass.
|
||||
*/
|
||||
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 BaseCompass
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define compassGetAxesNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @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) \
|
||||
(ip)->vmt->read_raw(ip, dp)
|
||||
|
||||
/**
|
||||
* @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) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates compass bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the compass axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseCompass class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define compassSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset compass bias data restoring it to zero.
|
||||
*
|
||||
* @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 compassResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates compass sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the compass axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseCompass class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define compassSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset compass sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @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 compassResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_COMPASS_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_displays.h
|
||||
* @brief Generic display interface header.
|
||||
*
|
||||
* @addtogroup EX_DISPLAYS
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_DISPLAYS_H
|
||||
#define EX_DISPLAYS_H
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief @p BaseDisplay specific methods.
|
||||
* @note No methods so far, just a common ancestor interface.
|
||||
*/
|
||||
#define _base_display_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseDisplay specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_display_methods \
|
||||
_base_display_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseDisplay virtual methods table.
|
||||
*/
|
||||
struct BaseDisplayVMT {
|
||||
_base_display_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseDisplay specific data.
|
||||
* @note It is empty because @p BaseDisplay is only an interface
|
||||
* without implementation.
|
||||
*/
|
||||
#define _base_display_data
|
||||
|
||||
/**
|
||||
* @brief Base display class.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseDisplayVMT *vmt_basedisplay;
|
||||
_base_display_data
|
||||
} BaseDisplay;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Macro Functions (BaseDisplay)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Sensors get axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseDisplay or derived class.
|
||||
* @return The number of axes of the BaseDisplay
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define displayGetType(ip) (ip)->vmt_basedisplay->get_type(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_DISPLAYS_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_gyroscope.h
|
||||
* @brief Generic gyroscope interface header.
|
||||
*
|
||||
* @addtogroup EX_GYROSCOPE
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_GYROSCOPE_H
|
||||
#define EX_GYROSCOPE_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseGyroscope specific methods.
|
||||
*/
|
||||
#define _base_gyroscope_methods_alone \
|
||||
/* Invoke the sample bias procedure.*/ \
|
||||
msg_t (*sample_bias)(void *instance); \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseGyroscope specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_gyroscope_methods \
|
||||
_base_sensor_methods \
|
||||
_base_gyroscope_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseGyroscope virtual methods table.
|
||||
*/
|
||||
struct BaseGyroscopeVMT {
|
||||
_base_gyroscope_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseGyroscope specific data.
|
||||
*/
|
||||
#define _base_gyroscope_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base gyroscope class.
|
||||
* @details This class represents a generic gyroscope.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseGyroscopeVMT *vmt;
|
||||
_base_gyroscope_data
|
||||
} BaseGyroscope;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Macro Functions (BaseGyroscope)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Gyroscope get axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseGyroscope class.
|
||||
* @return The number of axes of the BaseGyroscope
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define gyroscopeGetAxesNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @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 gyroscopeReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(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) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Gyroscope bias sampling procedure.
|
||||
* @note During this procedure gyroscope must be kept hold in the rest
|
||||
* position. Sampled bias will be automatically removed after
|
||||
* calling this 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 gyroscopeSampleBias(ip) \
|
||||
(ip)->vmt->sample_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates gyroscope bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the gyroscope axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseGyroscope class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define gyroscopeSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset gyroscope bias data restoring it to zero.
|
||||
*
|
||||
* @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 gyroscopeResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates gyroscope sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the gyroscope axes number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseGyroscope class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define gyroscopeSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset gyroscope sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @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 gyroscopeResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_GYROSCOPE_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_hygrometer.h
|
||||
* @brief Generic hygrometer interface header.
|
||||
*
|
||||
* @addtogroup EX_HYGROMETER
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_HYGROMETER_H
|
||||
#define EX_HYGROMETER_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseHygrometer specific methods.
|
||||
*/
|
||||
#define _base_hygrometer_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseHygrometer specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_hygrometer_methods \
|
||||
_base_sensor_methods \
|
||||
_base_hygrometer_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseHygrometer virtual methods table.
|
||||
*/
|
||||
struct BaseHygrometerVMT {
|
||||
_base_hygrometer_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseHygrometer specific data.
|
||||
*/
|
||||
#define _base_hygrometer_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base hygrometer class.
|
||||
* @details This class represents a generic hygrometer.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseHygrometerVMT *vmt;
|
||||
_base_hygrometer_data
|
||||
} BaseHygrometer;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Macro Functions (BaseHygrometer)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Hygrometer get channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer class.
|
||||
* @return The number of channels of the BaseHygrometer
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define hygrometerGetChannelsNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @brief Hygrometer read raw data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer 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 hygrometerReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Hygrometer read cooked data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer 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 hygrometerReadCooked(ip, dp) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates hygrometer bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the hygrometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define hygrometerSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset hygrometer bias data restoring it to zero.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define hygrometerResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates hygrometer sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the hygrometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define hygrometerSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset hygrometer sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseHygrometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define hygrometerResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_HYGROMETER_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_rangefinder.h
|
||||
* @brief Generic rangefinder interface header.
|
||||
*
|
||||
* @addtogroup EX_RANGEFINDER
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_RANGEFINDER_H
|
||||
#define EX_RANGEFINDER_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseRangeFinder specific methods.
|
||||
*/
|
||||
#define _base_rangefinder_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseRangeFinder specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_rangefinder_methods \
|
||||
_base_sensor_methods \
|
||||
_base_rangefinder_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseRangeFinder virtual methods table.
|
||||
*/
|
||||
struct BaseRangeFinderVMT {
|
||||
_base_rangefinder_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseRangeFinder specific data.
|
||||
*/
|
||||
#define _base_rangefinder_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base rangefinder class.
|
||||
* @details This class represents a generic rangefinder.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseRangeFinderVMT *vmt;
|
||||
_base_rangefinder_data
|
||||
} BaseRangeFinder;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Macro Functions (BaseRangeFinder)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief RangeFinder get channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder class.
|
||||
* @return The number of channels of the BaseRangeFinder
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define rangefinderGetChannelsNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @brief RangeFinder read raw data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder 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 rangefinderReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief RangeFinder read cooked data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder 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 rangefinderReadCooked(ip, dp) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates rangefinder bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the rangefinder channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define rangefinderSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset rangefinder bias data restoring it to zero.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define rangefinderResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates rangefinder sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the rangefinder channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define rangefinderSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset rangefinder sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseRangeFinder class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define rangefinderResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_RANGEFINDER_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_sensors.h
|
||||
* @brief Generic sensors interface header.
|
||||
*
|
||||
* @addtogroup EX_SENSORS
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_SENSORS_H
|
||||
#define EX_SENSORS_H
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseSensor specific methods.
|
||||
*/
|
||||
#define _base_sensor_methods_alone \
|
||||
/* Get number of channels.*/ \
|
||||
size_t (*get_channels_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 BaseSensor specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_sensor_methods \
|
||||
_base_object_methods \
|
||||
_base_sensor_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseSensor virtual methods table.
|
||||
*/
|
||||
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
|
||||
_base_object_data \
|
||||
|
||||
/**
|
||||
* @extends BaseObject
|
||||
*
|
||||
* @brief Base stream class.
|
||||
* @details This class represents a generic blocking unbuffered sequential
|
||||
* data stream.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseSensorVMT *vmt;
|
||||
_base_sensor_data
|
||||
} BaseSensor;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Macro Functions (BaseSensor)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Sensors get channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseSensor or derived class.
|
||||
* @return The number of channels of the BaseSensor
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define sensorGetChannelNumber(ip) (ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @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 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. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_SENSORS_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Rocco Marco Guglielmi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ex_thermometer.h
|
||||
* @brief Generic thermometer interface header.
|
||||
*
|
||||
* @addtogroup EX_THERMOMETER
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef EX_THERMOMETER_H
|
||||
#define EX_THERMOMETER_H
|
||||
|
||||
#include "ex_sensors.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief BaseThermometer specific methods.
|
||||
*/
|
||||
#define _base_thermometer_methods_alone \
|
||||
/* Invoke the set bias procedure.*/ \
|
||||
msg_t (*set_bias)(void *instance, float biases[]); \
|
||||
/* Remove bias stored data.*/ \
|
||||
msg_t (*reset_bias)(void *instance); \
|
||||
/* Invoke the set sensitivity procedure.*/ \
|
||||
msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
|
||||
/* Restore sensitivity stored data to default.*/ \
|
||||
msg_t (*reset_sensitivity)(void *instance);
|
||||
|
||||
|
||||
/**
|
||||
* @brief BaseThermometer specific methods with inherited ones.
|
||||
*/
|
||||
#define _base_thermometer_methods \
|
||||
_base_sensor_methods \
|
||||
_base_thermometer_methods_alone
|
||||
|
||||
/**
|
||||
* @brief @p BaseThermometer virtual methods table.
|
||||
*/
|
||||
struct BaseThermometerVMT {
|
||||
_base_thermometer_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief @p BaseThermometer specific data.
|
||||
*/
|
||||
#define _base_thermometer_data \
|
||||
_base_sensor_data
|
||||
|
||||
/**
|
||||
* @extends BaseSensor
|
||||
*
|
||||
* @brief Base thermometer class.
|
||||
* @details This class represents a generic thermometer.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct BaseThermometerVMT *vmt;
|
||||
_base_thermometer_data
|
||||
} BaseThermometer;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Macro Functions (BaseThermometer)
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Thermometer get channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer class.
|
||||
* @return The number of channels of the BaseThermometer
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define thermometerGetChannelsNumber(ip) \
|
||||
(ip)->vmt->get_channels_number(ip)
|
||||
|
||||
/**
|
||||
* @brief Thermometer read raw data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer 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 thermometerReadRaw(ip, dp) \
|
||||
(ip)->vmt->read_raw(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Thermometer read cooked data.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer 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 thermometerReadCooked(ip, dp) \
|
||||
(ip)->vmt->read_cooked(ip, dp)
|
||||
|
||||
/**
|
||||
* @brief Updates thermometer bias data from received buffer.
|
||||
* @note The bias buffer must have the same length of the
|
||||
* the thermometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer class.
|
||||
* @param[in] bp pointer to a buffer of bias values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define thermometerSetBias(ip, bp) \
|
||||
(ip)->vmt->set_bias(ip, bp)
|
||||
|
||||
/**
|
||||
* @brief Reset thermometer bias data restoring it to zero.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define thermometerResetBias(ip) \
|
||||
(ip)->vmt->reset_bias(ip)
|
||||
|
||||
/**
|
||||
* @brief Updates thermometer sensitivity data from received buffer.
|
||||
* @note The sensitivity buffer must have the same length of the
|
||||
* the thermometer channels number.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer class.
|
||||
* @param[in] sp pointer to a buffer of sensitivity values.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define thermometerSetSensitivity(ip, sp) \
|
||||
(ip)->vmt->set_sensitivity(ip, sp)
|
||||
|
||||
/**
|
||||
* @brief Reset thermometer sensitivity data restoring it to its typical
|
||||
* value.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseThermometer class.
|
||||
*
|
||||
* @return The operation status.
|
||||
* @retval MSG_OK if the function succeeded.
|
||||
* @retval MSG_RESET if one or more errors occurred.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define thermometerResetSensitivity(ip) \
|
||||
(ip)->vmt->reset_sensitivity(ip)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EX_THERMOMETER_H */
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue