I am working on a peripheral abstraction layer named EX. It is possible to find the current code on the trunk (even if it is at a very early stage).
I am concentrating in these days on MEMS and I had an interesting conversation with korken. I have some old code for more than a MEMS and I will gradually merge it on trunk. Before to do this I would like to improve interfaces making them suitable for most common uses like sensor fusion and estimation problems.
I hope to trig a discussion on certain API related to calibration of sensor data. Currently, I am working on gyroscope... a full calibration requires the measurement of 3 bias values and 3 sensitivity values (one for each axis). While bias can be acquired keeping sensor hold and acquiring some raw data, sensitivity requires a much more complex procedure which involves an external instrument and this means it could not be retrieved in a automatic way. My purpose to solve this problems is an API like this:
Code: Select all
/**
* @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 BaseSensor
*
* @api
*/
#define gyroscopeGetAxesNumber(ip) \
(ip)->vmt_basegyroscope->get_axes_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_basegyroscope->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_basegyroscope->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_basegyroscope->sample_bias(ip)
/**
* @brief Gyroscope setting bias procedure.
* @note bp must be a pointer to a buffer having 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_basegyroscope->set_bias(ip,bp)
/**
* @brief Reset 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_basegyroscope->reset_bias(ip)
/**
* @brief Gyroscope setting sensitivity procedure.
* @note sp must be a pointer to a buffer having 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_basegyroscope->set_sensitivity(ip,sp)
/**
* @brief Reset sensitivity data restoring it to 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_basegyroscope->reset_sensitivity(ip)
/** @} */
After that remains the temperature compensation. I think this could not be defined on interface level because I don't know if every Gyroscope has the capability to detect temperature. Nonetheless it is possible ad an API at device level something like
Code: Select all
msg_t l3gd20EnableTempCompens(L3GD20Driver* devp);
msg_t l3gd20DisableTempCompens(L3GD20Driver* devp);
Any feedback, suggestion, tip?
Ciao,
RM