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