summaryrefslogtreecommitdiffstats
path: root/sensors/akmdfs/AKFS_Common.h
blob: 77808015d8d2d94a5bdb5259f55aa54e9eade24b (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
/******************************************************************************
 *
 * Copyright (C) 2012 Asahi Kasei Microdevices Corporation, Japan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/
#ifndef AKFS_INC_COMMON_H
#define AKFS_INC_COMMON_H

#ifdef WIN32
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif    					
  					
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <stdarg.h>
#include <crtdbg.h>
#include "Android.h"

#define DBG_LEVEL	DBG_LEVEL4
#define ENABLE_AKMDEBUG	1

#else
#include <stdio.h>     /* frpintf */
#include <stdlib.h>    /* atoi */
#include <string.h>    /* memset */
#include <unistd.h>
#include <stdarg.h>    /* va_list */
#include <utils/Log.h> /* ALOGV */
#include <errno.h>     /* errno */

#endif

/*** Constant definition ******************************************************/
#define AKM_TRUE	1	/*!< Represents true */
#define AKM_FALSE	0	/*!< Represents false */
#define AKM_SUCCESS	1	/*!< Represents success */
#define AKM_FAIL	0	/*!< Represents fail */

#define DBG_LEVEL0	0	/* Critical */
#define DBG_LEVEL1	1	/* Notice */
#define DBG_LEVEL2	2	/* Information */
#define DBG_LEVEL3	3	/* Debug */
#define DBG_LEVEL4	4	/* Verbose */

#ifndef DBG_LEVEL
#define DBG_LEVEL	DBG_LEVEL0
#endif

#define DATA_AREA01	0x0001
#define DATA_AREA02	0x0002
#define DATA_AREA03	0x0004
#define DATA_AREA04	0x0008
#define DATA_AREA05	0x0010
#define DATA_AREA06	0x0020
#define DATA_AREA07	0x0040
#define DATA_AREA08	0x0080
#define DATA_AREA09	0x0100
#define DATA_AREA10	0x0200
#define DATA_AREA11	0x0400
#define DATA_AREA12	0x0800
#define DATA_AREA13	0x1000
#define DATA_AREA14	0x2000
#define DATA_AREA15	0x4000
#define DATA_AREA16	0x8000


/* Debug area definition */
#define AKMDATA_DUMP		DATA_AREA01	/*<! Dump data */
#define AKMDATA_BDATA		DATA_AREA02	/*<! BDATA */
#define AKMDATA_MAG			DATA_AREA03 /*<! Magnetic Field */
#define AKMDATA_ACC			DATA_AREA04 /*<! Accelerometer */
#define AKMDATA_ORI			DATA_AREA05 /*<! Orientation */
#define AKMDATA_GETINTERVAL	DATA_AREA06
#define AKMDATA_LOOP		DATA_AREA07
#define AKMDATA_DRV			DATA_AREA08

#ifndef ENABLE_AKMDEBUG
#define ENABLE_AKMDEBUG		0	/* Eanble debug output when it is 1. */
#endif

#define OPMODE_CONSOLE		0x01
#define OPMODE_FST			0x02

/***** Debug Level Output *************************************/
#if ENABLE_AKMDEBUG
#define AKMDEBUG(level, format, ...) \
    (((level) <= DBG_LEVEL) \
	  ? (fprintf(stdout, (format), ##__VA_ARGS__)) \
	  : ((void)0))
#else
#define AKMDEBUG(level, format, ...)
#endif

/***** Dbg Zone Output ***************************************/
#if ENABLE_AKMDEBUG
#define AKMDATA(flag, format, ...)  \
	((((int)flag) & g_dbgzone) \
	  ? (fprintf(stdout, (format), ##__VA_ARGS__)) \
	  : ((void)0))
#else
#define AKMDATA(flag, format, ...)
#endif

/***** Log output ********************************************/
#ifdef AKM_LOG_ENABLE
#define AKM_LOG(format, ...)	ALOGD((format), ##__VA_ARGS__)
#else
#define AKM_LOG(format, ...)
#endif

/***** Error output *******************************************/
#define AKMERROR \
	ALOGE("%s:%d Error.", __FUNCTION__, __LINE__)

#define AKMERROR_STR(api) \
	ALOGE("%s:%d %s Error (%s).", \
	  		  __FUNCTION__, __LINE__, (api), strerror(errno))

/*** Type declaration *********************************************************/

/*** Global variables *********************************************************/

/*** Prototype of function ****************************************************/

#endif /* AKMD_INC_AKCOMMON_H */