carlosperate . / FXOS8700Q

Dependents:   TALab2B_Part2_ECE595 TALab3C_i2c_acc Project1 FinalProject ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MbedComponentMotionSensor.h Source File

MbedComponentMotionSensor.h

00001 /* MotionSensor Base Class
00002  * Copyright (c) 2014-2015 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef MBED_COMPONENT_MOTIONSENSOR_H
00018 #define MBED_COMPONENT_MOTIONSENSOR_H
00019 
00020 #include "stdint.h"
00021 
00022 /** motion_data_counts_t struct
00023  */
00024 typedef struct {
00025     int16_t x ;      /*!< x-axis counts */
00026     int16_t y ;      /*!< y-axis counts */
00027     int16_t z ;      /*!< z-axis counts */
00028 } motion_data_counts_t;
00029 
00030 /** motion_data_units_t struct
00031  */
00032 typedef struct {
00033     float x ;        /*!< x-axis counts */
00034     float y ;        /*!< y-axis counts */
00035     float z ;        /*!< z-axis counts */
00036 } motion_data_units_t;
00037 
00038 
00039 namespace MbedComponent {
00040 
00041 /** Motion Sensor Base Class
00042     Useful for accessing data in a common way
00043  */
00044 class MotionSensor
00045 {
00046 public:
00047 
00048     /** Enable the sensor for operation
00049      */
00050     virtual void enable(void) const = 0;
00051 
00052     /** disable the sensors operation
00053      */
00054     virtual void disable(void) const = 0;
00055 
00056     /** Set the sensor sample rate
00057         @param frequency The desires sample frequency
00058         @return The amount of error in Hz between desired and actual frequency
00059      */
00060     virtual uint32_t sampleRate(uint32_t frequency) const = 0;
00061 
00062     /** Tells of new data is ready
00063         @return The amount of data samples ready to be read from a device
00064      */
00065     virtual uint32_t dataReady(void) const = 0;
00066 
00067     /** Get the x data in counts
00068         @param x A referene to the variable to put the data in, 0 denotes not used
00069         @return The x data in counts
00070      */
00071     virtual int16_t getX(int16_t &x) const = 0;
00072 
00073     /** Get the y data in counts
00074         @param y A referene to the variable to put the data in, 0 denotes not used
00075         @return The y data in counts
00076      */
00077     virtual int16_t getY(int16_t &y) const = 0;
00078 
00079     /** Get the z data in counts
00080         @param z A referene to the variable to put the data in, 0 denotes not used
00081         @return The z data in counts
00082      */
00083     virtual int16_t getZ(int16_t &z) const = 0;
00084 
00085     /** Get the x data in units
00086         @param x A referene to the variable to put the data in, 0 denotes not used
00087         @return The x data in units
00088      */
00089     virtual float getX(float &x) const = 0;
00090 
00091     /** Get the y data in units
00092         @param y A referene to the variable to put the data in, 0 denotes not used
00093         @return The y data in units
00094      */
00095     virtual float getY(float &y) const = 0;
00096 
00097     /** Get the z data in units
00098         @param z A referene to the variable to put the data in, 0 denotes not used
00099         @return The z data in units
00100      */
00101     virtual float getZ(float &z) const = 0;
00102 
00103     /** Get the x,y,z data in counts
00104         @param xyz A referene to the variable to put the data in, 0 denotes not used
00105      */
00106     virtual void getAxis(motion_data_counts_t &xyz) const = 0;
00107 
00108     /** Get the x,y,z data in units
00109         @param xyz A referene to the variable to put the data in, 0 denotes not used
00110      */
00111     virtual void getAxis(motion_data_units_t &xyz) const = 0;
00112 };
00113 
00114 }    // End namespace
00115 
00116 #endif