Thundersoft
/
FRDM_FXS_MULTI_B_for_TT_Mxx
Create a project for TT_Mxx.
FRDM_FXS_MULTI_B/MotionSensor.h@0:369a1b265ddb, 2019-03-21 (annotated)
- Committer:
- ThunderSoft
- Date:
- Thu Mar 21 09:03:32 2019 +0000
- Revision:
- 0:369a1b265ddb
Add code for FRDM_FXS_MULTI_B
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:369a1b265ddb | 1 | /* MotionSensor Base Class |
ThunderSoft | 0:369a1b265ddb | 2 | * Copyright (c) 2014-2015 ARM Limited |
ThunderSoft | 0:369a1b265ddb | 3 | * |
ThunderSoft | 0:369a1b265ddb | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ThunderSoft | 0:369a1b265ddb | 5 | * you may not use this file except in compliance with the License. |
ThunderSoft | 0:369a1b265ddb | 6 | * You may obtain a copy of the License at |
ThunderSoft | 0:369a1b265ddb | 7 | * |
ThunderSoft | 0:369a1b265ddb | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ThunderSoft | 0:369a1b265ddb | 9 | * |
ThunderSoft | 0:369a1b265ddb | 10 | * Unless required by applicable law or agreed to in writing, software |
ThunderSoft | 0:369a1b265ddb | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
ThunderSoft | 0:369a1b265ddb | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ThunderSoft | 0:369a1b265ddb | 13 | * See the License for the specific language governing permissions and |
ThunderSoft | 0:369a1b265ddb | 14 | * limitations under the License. |
ThunderSoft | 0:369a1b265ddb | 15 | */ |
ThunderSoft | 0:369a1b265ddb | 16 | |
ThunderSoft | 0:369a1b265ddb | 17 | #ifndef MOTIONSENSOR_H |
ThunderSoft | 0:369a1b265ddb | 18 | #define MOTIONSENSOR_H |
ThunderSoft | 0:369a1b265ddb | 19 | |
ThunderSoft | 0:369a1b265ddb | 20 | #include "stdint.h" |
ThunderSoft | 0:369a1b265ddb | 21 | |
ThunderSoft | 0:369a1b265ddb | 22 | /** motion_data_counts_t struct |
ThunderSoft | 0:369a1b265ddb | 23 | */ |
ThunderSoft | 0:369a1b265ddb | 24 | typedef struct { |
ThunderSoft | 0:369a1b265ddb | 25 | int16_t x; /*!< x-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 26 | int16_t y; /*!< y-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 27 | int16_t z; /*!< z-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 28 | } motion_data_counts_t; |
ThunderSoft | 0:369a1b265ddb | 29 | |
ThunderSoft | 0:369a1b265ddb | 30 | /** motion_data_units_t struct |
ThunderSoft | 0:369a1b265ddb | 31 | */ |
ThunderSoft | 0:369a1b265ddb | 32 | typedef struct { |
ThunderSoft | 0:369a1b265ddb | 33 | float x; /*!< x-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 34 | float y; /*!< y-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 35 | float z; /*!< z-axis counts */ |
ThunderSoft | 0:369a1b265ddb | 36 | } motion_data_units_t; |
ThunderSoft | 0:369a1b265ddb | 37 | |
ThunderSoft | 0:369a1b265ddb | 38 | typedef motion_data_units_t MotionSensorDataUnits; |
ThunderSoft | 0:369a1b265ddb | 39 | typedef motion_data_counts_t MotionSensorDataCounts; |
ThunderSoft | 0:369a1b265ddb | 40 | /** Motion Sensor Base Class |
ThunderSoft | 0:369a1b265ddb | 41 | Useful for accessing data in a common way |
ThunderSoft | 0:369a1b265ddb | 42 | */ |
ThunderSoft | 0:369a1b265ddb | 43 | class MotionSensor |
ThunderSoft | 0:369a1b265ddb | 44 | { |
ThunderSoft | 0:369a1b265ddb | 45 | //public: |
ThunderSoft | 0:369a1b265ddb | 46 | |
ThunderSoft | 0:369a1b265ddb | 47 | // /** Enable the sensor for operation |
ThunderSoft | 0:369a1b265ddb | 48 | // */ |
ThunderSoft | 0:369a1b265ddb | 49 | // virtual void enable(void) const = 0; |
ThunderSoft | 0:369a1b265ddb | 50 | |
ThunderSoft | 0:369a1b265ddb | 51 | // /** disable the sensors operation |
ThunderSoft | 0:369a1b265ddb | 52 | // */ |
ThunderSoft | 0:369a1b265ddb | 53 | // virtual void disable(void) const = 0; |
ThunderSoft | 0:369a1b265ddb | 54 | |
ThunderSoft | 0:369a1b265ddb | 55 | // /** Set the sensor sample rate |
ThunderSoft | 0:369a1b265ddb | 56 | // @param frequency The desires sample frequency |
ThunderSoft | 0:369a1b265ddb | 57 | // @return The amount of error in Hz between desired and actual frequency |
ThunderSoft | 0:369a1b265ddb | 58 | // */ |
ThunderSoft | 0:369a1b265ddb | 59 | // virtual uint32_t sampleRate(uint32_t frequency) const = 0; |
ThunderSoft | 0:369a1b265ddb | 60 | |
ThunderSoft | 0:369a1b265ddb | 61 | // /** Tells of new data is ready |
ThunderSoft | 0:369a1b265ddb | 62 | // @return The amount of data samples ready to be read from a device |
ThunderSoft | 0:369a1b265ddb | 63 | // */ |
ThunderSoft | 0:369a1b265ddb | 64 | // virtual uint32_t dataReady(void) const = 0; |
ThunderSoft | 0:369a1b265ddb | 65 | |
ThunderSoft | 0:369a1b265ddb | 66 | // /** Get the x data in counts |
ThunderSoft | 0:369a1b265ddb | 67 | // @param x A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 68 | // @return The x data in counts |
ThunderSoft | 0:369a1b265ddb | 69 | // */ |
ThunderSoft | 0:369a1b265ddb | 70 | // virtual int16_t getX(int16_t &x) const = 0; |
ThunderSoft | 0:369a1b265ddb | 71 | |
ThunderSoft | 0:369a1b265ddb | 72 | // /** Get the y data in counts |
ThunderSoft | 0:369a1b265ddb | 73 | // @param y A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 74 | // @return The y data in counts |
ThunderSoft | 0:369a1b265ddb | 75 | // */ |
ThunderSoft | 0:369a1b265ddb | 76 | // virtual int16_t getY(int16_t &y) const = 0; |
ThunderSoft | 0:369a1b265ddb | 77 | |
ThunderSoft | 0:369a1b265ddb | 78 | // * Get the z data in counts |
ThunderSoft | 0:369a1b265ddb | 79 | // @param z A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 80 | // @return The z data in counts |
ThunderSoft | 0:369a1b265ddb | 81 | |
ThunderSoft | 0:369a1b265ddb | 82 | // virtual int16_t getZ(int16_t &z) const = 0; |
ThunderSoft | 0:369a1b265ddb | 83 | |
ThunderSoft | 0:369a1b265ddb | 84 | // /** Get the x data in units |
ThunderSoft | 0:369a1b265ddb | 85 | // @param x A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 86 | // @return The x data in units |
ThunderSoft | 0:369a1b265ddb | 87 | // */ |
ThunderSoft | 0:369a1b265ddb | 88 | // virtual float getX(float &x) const = 0; |
ThunderSoft | 0:369a1b265ddb | 89 | |
ThunderSoft | 0:369a1b265ddb | 90 | // /** Get the y data in units |
ThunderSoft | 0:369a1b265ddb | 91 | // @param y A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 92 | // @return The y data in units |
ThunderSoft | 0:369a1b265ddb | 93 | // */ |
ThunderSoft | 0:369a1b265ddb | 94 | // virtual float getY(float &y) const = 0; |
ThunderSoft | 0:369a1b265ddb | 95 | |
ThunderSoft | 0:369a1b265ddb | 96 | // /** Get the z data in units |
ThunderSoft | 0:369a1b265ddb | 97 | // @param z A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 98 | // @return The z data in units |
ThunderSoft | 0:369a1b265ddb | 99 | // */ |
ThunderSoft | 0:369a1b265ddb | 100 | // virtual float getZ(float &z) const = 0; |
ThunderSoft | 0:369a1b265ddb | 101 | |
ThunderSoft | 0:369a1b265ddb | 102 | // /** Get the x,y,z data in counts |
ThunderSoft | 0:369a1b265ddb | 103 | // @param xyz A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 104 | // */ |
ThunderSoft | 0:369a1b265ddb | 105 | // virtual void getAxis(motion_data_counts_t &xyz) const = 0; |
ThunderSoft | 0:369a1b265ddb | 106 | |
ThunderSoft | 0:369a1b265ddb | 107 | // /** Get the x,y,z data in units |
ThunderSoft | 0:369a1b265ddb | 108 | // @param xyz A referene to the variable to put the data in, 0 denotes not used |
ThunderSoft | 0:369a1b265ddb | 109 | // */ |
ThunderSoft | 0:369a1b265ddb | 110 | // virtual void getAxis(motion_data_units_t &xyz) const = 0; |
ThunderSoft | 0:369a1b265ddb | 111 | }; |
ThunderSoft | 0:369a1b265ddb | 112 | |
ThunderSoft | 0:369a1b265ddb | 113 | #endif |
ThunderSoft | 0:369a1b265ddb | 114 |