Flemmard | 6b1be1e | 2014-02-21 19:34:00 +0100 | [diff] [blame^] | 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** |
| 2 | * |
| 3 | * File Name : lsm303dlh.h |
| 4 | * Authors : MSH - Motion Mems BU - Application Team |
| 5 | * : Carmine Iascone (carmine.iascone@st.com) |
| 6 | * : Matteo Dameno (matteo.dameno@st.com) |
| 7 | * Version : V 1.6.0 |
| 8 | * Date : 2011/02/28 |
| 9 | * Description : LSM303DLH 6D module sensor API |
| 10 | * |
| 11 | ******************************************************************************** |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License version 2 as |
| 15 | * published by the Free Software Foundation. |
| 16 | * |
| 17 | * THE PRESENT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES |
| 18 | * OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, FOR THE SOLE |
| 19 | * PURPOSE TO SUPPORT YOUR APPLICATION DEVELOPMENT. |
| 20 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
| 21 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
| 22 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
| 23 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
| 24 | * |
| 25 | *******************************************************************************/ |
| 26 | |
| 27 | #ifndef __LSM303DLH_H__ |
| 28 | #define __LSM303DLH_H__ |
| 29 | |
| 30 | #define SAD0L 0x00 |
| 31 | #define SAD0H 0x01 |
| 32 | #define LSM303DLH_ACC_I2C_SADROOT 0x0C |
| 33 | #define LSM303DLH_ACC_I2C_SAD_L ((LSM303DLH_ACC_I2C_SADROOT<<1)|SAD0L) |
| 34 | #define LSM303DLH_ACC_I2C_SAD_H ((LSM303DLH_ACC_I2C_SADROOT<<1)|SAD0H) |
| 35 | #define LSM303DLH_ACC_DEV_NAME "lsm303dlh_acc_sysfs" |
| 36 | |
| 37 | |
| 38 | #define LSM303DLH_MAG_I2C_SAD 0x1E |
| 39 | #define LSM303DLH_MAG_DEV_NAME "lsm303dlh_mag_sysfs" |
| 40 | |
| 41 | |
| 42 | |
| 43 | /************************************************/ |
| 44 | /* Accelerometer section defines */ |
| 45 | /************************************************/ |
| 46 | |
| 47 | /* Accelerometer Sensor Full Scale */ |
| 48 | #define LSM303DLH_ACC_FS_MASK 0x30 |
| 49 | #define LSM303DLH_ACC_G_2G 0x00 |
| 50 | #define LSM303DLH_ACC_G_4G 0x10 |
| 51 | #define LSM303DLH_ACC_G_8G 0x30 |
| 52 | |
| 53 | /* Accelerometer Sensor Operating Mode */ |
| 54 | #define LSM303DLH_ACC_ENABLE 0x01 |
| 55 | #define LSM303DLH_ACC_DISABLE 0x00 |
| 56 | #define LSM303DLH_ACC_PM_NORMAL 0x20 |
| 57 | #define LSM303DLH_ACC_PM_OFF LSM303DLH_ACC_DISABLE |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | /************************************************/ |
| 63 | /* Magnetometer section defines */ |
| 64 | /************************************************/ |
| 65 | |
| 66 | /* Magnetometer Sensor Full Scale */ |
| 67 | #define LSM303DLH_MAG_H_1_3G 0x20 |
| 68 | #define LSM303DLH_MAG_H_1_9G 0x40 |
| 69 | #define LSM303DLH_MAG_H_2_5G 0x60 |
| 70 | #define LSM303DLH_MAG_H_4_0G 0x80 |
| 71 | #define LSM303DLH_MAG_H_4_7G 0xA0 |
| 72 | #define LSM303DLH_MAG_H_5_6G 0xC0 |
| 73 | #define LSM303DLH_MAG_H_8_1G 0xE0 |
| 74 | |
| 75 | /* Magnetic Sensor Operating Mode */ |
| 76 | #define LSM303DLH_MAG_NORMAL_MODE 0x00 |
| 77 | #define LSM303DLH_MAG_POS_BIAS 0x01 |
| 78 | #define LSM303DLH_MAG_NEG_BIAS 0x02 |
| 79 | #define LSM303DLH_MAG_CC_MODE 0x00 |
| 80 | #define LSM303DLH_MAG_SC_MODE 0x01 |
| 81 | #define LSM303DLH_MAG_SLEEP_MODE 0x03 |
| 82 | |
| 83 | |
| 84 | #ifdef __KERNEL__ |
| 85 | struct lsm303dlh_acc_platform_data { |
| 86 | |
| 87 | int poll_interval; |
| 88 | int min_interval; |
| 89 | |
| 90 | u8 g_range; |
| 91 | |
| 92 | u8 axis_map_x; |
| 93 | u8 axis_map_y; |
| 94 | u8 axis_map_z; |
| 95 | |
| 96 | u8 negate_x; |
| 97 | u8 negate_y; |
| 98 | u8 negate_z; |
| 99 | |
| 100 | int (*init)(void); |
| 101 | void (*exit)(void); |
| 102 | int (*power_on)(void); |
| 103 | int (*power_off)(void); |
| 104 | |
| 105 | /* set gpio_int[1,2] either to the choosen gpio pin number or to -EINVAL |
| 106 | * if leaved unconnected |
| 107 | */ |
| 108 | int gpio_int1; |
| 109 | int gpio_int2; |
| 110 | }; |
| 111 | |
| 112 | struct lsm303dlh_mag_platform_data { |
| 113 | |
| 114 | int poll_interval; |
| 115 | int min_interval; |
| 116 | |
| 117 | u8 h_range; |
| 118 | |
| 119 | u8 axis_map_x; |
| 120 | u8 axis_map_y; |
| 121 | u8 axis_map_z; |
| 122 | |
| 123 | u8 negate_x; |
| 124 | u8 negate_y; |
| 125 | u8 negate_z; |
| 126 | |
| 127 | int (*init)(void); |
| 128 | void (*exit)(void); |
| 129 | int (*power_on)(void); |
| 130 | int (*power_off)(void); |
| 131 | |
| 132 | }; |
| 133 | #endif /* __KERNEL__ */ |
| 134 | |
| 135 | #endif /* __LSM303DLH_H__ */ |