Home | History | Annotate | Download | only in AKFS_APIs_8975
      1 /******************************************************************************
      2  * $Id: AKFS_AK8975.c 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 #include "AKFS_AK8975.h"
     20 #include "AKFS_Device.h"
     21 
     22 /*!
     23  */
     24 int16 AKFS_DecompAK8975(
     25 	const	int16		mag[3],
     26 	const	int16		status,
     27 	const	uint8vec*	asa,
     28 	const	int16		nhdata,
     29 			AKFVEC		hdata[]
     30 )
     31 {
     32 	/* put st1 and st2 value */
     33 	if (AK8975_ST_ERROR(status)) {
     34 		return AKFS_ERROR;
     35 	}
     36 
     37 	/* magnetic */
     38 	AKFS_BufShift(nhdata, 1, hdata);
     39 	hdata[0].u.x = mag[0] * (((asa->u.x)/256.0f) + 0.5f);
     40 	hdata[0].u.y = mag[1] * (((asa->u.y)/256.0f) + 0.5f);
     41 	hdata[0].u.z = mag[2] * (((asa->u.z)/256.0f) + 0.5f);
     42 
     43 	return AKFS_SUCCESS;
     44 }
     45 
     46