1 /******************************************************************************
2  * $Id: AKFS_Device.h 580 2012-03-29 09:56:21Z yamada.rj $
3  ******************************************************************************
4  *
5  * Copyright (C) 2012 Asahi Kasei Microdevices Corporation, Japan
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 #ifndef AKFS_INC_DEVICE_H
20 #define AKFS_INC_DEVICE_H
21 
22 #include <float.h>
23 #include "AKFS_Configure.h"
24 
25 /***** Constant definition ****************************************************/
26 #define AKFS_ERROR			0
27 #define AKFS_SUCCESS		1
28 
29 #define AKFS_HDATA_SIZE		32
30 #define AKFS_ADATA_SIZE		32
31 
32 /***** Type declaration *******************************************************/
33 typedef signed char     int8;
34 typedef signed short    int16;
35 typedef unsigned char   uint8;
36 typedef unsigned short  uint16;
37 
38 
39 #ifdef AKFS_PRECISION_DOUBLE
40 typedef	double			AKFLOAT;
41 #define AKFS_EPSILON	DBL_EPSILON
42 #define AKFS_FMAX		DBL_MAX
43 #define AKFS_FMIN		DBL_MIN
44 
45 #else
46 typedef	float			AKFLOAT;
47 #define AKFS_EPSILON	FLT_EPSILON
48 #define AKFS_FMAX		FLT_MAX
49 #define AKFS_FMIN		FLT_MIN
50 
51 #endif
52 
53 /* Treat maximum value as initial value */
54 #define AKFS_INIT_VALUE_F	AKFS_FMAX
55 
56 /***** Vector *****/
57 typedef union _uint8vec{
58 	struct {
59 		uint8	x;
60 		uint8	y;
61 		uint8	z;
62 	}u;
63 	uint8	v[3];
64 } uint8vec;
65 
66 typedef union _AKFVEC{
67 	struct {
68 		AKFLOAT x;
69 		AKFLOAT y;
70 		AKFLOAT z;
71 	}u;
72 	AKFLOAT	v[3];
73 } AKFVEC;
74 
75 /***** Layout pattern *****/
76 typedef enum _AKFS_PATNO {
77 	PAT_INVALID = 0,
78 	PAT1,	/* obverse: 1st pin is right down */
79 	PAT2,	/* obverse: 1st pin is left down */
80 	PAT3,	/* obverse: 1st pin is left top */
81 	PAT4,	/* obverse: 1st pin is right top */
82 	PAT5,	/* reverse: 1st pin is left down (from top view) */
83 	PAT6,	/* reverse: 1st pin is left top (from top view) */
84 	PAT7,	/* reverse: 1st pin is right top (from top view) */
85 	PAT8	/* reverse: 1st pin is right down (from top view) */
86 } AKFS_PATNO;
87 
88 /***** Prototype of function **************************************************/
89 AKLIB_C_API_START
90 int16 AKFS_InitBuffer(
91 	const	int16	ndata,		/*!< Size of raw vector buffer */
92 			AKFVEC	vdata[]		/*!< Raw vector buffer */
93 );
94 
95 int16 AKFS_BufShift(
96 	const	int16	len,
97 	const	int16	shift,
98 			AKFVEC	v[]
99 );
100 
101 int16 AKFS_Rotate(
102 	const   AKFS_PATNO  pat,
103 			AKFVEC*     vec
104 );
105 AKLIB_C_API_END
106 
107 #endif
108 
109