/*! * @section LICENSE * (C) Copyright 2011~2014 Bosch Sensortec GmbH All Rights Reserved * * This software program is licensed subject to the GNU General * Public License (GPL).Version 2,June 1991, * available at http://www.fsf.org/copyleft/gpl.html * * @filename bmg160.h * @date 2013/11/25 * @id "7bf4b97" * @version 1.5 * * @brief Header of BMG160 API */ /* user defined code to be added here ... */ #ifndef __BMG160_H__ #define __BMG160_H__ #ifdef __KERNEL__ #define BMG160_U16 unsigned short /* 16 bit achieved with short */ #define BMG160_S16 signed short #define BMG160_S32 signed int /* 32 bit achieved with int */ #else #include /*needed to test integer limits */ /* find correct data type for signed/unsigned 16 bit variables \ by checking max of unsigned variant */ #if USHRT_MAX == 0xFFFF /* 16 bit achieved with short */ #define BMG160_U16 unsigned short #define BMG160_S16 signed short #elif UINT_MAX == 0xFFFF /* 16 bit achieved with int */ #define BMG160_U16 unsigned int #define BMG160_S16 signed int #else #error BMG160_U16 and BMG160_S16 could not be #error defined automatically, please do so manually #endif /* find correct data type for signed 32 bit variables */ #if INT_MAX == 0x7FFFFFFF /* 32 bit achieved with int */ #define BMG160_S32 signed int #elif LONG_MAX == 0x7FFFFFFF /* 32 bit achieved with long int */ #define BMG160_S32 signed long int #else #error BMG160_S32 could not be #error defined automatically, please do so manually #endif #endif /**\brief defines the calling parameter types of the BMG160_WR_FUNCTION */ #define BMG160_BUS_WR_RETURN_TYPE char /**\brief links the order of parameters defined in BMG160_BUS_WR_PARAM_TYPE to function calls used inside the API*/ #define BMG160_BUS_WR_PARAM_TYPES unsigned char, unsigned char,\ unsigned char *, unsigned char /**\brief links the order of parameters defined in BMG160_BUS_WR_PARAM_TYPE to function calls used inside the API*/ #define BMG160_BUS_WR_PARAM_ORDER(device_addr, register_addr,\ register_data, wr_len) /* never change this line */ #define BMG160_BUS_WRITE_FUNC(device_addr, register_addr,\ register_data, wr_len) bus_write(device_addr, register_addr,\ register_data, wr_len) /**\brief defines the return parameter type of the BMG160_RD_FUNCTION */ #define BMG160_BUS_RD_RETURN_TYPE char /**\brief defines the calling parameter types of the BMG160_RD_FUNCTION */ #define BMG160_BUS_RD_PARAM_TYPES unsigned char, unsigned char,\ unsigned char *, unsigned char /**\brief links the order of parameters defined in \ BMG160_BUS_RD_PARAM_TYPE to function calls used inside the API */ #define BMG160_BUS_RD_PARAM_ORDER (device_addr, register_addr,\ register_data) /* never change this line */ #define BMG160_BUS_READ_FUNC(device_addr, register_addr,\ register_data, rd_len)bus_read(device_addr, register_addr,\ register_data, rd_len) /**\brief defines the return parameter type of the BMG160_RD_FUNCTION */ #define BMG160_BURST_RD_RETURN_TYPE char /**\brief defines the calling parameter types of the BMG160_RD_FUNCTION */ #define BMG160_BURST_RD_PARAM_TYPES unsigned char,\ unsigned char, unsigned char *, signed int /**\brief links the order of parameters defined in \ BMG160_BURST_RD_PARAM_TYPE to function calls used inside the API */ #define BMG160_BURST_RD_PARAM_ORDER (device_addr, register_addr,\ register_data) /* never change this line */ #define BMG160_BURST_READ_FUNC(device_addr, register_addr,\ register_data, rd_len)burst_read(device_addr, \ register_addr, register_data, rd_len) /**\brief defines the return parameter type of the BMG160_DELAY_FUNCTION */ #define BMG160_DELAY_RETURN_TYPE void /* never change this line */ #define BMG160_DELAY_FUNC(delay_in_msec)\ delay_func(delay_in_msec) #define BMG160_RETURN_FUNCTION_TYPE int /**< This refers BMG160 return type as char */ #define BMG160_I2C_ADDR1 0x68 #define BMG160_I2C_ADDR BMG160_I2C_ADDR1 #define BMG160_I2C_ADDR2 0x69 /*Define of registers*/ /* Hard Wired */ #define BMG160_CHIP_ID_ADDR 0x00 /**
> bitname##__POS) /* Set bit slice */ #define BMG160_SET_BITSLICE(regvar, bitname, val)\ ((regvar&~bitname##__MSK)|((val<