aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/inv_mpu/mltypes.h
blob: a249f93be3eea9e1d5c42f806202bfb8323dd16a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
	$License:
	Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	$
 */

/**
 *  @defgroup MLERROR
 *  @brief  Definition of the error codes used within the MPL and
 *          returned to the user.
 *          Every function tries to return a meaningful error code basing
 *          on the occuring error condition. The error code is numeric.
 *
 *          The available error codes and their associated values are:
 *          - (0)               INV_SUCCESS
 *          - (32)              INV_ERROR
 *          - (22 / EINVAL)     INV_ERROR_INVALID_PARAMETER
 *          - (1  / EPERM)      INV_ERROR_FEATURE_NOT_ENABLED
 *          - (36)              INV_ERROR_FEATURE_NOT_IMPLEMENTED
 *          - (38)              INV_ERROR_DMP_NOT_STARTED
 *          - (39)              INV_ERROR_DMP_STARTED
 *          - (40)              INV_ERROR_NOT_OPENED
 *          - (41)              INV_ERROR_OPENED
 *          - (19 / ENODEV)     INV_ERROR_INVALID_MODULE
 *          - (12 / ENOMEM)     INV_ERROR_MEMORY_EXAUSTED
 *          - (44)              INV_ERROR_DIVIDE_BY_ZERO
 *          - (45)              INV_ERROR_ASSERTION_FAILURE
 *          - (46)              INV_ERROR_FILE_OPEN
 *          - (47)              INV_ERROR_FILE_READ
 *          - (48)              INV_ERROR_FILE_WRITE
 *          - (49)              INV_ERROR_INVALID_CONFIGURATION
 *          - (52)              INV_ERROR_SERIAL_CLOSED
 *          - (53)              INV_ERROR_SERIAL_OPEN_ERROR
 *          - (54)              INV_ERROR_SERIAL_READ
 *          - (55)              INV_ERROR_SERIAL_WRITE
 *          - (56)              INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
 *          - (57)              INV_ERROR_SM_TRANSITION
 *          - (58)              INV_ERROR_SM_IMPROPER_STATE
 *          - (62)              INV_ERROR_FIFO_OVERFLOW
 *          - (63)              INV_ERROR_FIFO_FOOTER
 *          - (64)              INV_ERROR_FIFO_READ_COUNT
 *          - (65)              INV_ERROR_FIFO_READ_DATA
 *          - (72)              INV_ERROR_MEMORY_SET
 *          - (82)              INV_ERROR_LOG_MEMORY_ERROR
 *          - (83)              INV_ERROR_LOG_OUTPUT_ERROR
 *          - (92)              INV_ERROR_OS_BAD_PTR
 *          - (93)              INV_ERROR_OS_BAD_HANDLE
 *          - (94)              INV_ERROR_OS_CREATE_FAILED
 *          - (95)              INV_ERROR_OS_LOCK_FAILED
 *          - (102)             INV_ERROR_COMPASS_DATA_OVERFLOW
 *          - (103)             INV_ERROR_COMPASS_DATA_UNDERFLOW
 *          - (104)             INV_ERROR_COMPASS_DATA_NOT_READY
 *          - (105)             INV_ERROR_COMPASS_DATA_ERROR
 *          - (107)             INV_ERROR_CALIBRATION_LOAD
 *          - (108)             INV_ERROR_CALIBRATION_STORE
 *          - (109)             INV_ERROR_CALIBRATION_LEN
 *          - (110)             INV_ERROR_CALIBRATION_CHECKSUM
 *          - (111)             INV_ERROR_ACCEL_DATA_OVERFLOW
 *          - (112)             INV_ERROR_ACCEL_DATA_UNDERFLOW
 *          - (113)             INV_ERROR_ACCEL_DATA_NOT_READY
 *          - (114)             INV_ERROR_ACCEL_DATA_ERROR
 *
 *          The available warning codes and their associated values are:
 *          - (115)             INV_WARNING_MOTION_RACE
 *          - (116)             INV_WARNING_QUAT_TRASHED
 *
 *  @{
 *      @file mltypes.h
 *  @}
 */

#ifndef MLTYPES_H
#define MLTYPES_H

#include <linux/types.h>
#include <asm-generic/errno-base.h>




/*---------------------------
 *    ML Defines
 *--------------------------*/

#ifndef NULL
#define NULL 0
#endif

/* - ML Errors. - */
#define ERROR_NAME(x)   (#x)
#define ERROR_CHECK_FIRST(first, x) \
	{ if (INV_SUCCESS == first) first = x; }

#define INV_SUCCESS                       (0)
/* Generic Error code.  Proprietary Error Codes only */
#define INV_ERROR_BASE                    (0x20)
#define INV_ERROR                         (INV_ERROR_BASE)

/* Compatibility and other generic error codes */
#define INV_ERROR_INVALID_PARAMETER             (EINVAL)
#define INV_ERROR_FEATURE_NOT_ENABLED           (EPERM)
#define INV_ERROR_FEATURE_NOT_IMPLEMENTED       (INV_ERROR_BASE + 4)
#define INV_ERROR_DMP_NOT_STARTED               (INV_ERROR_BASE + 6)
#define INV_ERROR_DMP_STARTED                   (INV_ERROR_BASE + 7)
#define INV_ERROR_NOT_OPENED                    (INV_ERROR_BASE + 8)
#define INV_ERROR_OPENED                        (INV_ERROR_BASE + 9)
#define INV_ERROR_INVALID_MODULE                (ENODEV)
#define INV_ERROR_MEMORY_EXAUSTED               (ENOMEM)
#define INV_ERROR_DIVIDE_BY_ZERO                (INV_ERROR_BASE + 12)
#define INV_ERROR_ASSERTION_FAILURE             (INV_ERROR_BASE + 13)
#define INV_ERROR_FILE_OPEN                     (INV_ERROR_BASE + 14)
#define INV_ERROR_FILE_READ                     (INV_ERROR_BASE + 15)
#define INV_ERROR_FILE_WRITE                    (INV_ERROR_BASE + 16)
#define INV_ERROR_INVALID_CONFIGURATION         (INV_ERROR_BASE + 17)

/* Serial Communication */
#define INV_ERROR_SERIAL_CLOSED                 (INV_ERROR_BASE + 20)
#define INV_ERROR_SERIAL_OPEN_ERROR             (INV_ERROR_BASE + 21)
#define INV_ERROR_SERIAL_READ                   (INV_ERROR_BASE + 22)
#define INV_ERROR_SERIAL_WRITE                  (INV_ERROR_BASE + 23)
#define INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  (INV_ERROR_BASE + 24)

/* SM = State Machine */
#define INV_ERROR_SM_TRANSITION                 (INV_ERROR_BASE + 25)
#define INV_ERROR_SM_IMPROPER_STATE             (INV_ERROR_BASE + 26)

/* Fifo */
#define INV_ERROR_FIFO_OVERFLOW                 (INV_ERROR_BASE + 30)
#define INV_ERROR_FIFO_FOOTER                   (INV_ERROR_BASE + 31)
#define INV_ERROR_FIFO_READ_COUNT               (INV_ERROR_BASE + 32)
#define INV_ERROR_FIFO_READ_DATA                (INV_ERROR_BASE + 33)

/* Memory & Registers, Set & Get */
#define INV_ERROR_MEMORY_SET                    (INV_ERROR_BASE + 40)

#define INV_ERROR_LOG_MEMORY_ERROR              (INV_ERROR_BASE + 50)
#define INV_ERROR_LOG_OUTPUT_ERROR              (INV_ERROR_BASE + 51)

/* OS interface errors */
#define INV_ERROR_OS_BAD_PTR                    (INV_ERROR_BASE + 60)
#define INV_ERROR_OS_BAD_HANDLE                 (INV_ERROR_BASE + 61)
#define INV_ERROR_OS_CREATE_FAILED              (INV_ERROR_BASE + 62)
#define INV_ERROR_OS_LOCK_FAILED                (INV_ERROR_BASE + 63)

/* Compass errors */
#define INV_ERROR_COMPASS_DATA_OVERFLOW         (INV_ERROR_BASE + 70)
#define INV_ERROR_COMPASS_DATA_UNDERFLOW        (INV_ERROR_BASE + 71)
#define INV_ERROR_COMPASS_DATA_NOT_READY        (INV_ERROR_BASE + 72)
#define INV_ERROR_COMPASS_DATA_ERROR            (INV_ERROR_BASE + 73)

/* Load/Store calibration */
#define INV_ERROR_CALIBRATION_LOAD              (INV_ERROR_BASE + 75)
#define INV_ERROR_CALIBRATION_STORE             (INV_ERROR_BASE + 76)
#define INV_ERROR_CALIBRATION_LEN               (INV_ERROR_BASE + 77)
#define INV_ERROR_CALIBRATION_CHECKSUM          (INV_ERROR_BASE + 78)

/* Accel errors */
#define INV_ERROR_ACCEL_DATA_OVERFLOW           (INV_ERROR_BASE + 79)
#define INV_ERROR_ACCEL_DATA_UNDERFLOW          (INV_ERROR_BASE + 80)
#define INV_ERROR_ACCEL_DATA_NOT_READY          (INV_ERROR_BASE + 81)
#define INV_ERROR_ACCEL_DATA_ERROR              (INV_ERROR_BASE + 82)

/* No Motion Warning States */
#define INV_WARNING_MOTION_RACE                 (INV_ERROR_BASE + 83)
#define INV_WARNING_QUAT_TRASHED                (INV_ERROR_BASE + 84)
#define INV_WARNING_GYRO_MAG                    (INV_ERROR_BASE + 85)

#ifdef INV_USE_LEGACY_NAMES
#define ML_SUCCESS                        INV_SUCCESS
#define ML_ERROR                          INV_ERROR
#define ML_ERROR_INVALID_PARAMETER        INV_ERROR_INVALID_PARAMETER
#define ML_ERROR_FEATURE_NOT_ENABLED      INV_ERROR_FEATURE_NOT_ENABLED
#define ML_ERROR_FEATURE_NOT_IMPLEMENTED  INV_ERROR_FEATURE_NOT_IMPLEMENTED
#define ML_ERROR_DMP_NOT_STARTED          INV_ERROR_DMP_NOT_STARTED
#define ML_ERROR_DMP_STARTED              INV_ERROR_DMP_STARTED
#define ML_ERROR_NOT_OPENED               INV_ERROR_NOT_OPENED
#define ML_ERROR_OPENED                   INV_ERROR_OPENED
#define ML_ERROR_INVALID_MODULE           INV_ERROR_INVALID_MODULE
#define ML_ERROR_MEMORY_EXAUSTED          INV_ERROR_MEMORY_EXAUSTED
#define ML_ERROR_DIVIDE_BY_ZERO           INV_ERROR_DIVIDE_BY_ZERO
#define ML_ERROR_ASSERTION_FAILURE        INV_ERROR_ASSERTION_FAILURE
#define ML_ERROR_FILE_OPEN                INV_ERROR_FILE_OPEN
#define ML_ERROR_FILE_READ                INV_ERROR_FILE_READ
#define ML_ERROR_FILE_WRITE               INV_ERROR_FILE_WRITE
#define ML_ERROR_INVALID_CONFIGURATION    INV_ERROR_INVALID_CONFIGURATION
#define ML_ERROR_SERIAL_CLOSED            INV_ERROR_SERIAL_CLOSED
#define ML_ERROR_SERIAL_OPEN_ERROR        INV_ERROR_SERIAL_OPEN_ERROR
#define ML_ERROR_SERIAL_READ              INV_ERROR_SERIAL_READ
#define ML_ERROR_SERIAL_WRITE             INV_ERROR_SERIAL_WRITE
#define ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  \
	INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
#define ML_ERROR_SM_TRANSITION            INV_ERROR_SM_TRANSITION
#define ML_ERROR_SM_IMPROPER_STATE        INV_ERROR_SM_IMPROPER_STATE
#define ML_ERROR_FIFO_OVERFLOW            INV_ERROR_FIFO_OVERFLOW
#define ML_ERROR_FIFO_FOOTER              INV_ERROR_FIFO_FOOTER
#define ML_ERROR_FIFO_READ_COUNT          INV_ERROR_FIFO_READ_COUNT
#define ML_ERROR_FIFO_READ_DATA           INV_ERROR_FIFO_READ_DATA
#define ML_ERROR_MEMORY_SET               INV_ERROR_MEMORY_SET
#define ML_ERROR_LOG_MEMORY_ERROR         INV_ERROR_LOG_MEMORY_ERROR
#define ML_ERROR_LOG_OUTPUT_ERROR         INV_ERROR_LOG_OUTPUT_ERROR
#define ML_ERROR_OS_BAD_PTR               INV_ERROR_OS_BAD_PTR
#define ML_ERROR_OS_BAD_HANDLE            INV_ERROR_OS_BAD_HANDLE
#define ML_ERROR_OS_CREATE_FAILED         INV_ERROR_OS_CREATE_FAILED
#define ML_ERROR_OS_LOCK_FAILED           INV_ERROR_OS_LOCK_FAILED
#define ML_ERROR_COMPASS_DATA_OVERFLOW    INV_ERROR_COMPASS_DATA_OVERFLOW
#define ML_ERROR_COMPASS_DATA_UNDERFLOW   INV_ERROR_COMPASS_DATA_UNDERFLOW
#define ML_ERROR_COMPASS_DATA_NOT_READY   INV_ERROR_COMPASS_DATA_NOT_READY
#define ML_ERROR_COMPASS_DATA_ERROR       INV_ERROR_COMPASS_DATA_ERROR
#define ML_ERROR_CALIBRATION_LOAD         INV_ERROR_CALIBRATION_LOAD
#define ML_ERROR_CALIBRATION_STORE        INV_ERROR_CALIBRATION_STORE
#define ML_ERROR_CALIBRATION_LEN          INV_ERROR_CALIBRATION_LEN
#define ML_ERROR_CALIBRATION_CHECKSUM     INV_ERROR_CALIBRATION_CHECKSUM
#define ML_ERROR_ACCEL_DATA_OVERFLOW      INV_ERROR_ACCEL_DATA_OVERFLOW
#define ML_ERROR_ACCEL_DATA_UNDERFLOW     INV_ERROR_ACCEL_DATA_UNDERFLOW
#define ML_ERROR_ACCEL_DATA_NOT_READY     INV_ERROR_ACCEL_DATA_NOT_READY
#define ML_ERROR_ACCEL_DATA_ERROR         INV_ERROR_ACCEL_DATA_ERROR
#endif

/* For Linux coding compliance */

#endif				/* MLTYPES_H */