Home | History | Annotate | Download | only in akmdfs
      1 /******************************************************************************
      2  * $Id: AK8975Driver.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 AKMD_INC_AK8975DRIVER_H
     20 #define AKMD_INC_AK8975DRIVER_H
     21 
     22 #include "platform/include/linux/akm8975.h"	/* Device driver */
     23 #include <stdint.h>			/* int8_t, int16_t etc. */
     24 
     25 /*** Constant definition ******************************************************/
     26 #define AKD_TRUE	1		/*!< Represents true */
     27 #define AKD_FALSE	0		/*!< Represents false */
     28 #define AKD_SUCCESS	1		/*!< Represents success.*/
     29 #define AKD_FAIL	0		/*!< Represents fail. */
     30 #define AKD_ERROR	-1		/*!< Represents error. */
     31 
     32 /*! 0:Don't Output data, 1:Output data */
     33 #define AKD_DBG_DATA	0
     34 /*! Typical interval in ns */
     35 #define AK8975_MEASUREMENT_TIME_NS	((AK8975_MEASUREMENT_TIME_US) * 1000)
     36 /*! 720 LSG = 1G = 9.8 m/s2 */
     37 #define LSG			720
     38 
     39 
     40 /*** Type declaration *********************************************************/
     41 typedef unsigned char BYTE;
     42 
     43 /*!
     44  Open device driver.
     45  This function opens device driver of acceleration sensor.
     46  @return If this function succeeds, the return value is #AKD_SUCCESS. Otherwise
     47  the return value is #AKD_FAIL.
     48  */
     49 typedef int16_t(*ACCFNC_INITDEVICE)(void);
     50 
     51 /*!
     52  Close device driver.
     53  This function closes device drivers of acceleration sensor.
     54  */
     55 typedef void(*ACCFNC_DEINITDEVICE)(void);
     56 
     57 /*!
     58  Acquire acceleration data from acceleration sensor and convert it to Android
     59  coordinate system.
     60  @return If this function succeeds, the return value is #AKD_SUCCESS. Otherwise
     61  the return value is #AKD_FAIL.
     62  @param[out] data A acceleration data array. The coordinate system of the
     63  acquired data follows the definition of Android. Unit is SmartCompass.
     64  */
     65 typedef int16_t(*ACCFNC_GETACCDATA)(short data[3]);
     66 
     67 
     68 /*** Global variables *********************************************************/
     69 
     70 /*** Prototype of Function  ***************************************************/
     71 
     72 int16_t AKD_InitDevice(void);
     73 
     74 void AKD_DeinitDevice(void);
     75 
     76 int16_t AKD_TxData(
     77 	const BYTE address,
     78 	const BYTE* data,
     79 	const uint16_t numberOfBytesToWrite);
     80 
     81 int16_t AKD_RxData(
     82 	const BYTE address,
     83 	BYTE* data,
     84 	const uint16_t numberOfBytesToRead);
     85 
     86 int16_t AKD_GetMagneticData(BYTE data[SENSOR_DATA_SIZE]);
     87 
     88 void AKD_SetYPR(const int buf[YPR_DATA_SIZE]);
     89 
     90 int AKD_GetOpenStatus(int* status);
     91 
     92 int AKD_GetCloseStatus(int* status);
     93 
     94 int16_t AKD_SetMode(const BYTE mode);
     95 
     96 int16_t AKD_GetDelay(int64_t delay[AKM_NUM_SENSORS]);
     97 
     98 int16_t AKD_GetLayout(int16_t* layout);
     99 
    100 int16_t AKD_GetAccelerationData(int16_t data[3]);
    101 
    102 #endif /* AKMD_INC_AK8975DRIVER_H */
    103 
    104