Home | History | Annotate | Download | only in include
      1 /*
      2  $License:
      3    Copyright 2011 InvenSense, Inc.
      4 
      5  Licensed under the Apache License, Version 2.0 (the "License");
      6  you may not use this file except in compliance with the License.
      7  You may obtain a copy of the License at
      8 
      9  http://www.apache.org/licenses/LICENSE-2.0
     10 
     11  Unless required by applicable law or agreed to in writing, software
     12  distributed under the License is distributed on an "AS IS" BASIS,
     13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  See the License for the specific language governing permissions and
     15  limitations under the License.
     16   $
     17  */
     18 
     19 /**
     20  *  @defgroup MLERROR
     21  *  @brief  Motion Library - Error definitions.
     22  *          Definition of the error codes used within the MPL and
     23  *          returned to the user.
     24  *          Every function tries to return a meaningful error code basing
     25  *          on the occuring error condition. The error code is numeric.
     26  *
     27  *          The available error codes and their associated values are:
     28  *          - (0)       INV_SUCCESS
     29  *          - (1)       INV_ERROR
     30  *          - (2)       INV_ERROR_INVALID_PARAMETER
     31  *          - (3)       INV_ERROR_FEATURE_NOT_ENABLED
     32  *          - (4)       INV_ERROR_FEATURE_NOT_IMPLEMENTED
     33  *          - (6)       INV_ERROR_DMP_NOT_STARTED
     34  *          - (7)       INV_ERROR_DMP_STARTED
     35  *          - (8)       INV_ERROR_NOT_OPENED
     36  *          - (9)       INV_ERROR_OPENED
     37  *          - (10)      INV_ERROR_INVALID_MODULE
     38  *          - (11)      INV_ERROR_MEMORY_EXAUSTED
     39  *          - (12)      INV_ERROR_DIVIDE_BY_ZERO
     40  *          - (13)      INV_ERROR_ASSERTION_FAILURE
     41  *          - (14)      INV_ERROR_FILE_OPEN
     42  *          - (15)      INV_ERROR_FILE_READ
     43  *          - (16)      INV_ERROR_FILE_WRITE
     44  *          - (17)      INV_ERROR_INVALID_CONFIGURATION
     45  *          - (20)      INV_ERROR_SERIAL_CLOSED
     46  *          - (21)      INV_ERROR_SERIAL_OPEN_ERROR
     47  *          - (22)      INV_ERROR_SERIAL_READ
     48  *          - (23)      INV_ERROR_SERIAL_WRITE
     49  *          - (24)      INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
     50  *          - (25)      INV_ERROR_SM_TRANSITION
     51  *          - (26)      INV_ERROR_SM_IMPROPER_STATE
     52  *          - (30)      INV_ERROR_FIFO_OVERFLOW
     53  *          - (31)      INV_ERROR_FIFO_FOOTER
     54  *          - (32)      INV_ERROR_FIFO_READ_COUNT
     55  *          - (33)      INV_ERROR_FIFO_READ_DATA
     56  *          - (40)      INV_ERROR_MEMORY_SET
     57  *          - (50)      INV_ERROR_LOG_MEMORY_ERROR
     58  *          - (51)      INV_ERROR_LOG_OUTPUT_ERROR
     59  *          - (60)      INV_ERROR_OS_BAD_PTR
     60  *          - (61)      INV_ERROR_OS_BAD_HANDLE
     61  *          - (62)      INV_ERROR_OS_CREATE_FAILED
     62  *          - (63)      INV_ERROR_OS_LOCK_FAILED
     63  *          - (70)      INV_ERROR_COMPASS_DATA_OVERFLOW
     64  *          - (71)      INV_ERROR_COMPASS_DATA_UNDERFLOW
     65  *          - (72)      INV_ERROR_COMPASS_DATA_NOT_READY
     66  *          - (73)      INV_ERROR_COMPASS_DATA_ERROR
     67  *          - (75)      INV_ERROR_CALIBRATION_LOAD
     68  *          - (76)      INV_ERROR_CALIBRATION_STORE
     69  *          - (77)      INV_ERROR_CALIBRATION_LEN
     70  *          - (78)      INV_ERROR_CALIBRATION_CHECKSUM
     71  *          - (79)      INV_ERROR_ACCEL_DATA_OVERFLOW
     72  *          - (80)      INV_ERROR_ACCEL_DATA_UNDERFLOW
     73  *          - (81)      INV_ERROR_ACCEL_DATA_NOT_READY
     74  *          - (82)      INV_ERROR_ACCEL_DATA_ERROR
     75  *
     76  *  @{
     77  *      @file mltypes.h
     78  *  @}
     79  */
     80 
     81 #ifndef MLTYPES_H
     82 #define MLTYPES_H
     83 
     84 #ifdef __KERNEL__
     85 #include <linux/types.h>
     86 #else
     87 #include "stdint_invensense.h"
     88 #endif
     89 
     90 /*---------------------------
     91     ML Types
     92 ---------------------------*/
     93 
     94 /**
     95  *  @struct inv_error_t mltypes.h "mltypes"
     96  *  @brief  The MPL Error Code return type.
     97  *
     98  *  @code
     99  *      typedef unsigned char inv_error_t;
    100  *  @endcode
    101  */
    102 typedef unsigned char inv_error_t;
    103 
    104 #ifndef __cplusplus
    105 #ifndef __KERNEL__
    106 typedef int_fast8_t bool;
    107 #endif
    108 #endif
    109 
    110 /*---------------------------
    111     ML Defines
    112 ---------------------------*/
    113 
    114 #ifndef NULL
    115 #define NULL 0
    116 #endif
    117 
    118 #ifndef TRUE
    119 #define TRUE 1
    120 #endif
    121 
    122 #ifndef FALSE
    123 #define FALSE 0
    124 #endif
    125 
    126 #ifndef __KERNEL__
    127 #ifndef ARRAY_SIZE
    128 /* Dimension of an array */
    129 #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0]))
    130 #endif
    131 #endif
    132 /* - ML Errors. - */
    133 #define ERROR_NAME(x)   (#x)
    134 #define ERROR_CHECK_FIRST(first, x)                                     \
    135 	{ if (INV_SUCCESS == first) first = x; }
    136 
    137 #define INV_SUCCESS                       (0)
    138 /* Generic Error code.  Proprietary Error Codes only */
    139 #define INV_ERROR                         (1)
    140 
    141 /* Compatibility and other generic error codes */
    142 #define INV_ERROR_INVALID_PARAMETER       (2)
    143 #define INV_ERROR_FEATURE_NOT_ENABLED     (3)
    144 #define INV_ERROR_FEATURE_NOT_IMPLEMENTED (4)
    145 #define INV_ERROR_DMP_NOT_STARTED         (6)
    146 #define INV_ERROR_DMP_STARTED             (7)
    147 #define INV_ERROR_NOT_OPENED              (8)
    148 #define INV_ERROR_OPENED                  (9)
    149 #define INV_ERROR_INVALID_MODULE         (10)
    150 #define INV_ERROR_MEMORY_EXAUSTED        (11)
    151 #define INV_ERROR_DIVIDE_BY_ZERO         (12)
    152 #define INV_ERROR_ASSERTION_FAILURE      (13)
    153 #define INV_ERROR_FILE_OPEN              (14)
    154 #define INV_ERROR_FILE_READ              (15)
    155 #define INV_ERROR_FILE_WRITE             (16)
    156 #define INV_ERROR_INVALID_CONFIGURATION  (17)
    157 
    158 /* Serial Communication */
    159 #define INV_ERROR_SERIAL_CLOSED          (20)
    160 #define INV_ERROR_SERIAL_OPEN_ERROR      (21)
    161 #define INV_ERROR_SERIAL_READ            (22)
    162 #define INV_ERROR_SERIAL_WRITE           (23)
    163 #define INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  (24)
    164 
    165 /* SM = State Machine */
    166 #define INV_ERROR_SM_TRANSITION          (25)
    167 #define INV_ERROR_SM_IMPROPER_STATE      (26)
    168 
    169 /* Fifo */
    170 #define INV_ERROR_FIFO_OVERFLOW          (30)
    171 #define INV_ERROR_FIFO_FOOTER            (31)
    172 #define INV_ERROR_FIFO_READ_COUNT        (32)
    173 #define INV_ERROR_FIFO_READ_DATA         (33)
    174 
    175 /* Memory & Registers, Set & Get */
    176 #define INV_ERROR_MEMORY_SET             (40)
    177 
    178 #define INV_ERROR_LOG_MEMORY_ERROR       (50)
    179 #define INV_ERROR_LOG_OUTPUT_ERROR       (51)
    180 
    181 /* OS interface errors */
    182 #define INV_ERROR_OS_BAD_PTR             (60)
    183 #define INV_ERROR_OS_BAD_HANDLE          (61)
    184 #define INV_ERROR_OS_CREATE_FAILED       (62)
    185 #define INV_ERROR_OS_LOCK_FAILED         (63)
    186 
    187 /* Compass errors */
    188 #define INV_ERROR_COMPASS_DATA_OVERFLOW  (70)
    189 #define INV_ERROR_COMPASS_DATA_UNDERFLOW (71)
    190 #define INV_ERROR_COMPASS_DATA_NOT_READY (72)
    191 #define INV_ERROR_COMPASS_DATA_ERROR     (73)
    192 
    193 /* Load/Store calibration */
    194 #define INV_ERROR_CALIBRATION_LOAD       (75)
    195 #define INV_ERROR_CALIBRATION_STORE      (76)
    196 #define INV_ERROR_CALIBRATION_LEN        (77)
    197 #define INV_ERROR_CALIBRATION_CHECKSUM   (78)
    198 
    199 /* Accel errors */
    200 #define INV_ERROR_ACCEL_DATA_OVERFLOW    (79)
    201 #define INV_ERROR_ACCEL_DATA_UNDERFLOW   (80)
    202 #define INV_ERROR_ACCEL_DATA_NOT_READY   (81)
    203 #define INV_ERROR_ACCEL_DATA_ERROR       (82)
    204 
    205 #ifdef INV_USE_LEGACY_NAMES
    206 #define ML_SUCCESS                       INV_SUCCESS
    207 #define ML_ERROR                         INV_ERROR
    208 #define ML_ERROR_INVALID_PARAMETER       INV_ERROR_INVALID_PARAMETER
    209 #define ML_ERROR_FEATURE_NOT_ENABLED     INV_ERROR_FEATURE_NOT_ENABLED
    210 #define ML_ERROR_FEATURE_NOT_IMPLEMENTED INV_ERROR_FEATURE_NOT_IMPLEMENTED
    211 #define ML_ERROR_DMP_NOT_STARTED         INV_ERROR_DMP_NOT_STARTED
    212 #define ML_ERROR_DMP_STARTED             INV_ERROR_DMP_STARTED
    213 #define ML_ERROR_NOT_OPENED              INV_ERROR_NOT_OPENED
    214 #define ML_ERROR_OPENED                  INV_ERROR_OPENED
    215 #define ML_ERROR_INVALID_MODULE          INV_ERROR_INVALID_MODULE
    216 #define ML_ERROR_MEMORY_EXAUSTED         INV_ERROR_MEMORY_EXAUSTED
    217 #define ML_ERROR_DIVIDE_BY_ZERO          INV_ERROR_DIVIDE_BY_ZERO
    218 #define ML_ERROR_ASSERTION_FAILURE       INV_ERROR_ASSERTION_FAILURE
    219 #define ML_ERROR_FILE_OPEN               INV_ERROR_FILE_OPEN
    220 #define ML_ERROR_FILE_READ               INV_ERROR_FILE_READ
    221 #define ML_ERROR_FILE_WRITE              INV_ERROR_FILE_WRITE
    222 #define ML_ERROR_INVALID_CONFIGURATION   INV_ERROR_INVALID_CONFIGURATION
    223 #define ML_ERROR_SERIAL_CLOSED           INV_ERROR_SERIAL_CLOSED
    224 #define ML_ERROR_SERIAL_OPEN_ERROR       INV_ERROR_SERIAL_OPEN_ERROR
    225 #define ML_ERROR_SERIAL_READ             INV_ERROR_SERIAL_READ
    226 #define ML_ERROR_SERIAL_WRITE            INV_ERROR_SERIAL_WRITE
    227 #define ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  \
    228 	INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
    229 #define ML_ERROR_SM_TRANSITION          INV_ERROR_SM_TRANSITION
    230 #define ML_ERROR_SM_IMPROPER_STATE      INV_ERROR_SM_IMPROPER_STATE
    231 #define ML_ERROR_FIFO_OVERFLOW          INV_ERROR_FIFO_OVERFLOW
    232 #define ML_ERROR_FIFO_FOOTER            INV_ERROR_FIFO_FOOTER
    233 #define ML_ERROR_FIFO_READ_COUNT        INV_ERROR_FIFO_READ_COUNT
    234 #define ML_ERROR_FIFO_READ_DATA         INV_ERROR_FIFO_READ_DATA
    235 #define ML_ERROR_MEMORY_SET             INV_ERROR_MEMORY_SET
    236 #define ML_ERROR_LOG_MEMORY_ERROR       INV_ERROR_LOG_MEMORY_ERROR
    237 #define ML_ERROR_LOG_OUTPUT_ERROR       INV_ERROR_LOG_OUTPUT_ERROR
    238 #define ML_ERROR_OS_BAD_PTR             INV_ERROR_OS_BAD_PTR
    239 #define ML_ERROR_OS_BAD_HANDLE          INV_ERROR_OS_BAD_HANDLE
    240 #define ML_ERROR_OS_CREATE_FAILED       INV_ERROR_OS_CREATE_FAILED
    241 #define ML_ERROR_OS_LOCK_FAILED         INV_ERROR_OS_LOCK_FAILED
    242 #define ML_ERROR_COMPASS_DATA_OVERFLOW  INV_ERROR_COMPASS_DATA_OVERFLOW
    243 #define ML_ERROR_COMPASS_DATA_UNDERFLOW INV_ERROR_COMPASS_DATA_UNDERFLOW
    244 #define ML_ERROR_COMPASS_DATA_NOT_READY INV_ERROR_COMPASS_DATA_NOT_READY
    245 #define ML_ERROR_COMPASS_DATA_ERROR     INV_ERROR_COMPASS_DATA_ERROR
    246 #define ML_ERROR_CALIBRATION_LOAD       INV_ERROR_CALIBRATION_LOAD
    247 #define ML_ERROR_CALIBRATION_STORE      INV_ERROR_CALIBRATION_STORE
    248 #define ML_ERROR_CALIBRATION_LEN        INV_ERROR_CALIBRATION_LEN
    249 #define ML_ERROR_CALIBRATION_CHECKSUM   INV_ERROR_CALIBRATION_CHECKSUM
    250 #define ML_ERROR_ACCEL_DATA_OVERFLOW    INV_ERROR_ACCEL_DATA_OVERFLOW
    251 #define ML_ERROR_ACCEL_DATA_UNDERFLOW   INV_ERROR_ACCEL_DATA_UNDERFLOW
    252 #define ML_ERROR_ACCEL_DATA_NOT_READY   INV_ERROR_ACCEL_DATA_NOT_READY
    253 #define ML_ERROR_ACCEL_DATA_ERROR       INV_ERROR_ACCEL_DATA_ERROR
    254 #endif
    255 
    256 /* For Linux coding compliance */
    257 #ifndef __KERNEL__
    258 #define EXPORT_SYMBOL(x)
    259 #endif
    260 
    261 /*---------------------------
    262     p-Types
    263 ---------------------------*/
    264 
    265 #endif				/* MLTYPES_H */
    266