Home | History | Annotate | only in /device/google/contexthub/firmware/os/drivers/st_mag40
Up to higher level directory
NameDateSize
README21-Aug-20182K
st_mag40.c21-Aug-201830.6K

README

      1 STMicroelectronics mag40 magnetometer sensor device driver for Google nanohub.
      2 
      3 This drivers support following devices:
      4     - LSM303AGR
      5     - LSM303AH
      6     - LIS2MDL
      7 
      8 - Supported features:
      9 
     10 A. Reports geomagnetic field vector data
     11 B. Different data rates: 10/20/50/100 Hz
     12 C. I2C protocol
     13 D. Data ready reported by interrupt
     14 
     15 
     16 - Platform/variant porting:
     17 
     18 The driver requires that following macros are defined in the variant.h
     19 file of the specific variant:
     20 
     21   ST_MAG40_CAL_ENABLED   /* specify whether the magnetic calibration API must be included */
     22 
     23   ST_MAG40_I2C_BUS_ID    /* specify I2C Bus ID */
     24   ST_MAG40_I2C_SPEED     /* specify I2C Bus speed in hz */
     25   ST_MAG40_I2C_ADDR      /* specify device I2C address */
     26 
     27   ST_MAG40_INT_PIN       /* specify the gpio used for the DRDY irq */
     28   ST_MAG40_INT_IRQ       /* specify the exti interrupt of ST_MAG40_INT_PIN */
     29   ST_MAG40_ROT_MATRIX    /* specify how axis has to be rotated according to variant platform
     30                           * orientation.
     31                           *
     32                           * = r11, r12, r13, r21, r22, r23, r31, r32, r33
     33                           *
     34                           * Rotation:
     35                           *
     36                           * [x']   [r11 r12 r13]   [x]   [r11*x + r12*y +r13*z]
     37                           * [y'] = [r21 r22 r23] * [y] = [r21*x + r22*y +r23*z]
     38                           * [z']   [r31 r32 r33]   [x]   [r31*x + r32*y +r33*z]
     39                           */
     40 
     41 Example:
     42 
     43   /*
     44    * Define platform/variant dependent ST_MAG40 device macros
     45    */
     46   #define ST_MAG40_CAL_ENABLED   1
     47 
     48   /* I2C defs to be used when device is plugged on U4 slot */
     49   #define ST_MAG40_I2C_BUS_ID      0
     50   #define ST_MAG40_I2C_SPEED       400000
     51   #define ST_MAG40_I2C_ADDR        0x1E
     52 
     53   #define ST_MAG40_INT_PIN         GPIO_PB(4)
     54   #define ST_MAG40_INT_IRQ         EXTI4_IRQn
     55 
     56   #define ST_MAG40_ROT_MATRIX      0, 1, 0, 1, 0, 0, 0, 0, 1
     57 
     58 If these macros are not defined in the current variant the driver forces a compilation
     59 error.
     60