aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mpu3050/mltypes.h
blob: 5c1b684e5b5040553ab2e68308004e4530d280a1 (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
/*
 $License:
    Copyright (C) 2010 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  Motion Library - Error definitions.
 *          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)       ML_SUCCESS
 *          - (1)       ML_ERROR
 *          - (2)       ML_ERROR_INVALID_PARAMETER
 *          - (3)       ML_ERROR_FEATURE_NOT_ENABLED
 *          - (4)       ML_ERROR_FEATURE_NOT_IMPLEMENTED
 *          - (6)       ML_ERROR_DMP_NOT_STARTED
 *          - (7)       ML_ERROR_DMP_STARTED
 *          - (8)       ML_ERROR_NOT_OPENED
 *          - (9)       ML_ERROR_OPENED
 *          - (10)      ML_ERROR_INVALID_MODULE
 *          - (11)      ML_ERROR_MEMORY_EXAUSTED
 *          - (12)      ML_ERROR_DIVIDE_BY_ZERO
 *          - (13)      ML_ERROR_ASSERTION_FAILURE
 *          - (14)      ML_ERROR_FILE_OPEN
 *          - (15)      ML_ERROR_FILE_READ
 *          - (16)      ML_ERROR_FILE_WRITE
 *          - (20)      ML_ERROR_SERIAL_CLOSED
 *          - (21)      ML_ERROR_SERIAL_OPEN_ERROR
 *          - (22)      ML_ERROR_SERIAL_READ
 *          - (23)      ML_ERROR_SERIAL_WRITE
 *          - (24)      ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
 *          - (25)      ML_ERROR_SM_TRANSITION
 *          - (26)      ML_ERROR_SM_IMPROPER_STATE
 *          - (30)      ML_ERROR_FIFO_OVERFLOW
 *          - (31)      ML_ERROR_FIFO_FOOTER
 *          - (32)      ML_ERROR_FIFO_READ_COUNT
 *          - (33)      ML_ERROR_FIFO_READ_DATA
 *          - (40)      ML_ERROR_MEMORY_SET
 *          - (50)      ML_ERROR_LOG_MEMORY_ERROR
 *          - (51)      ML_ERROR_LOG_OUTPUT_ERROR
 *          - (60)      ML_ERROR_OS_BAD_PTR
 *          - (61)      ML_ERROR_OS_BAD_HANDLE
 *          - (62)      ML_ERROR_OS_CREATE_FAILED
 *          - (63)      ML_ERROR_OS_LOCK_FAILED
 *          - (70)      ML_ERROR_COMPASS_DATA_OVERFLOW
 *          - (71)      ML_ERROR_COMPASS_DATA_UNDERFLOW
 *          - (72)      ML_ERROR_COMPASS_DATA_NOT_READY
 *          - (73)      ML_ERROR_COMPASS_DATA_ERROR
 *          - (75)      ML_ERROR_CALIBRATION_LOAD
 *          - (76)      ML_ERROR_CALIBRATION_STORE
 *          - (77)      ML_ERROR_CALIBRATION_LEN
 *          - (78)      ML_ERROR_CALIBRATION_CHECKSUM
 *
 *  @{
 *      @file mltypes.h
 *  @}
 */

#ifndef MLTYPES_H
#define MLTYPES_H

#ifdef __KERNEL__
#include <linux/types.h>
#else
#include "stdint_invensense.h"
#endif
#include "log.h"

/*---------------------------
    ML Types
---------------------------*/

/**
 *  @struct tMLError mltypes.h "mltypes"
 *  @brief  The MPL Error Code return type.
 *
 *  @code
 *      typedef unsigned char tMLError;
 *  @endcode
 */
typedef unsigned char tMLError;

#if defined(LINUX) || defined(__KERNEL__)
typedef unsigned int HANDLE;
#endif

#ifdef __KERNEL__
typedef HANDLE FILE;
#endif

#ifndef __cplusplus
#ifndef __KERNEL__
typedef int_fast8_t bool;
#endif
#endif

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

#ifndef NULL
#define NULL 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

/* Dimension of an array */
#ifndef DIM
#define DIM(array) (sizeof(array)/sizeof((array)[0]))
#endif

/* - ML Errors. - */
#define ERROR_NAME(x)   (#x)
#define ERROR_CHECK(x)                                                  \
	{								\
		if (ML_SUCCESS != x) {					\
			MPL_LOGE("%s|%s|%d returning %d\n",		\
				__FILE__, __func__, __LINE__, x);	\
			return x;					\
		}							\
	}

#define ERROR_CHECK_FIRST(first, x)                                     \
	{ if (ML_SUCCESS == first) first = x; }

#define ML_SUCCESS                       (0)
/* Generic Error code.  Proprietary Error Codes only */
#define ML_ERROR                         (1)

/* Compatibility and other generic error codes */
#define ML_ERROR_INVALID_PARAMETER       (2)
#define ML_ERROR_FEATURE_NOT_ENABLED     (3)
#define ML_ERROR_FEATURE_NOT_IMPLEMENTED (4)
#define ML_ERROR_DMP_NOT_STARTED         (6)
#define ML_ERROR_DMP_STARTED             (7)
#define ML_ERROR_NOT_OPENED              (8)
#define ML_ERROR_OPENED                  (9)
#define ML_ERROR_INVALID_MODULE         (10)
#define ML_ERROR_MEMORY_EXAUSTED        (11)
#define ML_ERROR_DIVIDE_BY_ZERO         (12)
#define ML_ERROR_ASSERTION_FAILURE      (13)
#define ML_ERROR_FILE_OPEN              (14)
#define ML_ERROR_FILE_READ              (15)
#define ML_ERROR_FILE_WRITE             (16)
#define ML_ERROR_INVALID_CONFIGURATION  (17)

/* Serial Communication */
#define ML_ERROR_SERIAL_CLOSED          (20)
#define ML_ERROR_SERIAL_OPEN_ERROR      (21)
#define ML_ERROR_SERIAL_READ            (22)
#define ML_ERROR_SERIAL_WRITE           (23)
#define ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  (24)

/* SM = State Machine */
#define ML_ERROR_SM_TRANSITION          (25)
#define ML_ERROR_SM_IMPROPER_STATE      (26)

/* Fifo */
#define ML_ERROR_FIFO_OVERFLOW          (30)
#define ML_ERROR_FIFO_FOOTER            (31)
#define ML_ERROR_FIFO_READ_COUNT        (32)
#define ML_ERROR_FIFO_READ_DATA         (33)

/* Memory & Registers, Set & Get */
#define ML_ERROR_MEMORY_SET             (40)

#define ML_ERROR_LOG_MEMORY_ERROR       (50)
#define ML_ERROR_LOG_OUTPUT_ERROR       (51)

/* OS interface errors */
#define ML_ERROR_OS_BAD_PTR             (60)
#define ML_ERROR_OS_BAD_HANDLE          (61)
#define ML_ERROR_OS_CREATE_FAILED       (62)
#define ML_ERROR_OS_LOCK_FAILED         (63)

/* Compass errors */
#define ML_ERROR_COMPASS_DATA_OVERFLOW  (70)
#define ML_ERROR_COMPASS_DATA_UNDERFLOW (71)
#define ML_ERROR_COMPASS_DATA_NOT_READY (72)
#define ML_ERROR_COMPASS_DATA_ERROR     (73)

/* Load/Store calibration */
#define ML_ERROR_CALIBRATION_LOAD       (75)
#define ML_ERROR_CALIBRATION_STORE      (76)
#define ML_ERROR_CALIBRATION_LEN        (77)
#define ML_ERROR_CALIBRATION_CHECKSUM   (78)

/* Accel errors */
#define ML_ERROR_ACCEL_DATA_OVERFLOW    (79)
#define ML_ERROR_ACCEL_DATA_UNDERFLOW   (80)
#define ML_ERROR_ACCEL_DATA_NOT_READY   (81)
#define ML_ERROR_ACCEL_DATA_ERROR       (82)

/* For Linux coding compliance */
#ifndef __KERNEL__
#define EXPORT_SYMBOL(x)
#endif

/*---------------------------
    p-Types
---------------------------*/

#endif				/* MLTYPES_H */