Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Motor_XYZ_UI_SPI_I2C_5mag by
XYZ_sensor_Platform/ST_INTERFACES/Sensors/MotionSensor.h@20:ba6de7e5240c, 2018-08-13 (annotated)
- Committer:
- hober
- Date:
- Mon Aug 13 01:49:53 2018 +0000
- Branch:
- envelope
- Revision:
- 20:ba6de7e5240c
- Parent:
- XYZ_sensor_Platform/AltIMU_10_v5/ST_INTERFACES/Sensors/MotionSensor.h@18:dce64bdc6ca3
2018/08/13 doc.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hober | 18:dce64bdc6ca3 | 1 | /** |
| hober | 18:dce64bdc6ca3 | 2 | ****************************************************************************** |
| hober | 18:dce64bdc6ca3 | 3 | * @file MotionSensor.h |
| hober | 18:dce64bdc6ca3 | 4 | * @author AST / EST |
| hober | 18:dce64bdc6ca3 | 5 | * @version V0.0.1 |
| hober | 18:dce64bdc6ca3 | 6 | * @date 13-April-2015 |
| hober | 18:dce64bdc6ca3 | 7 | * @brief This file contains the abstract class describing in general |
| hober | 18:dce64bdc6ca3 | 8 | * the interfaces of an accelerometer |
| hober | 18:dce64bdc6ca3 | 9 | ****************************************************************************** |
| hober | 18:dce64bdc6ca3 | 10 | * @attention |
| hober | 18:dce64bdc6ca3 | 11 | * |
| hober | 18:dce64bdc6ca3 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| hober | 18:dce64bdc6ca3 | 13 | * |
| hober | 18:dce64bdc6ca3 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
| hober | 18:dce64bdc6ca3 | 15 | * are permitted provided that the following conditions are met: |
| hober | 18:dce64bdc6ca3 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
| hober | 18:dce64bdc6ca3 | 17 | * this list of conditions and the following disclaimer. |
| hober | 18:dce64bdc6ca3 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| hober | 18:dce64bdc6ca3 | 19 | * this list of conditions and the following disclaimer in the documentation |
| hober | 18:dce64bdc6ca3 | 20 | * and/or other materials provided with the distribution. |
| hober | 18:dce64bdc6ca3 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| hober | 18:dce64bdc6ca3 | 22 | * may be used to endorse or promote products derived from this software |
| hober | 18:dce64bdc6ca3 | 23 | * without specific prior written permission. |
| hober | 18:dce64bdc6ca3 | 24 | * |
| hober | 18:dce64bdc6ca3 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| hober | 18:dce64bdc6ca3 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| hober | 18:dce64bdc6ca3 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| hober | 18:dce64bdc6ca3 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| hober | 18:dce64bdc6ca3 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| hober | 18:dce64bdc6ca3 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| hober | 18:dce64bdc6ca3 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| hober | 18:dce64bdc6ca3 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| hober | 18:dce64bdc6ca3 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| hober | 18:dce64bdc6ca3 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| hober | 18:dce64bdc6ca3 | 35 | * |
| hober | 18:dce64bdc6ca3 | 36 | ****************************************************************************** |
| hober | 18:dce64bdc6ca3 | 37 | */ |
| hober | 18:dce64bdc6ca3 | 38 | |
| hober | 18:dce64bdc6ca3 | 39 | |
| hober | 18:dce64bdc6ca3 | 40 | /* Define to prevent from recursive inclusion --------------------------------*/ |
| hober | 18:dce64bdc6ca3 | 41 | |
| hober | 18:dce64bdc6ca3 | 42 | #ifndef __MOTION_SENSOR_CLASS_H |
| hober | 18:dce64bdc6ca3 | 43 | #define __MOTION_SENSOR_CLASS_H |
| hober | 18:dce64bdc6ca3 | 44 | |
| hober | 18:dce64bdc6ca3 | 45 | |
| hober | 18:dce64bdc6ca3 | 46 | /* Includes ------------------------------------------------------------------*/ |
| hober | 18:dce64bdc6ca3 | 47 | |
| hober | 18:dce64bdc6ca3 | 48 | #include <Component.h> |
| hober | 18:dce64bdc6ca3 | 49 | |
| hober | 18:dce64bdc6ca3 | 50 | |
| hober | 18:dce64bdc6ca3 | 51 | /* Classes ------------------------------------------------------------------*/ |
| hober | 18:dce64bdc6ca3 | 52 | |
| hober | 18:dce64bdc6ca3 | 53 | /** |
| hober | 18:dce64bdc6ca3 | 54 | * An abstract class for an Accelerometer |
| hober | 18:dce64bdc6ca3 | 55 | */ |
| hober | 18:dce64bdc6ca3 | 56 | class MotionSensor : public Component { |
| hober | 18:dce64bdc6ca3 | 57 | public: |
| hober | 18:dce64bdc6ca3 | 58 | |
| hober | 18:dce64bdc6ca3 | 59 | /** |
| hober | 18:dce64bdc6ca3 | 60 | * @brief Get current accelerometer linear acceleration X/Y/Z-axes values |
| hober | 18:dce64bdc6ca3 | 61 | * in standard data units [mg] |
| hober | 18:dce64bdc6ca3 | 62 | * @param[out] p_data Pointer to where to store linear accelerations to. |
| hober | 18:dce64bdc6ca3 | 63 | * p_data must point to an array of (at least) three elements, where: |
| hober | 18:dce64bdc6ca3 | 64 | * p_data[0] corresponds to X-axis, |
| hober | 18:dce64bdc6ca3 | 65 | * p_data[1] corresponds to Y-axis, and |
| hober | 18:dce64bdc6ca3 | 66 | * p_data[2] corresponds to Z-axis. |
| hober | 18:dce64bdc6ca3 | 67 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 68 | */ |
| hober | 18:dce64bdc6ca3 | 69 | virtual int get_x_axes(int32_t *p_data) = 0; |
| hober | 18:dce64bdc6ca3 | 70 | |
| hober | 18:dce64bdc6ca3 | 71 | /** |
| hober | 18:dce64bdc6ca3 | 72 | * @brief Get current accelerometer raw data X/Y/Z-axes values |
| hober | 18:dce64bdc6ca3 | 73 | * in device sepcific LSB units |
| hober | 18:dce64bdc6ca3 | 74 | * @param[out] p_data Pointer to where to store accelerometer raw data to. |
| hober | 18:dce64bdc6ca3 | 75 | * p_data must point to an array of (at least) three elements, where: |
| hober | 18:dce64bdc6ca3 | 76 | * p_data[0] corresponds to X-axis, |
| hober | 18:dce64bdc6ca3 | 77 | * p_data[1] corresponds to Y-axis, and |
| hober | 18:dce64bdc6ca3 | 78 | * p_data[2] corresponds to Z-axis. |
| hober | 18:dce64bdc6ca3 | 79 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 80 | */ |
| hober | 18:dce64bdc6ca3 | 81 | virtual int get_x_axes_raw(int16_t *p_data) = 0; |
| hober | 18:dce64bdc6ca3 | 82 | |
| hober | 18:dce64bdc6ca3 | 83 | /** |
| hober | 18:dce64bdc6ca3 | 84 | * @brief Get accelerometer's current sensitivity [mg/LSB] |
| hober | 18:dce64bdc6ca3 | 85 | * @param[out] pf_data Pointer to where the accelerometer's sensitivity is stored to |
| hober | 18:dce64bdc6ca3 | 86 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 87 | */ |
| hober | 18:dce64bdc6ca3 | 88 | virtual int get_x_sensitivity(float *pf_data) = 0; |
| hober | 18:dce64bdc6ca3 | 89 | |
| hober | 18:dce64bdc6ca3 | 90 | /** |
| hober | 18:dce64bdc6ca3 | 91 | * @brief Get accelerometer's current output data rate [Hz] |
| hober | 18:dce64bdc6ca3 | 92 | * @param[out] pf_data Pointer to where the accelerometer output data rate is stored to |
| hober | 18:dce64bdc6ca3 | 93 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 94 | */ |
| hober | 18:dce64bdc6ca3 | 95 | virtual int get_x_odr(float *pf_data) = 0; |
| hober | 18:dce64bdc6ca3 | 96 | |
| hober | 18:dce64bdc6ca3 | 97 | /** |
| hober | 18:dce64bdc6ca3 | 98 | * @brief Set accelerometer's output data rate |
| hober | 18:dce64bdc6ca3 | 99 | * @param[in] odr New value for accelerometer's output data rate in [Hz] |
| hober | 18:dce64bdc6ca3 | 100 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 101 | */ |
| hober | 18:dce64bdc6ca3 | 102 | virtual int set_x_odr(float odr) = 0; |
| hober | 18:dce64bdc6ca3 | 103 | |
| hober | 18:dce64bdc6ca3 | 104 | /** |
| hober | 18:dce64bdc6ca3 | 105 | * @brief Get accelerometer's full scale value |
| hober | 18:dce64bdc6ca3 | 106 | * i.e.\ min/max measurable value [g] |
| hober | 18:dce64bdc6ca3 | 107 | * @param[out] pf_data Pointer to where the accelerometer full scale value is stored to |
| hober | 18:dce64bdc6ca3 | 108 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 109 | */ |
| hober | 18:dce64bdc6ca3 | 110 | virtual int get_x_fs(float *pf_data) = 0; |
| hober | 18:dce64bdc6ca3 | 111 | |
| hober | 18:dce64bdc6ca3 | 112 | /** |
| hober | 18:dce64bdc6ca3 | 113 | * @brief Set accelerometer's full scale value |
| hober | 18:dce64bdc6ca3 | 114 | * i.e.\ min/max measurable value |
| hober | 18:dce64bdc6ca3 | 115 | * @param[in] fs New full scale value for accelerometer in [g] |
| hober | 18:dce64bdc6ca3 | 116 | * @return 0 in case of success, an error code otherwise |
| hober | 18:dce64bdc6ca3 | 117 | */ |
| hober | 18:dce64bdc6ca3 | 118 | virtual int set_x_fs(float fs) = 0; |
| hober | 18:dce64bdc6ca3 | 119 | |
| hober | 18:dce64bdc6ca3 | 120 | /** |
| hober | 18:dce64bdc6ca3 | 121 | * @brief Destructor. |
| hober | 18:dce64bdc6ca3 | 122 | */ |
| hober | 18:dce64bdc6ca3 | 123 | virtual ~MotionSensor() {}; |
| hober | 18:dce64bdc6ca3 | 124 | }; |
| hober | 18:dce64bdc6ca3 | 125 | |
| hober | 18:dce64bdc6ca3 | 126 | #endif /* __MOTION_SENSOR_CLASS_H */ |
