Basic functions is OK. Lack interrupts function.

Dependents:   Mt05_MtSense07

Committer:
bcc6
Date:
Thu Jan 26 03:08:15 2017 +0000
Revision:
0:4f87d5af61b1
Child:
1:4eefcf1d7351
Basic functions is OK. Lack interrupts function.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcc6 0:4f87d5af61b1 1 #ifndef AK09912_H
bcc6 0:4f87d5af61b1 2 #define AK09912_H
bcc6 0:4f87d5af61b1 3
bcc6 0:4f87d5af61b1 4 #include "mbed.h"
bcc6 0:4f87d5af61b1 5
bcc6 0:4f87d5af61b1 6
bcc6 0:4f87d5af61b1 7 #define AK09912_SLAVE_ADDR 0x1A // 0001_1010b
bcc6 0:4f87d5af61b1 8
bcc6 0:4f87d5af61b1 9
bcc6 0:4f87d5af61b1 10 class AK09912 {
bcc6 0:4f87d5af61b1 11 public:
bcc6 0:4f87d5af61b1 12 struct Data {
bcc6 0:4f87d5af61b1 13 float x; // uT/LSB
bcc6 0:4f87d5af61b1 14 float y;
bcc6 0:4f87d5af61b1 15 float z;
bcc6 0:4f87d5af61b1 16 float t; // 'C
bcc6 0:4f87d5af61b1 17 };
bcc6 0:4f87d5af61b1 18
bcc6 0:4f87d5af61b1 19 static const uint8_t DEVICE_ID = 0x04;
bcc6 0:4f87d5af61b1 20
bcc6 0:4f87d5af61b1 21 AK09912(I2C &i2c, PinName int1 = NC);
bcc6 0:4f87d5af61b1 22
bcc6 0:4f87d5af61b1 23 void ConfigDevice();
bcc6 0:4f87d5af61b1 24 void GetDeviceID(uint8_t *id);
bcc6 0:4f87d5af61b1 25 void GetData(Data *data);
bcc6 0:4f87d5af61b1 26
bcc6 0:4f87d5af61b1 27 private:
bcc6 0:4f87d5af61b1 28 I2C &_i2c;
bcc6 0:4f87d5af61b1 29 InterruptIn _int1;
bcc6 0:4f87d5af61b1 30
bcc6 0:4f87d5af61b1 31 uint8_t _asa[3]; // ASAX, ASAY, ASAZ
bcc6 0:4f87d5af61b1 32
bcc6 0:4f87d5af61b1 33 float ConvertAdcToMagnetic(int16_t adc, uint8_t asa);
bcc6 0:4f87d5af61b1 34 float ConvertAdcToTemperature(uint8_t adc);
bcc6 0:4f87d5af61b1 35
bcc6 0:4f87d5af61b1 36 void RegWrite(char reg, char val);
bcc6 0:4f87d5af61b1 37 void RegRead (char reg, char *val, int len);
bcc6 0:4f87d5af61b1 38 void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
bcc6 0:4f87d5af61b1 39 };
bcc6 0:4f87d5af61b1 40
bcc6 0:4f87d5af61b1 41 #endif