AKM AK09970N 3D Magnetic Sensor with Programmable Switch

Committer:
Rhyme
Date:
Thu Dec 28 07:24:03 2017 +0000
Revision:
1:2b2ead3e4efc
first working version, no documents in place

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 1:2b2ead3e4efc 1 #ifndef _AK09970N_H_
Rhyme 1:2b2ead3e4efc 2 #define _AK09970N_H_
Rhyme 1:2b2ead3e4efc 3 /**
Rhyme 1:2b2ead3e4efc 4 * AK09970N
Rhyme 1:2b2ead3e4efc 5 * 3D Magnetic Sensor with Programmable Switch
Rhyme 1:2b2ead3e4efc 6 */
Rhyme 1:2b2ead3e4efc 7 #include "mbed.h"
Rhyme 1:2b2ead3e4efc 8 class AK09970N
Rhyme 1:2b2ead3e4efc 9 {
Rhyme 1:2b2ead3e4efc 10 public:
Rhyme 1:2b2ead3e4efc 11 /**
Rhyme 1:2b2ead3e4efc 12 * AK09970N constructor
Rhyme 1:2b2ead3e4efc 13 *
Rhyme 1:2b2ead3e4efc 14 * @param sda SDA pin
Rhyme 1:2b2ead3e4efc 15 * @param sdl SCL pin
Rhyme 1:2b2ead3e4efc 16 * @param addr addr of the I2C peripheral
Rhyme 1:2b2ead3e4efc 17 */
Rhyme 1:2b2ead3e4efc 18 AK09970N(PinName sda, PinName scl, int addr);
Rhyme 1:2b2ead3e4efc 19
Rhyme 1:2b2ead3e4efc 20 /**
Rhyme 1:2b2ead3e4efc 21 * AK09970N destructor
Rhyme 1:2b2ead3e4efc 22 */
Rhyme 1:2b2ead3e4efc 23 ~AK09970N();
Rhyme 1:2b2ead3e4efc 24 int software_reset(void) ;
Rhyme 1:2b2ead3e4efc 25 int getID(uint16_t *CompanyID, uint16_t *DeviceID) ;
Rhyme 1:2b2ead3e4efc 26 uint16_t getStatus(void) ;
Rhyme 1:2b2ead3e4efc 27 int setINT(uint16_t value) ;
Rhyme 1:2b2ead3e4efc 28 uint16_t getINT(void) ;
Rhyme 1:2b2ead3e4efc 29 int setConfig(uint8_t config) ;
Rhyme 1:2b2ead3e4efc 30 uint8_t getConfig(void) ;
Rhyme 1:2b2ead3e4efc 31 int singleShot(void) ;
Rhyme 1:2b2ead3e4efc 32 float i2f(int16_t value) ;
Rhyme 1:2b2ead3e4efc 33
Rhyme 1:2b2ead3e4efc 34 /* get data float version */
Rhyme 1:2b2ead3e4efc 35 int getX(uint16_t *status, float *x) ;
Rhyme 1:2b2ead3e4efc 36 int getY(uint16_t *status, float *y) ;
Rhyme 1:2b2ead3e4efc 37 int getZ(uint16_t *status, float *z) ;
Rhyme 1:2b2ead3e4efc 38 int getX_Y(uint16_t *status, float *x, float *y) ;
Rhyme 1:2b2ead3e4efc 39 int getX_Z(uint16_t *status, float *x, float *z) ;
Rhyme 1:2b2ead3e4efc 40 int getY_Z(uint16_t *status, float *y, float *z) ;
Rhyme 1:2b2ead3e4efc 41 int getX_Y_Z(uint16_t *status, float *x, float *y, float *z) ;
Rhyme 1:2b2ead3e4efc 42
Rhyme 1:2b2ead3e4efc 43 /* get data 16bit version */
Rhyme 1:2b2ead3e4efc 44 int getHX(uint16_t *status, int16_t *x) ;
Rhyme 1:2b2ead3e4efc 45 int getHY(uint16_t *status, int16_t *y) ;
Rhyme 1:2b2ead3e4efc 46 int getHZ(uint16_t *status, int16_t *z) ;
Rhyme 1:2b2ead3e4efc 47 int getHX_HY(uint16_t *status, int16_t *x, int16_t *y) ;
Rhyme 1:2b2ead3e4efc 48 int getHX_HZ(uint16_t *status, int16_t *x, int16_t *z) ;
Rhyme 1:2b2ead3e4efc 49 int getHY_HZ(uint16_t *status, int16_t *y, int16_t *z) ;
Rhyme 1:2b2ead3e4efc 50 int getHX_HY_HZ(uint16_t *status, int16_t *x, int16_t *y, int16_t *z) ;
Rhyme 1:2b2ead3e4efc 51
Rhyme 1:2b2ead3e4efc 52 /* get data 8bit version */
Rhyme 1:2b2ead3e4efc 53 int getBX(uint16_t *status, int8_t *x) ;
Rhyme 1:2b2ead3e4efc 54 int getBY(uint16_t *status, int8_t *y) ;
Rhyme 1:2b2ead3e4efc 55 int getBZ(uint16_t *status, int8_t *z) ;
Rhyme 1:2b2ead3e4efc 56 int getBX_BY(uint16_t *status, int8_t *x, int8_t *y) ;
Rhyme 1:2b2ead3e4efc 57 int getBX_BZ(uint16_t *status, int8_t *x, int8_t *z) ;
Rhyme 1:2b2ead3e4efc 58 int getBY_BZ(uint16_t *status, int8_t *y, int8_t *z) ;
Rhyme 1:2b2ead3e4efc 59 int getBX_BY_BZ(uint16_t *status, int8_t *x, int8_t *y, int8_t *z) ;
Rhyme 1:2b2ead3e4efc 60
Rhyme 1:2b2ead3e4efc 61 /* get thresholds */
Rhyme 1:2b2ead3e4efc 62 int getTHS_X1(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 63 int getTHS_X2(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 64 int getTHS_Y1(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 65 int getTHS_Y2(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 66 int getTHS_Z1(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 67 int getTHS_Z2(int16_t *bop, int16_t *brp) ;
Rhyme 1:2b2ead3e4efc 68
Rhyme 1:2b2ead3e4efc 69 /* set thresholds */
Rhyme 1:2b2ead3e4efc 70 int setTHS_X1(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 71 int setTHS_X2(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 72 int setTHS_Y1(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 73 int setTHS_Y2(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 74 int setTHS_Z1(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 75 int setTHS_Z2(int16_t bop, int16_t brp) ;
Rhyme 1:2b2ead3e4efc 76
Rhyme 1:2b2ead3e4efc 77 private:
Rhyme 1:2b2ead3e4efc 78 uint8_t _mode ;
Rhyme 1:2b2ead3e4efc 79 uint8_t _sdr ;
Rhyme 1:2b2ead3e4efc 80 uint8_t _smr ;
Rhyme 1:2b2ead3e4efc 81 I2C m_i2c;
Rhyme 1:2b2ead3e4efc 82 int m_addr;
Rhyme 1:2b2ead3e4efc 83 int readRegs(int addr, uint8_t * data, int len);
Rhyme 1:2b2ead3e4efc 84 int writeRegs(uint8_t * data, int len);
Rhyme 1:2b2ead3e4efc 85 };
Rhyme 1:2b2ead3e4efc 86 #endif