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