Basic functions is OK. Lack interrupts function.

Dependents:   Mt05_MtSense07

Committer:
bcc6
Date:
Thu Jan 26 03:22:34 2017 +0000
Revision:
1:4eefcf1d7351
Parent:
0:4f87d5af61b1
Child:
2:afb035feac6c
Basic functions is OK. Lack interrupts function.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcc6 1:4eefcf1d7351 1 /* Copyright (c) 2016 MtM Technology Corporation, MIT License
bcc6 1:4eefcf1d7351 2 *
bcc6 1:4eefcf1d7351 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcc6 1:4eefcf1d7351 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
bcc6 1:4eefcf1d7351 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
bcc6 1:4eefcf1d7351 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
bcc6 1:4eefcf1d7351 7 * furnished to do so, subject to the following conditions:
bcc6 1:4eefcf1d7351 8 *
bcc6 1:4eefcf1d7351 9 * The above copyright notice and this permission notice shall be included in all copies or
bcc6 1:4eefcf1d7351 10 * substantial portions of the Software.
bcc6 1:4eefcf1d7351 11 *
bcc6 1:4eefcf1d7351 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcc6 1:4eefcf1d7351 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcc6 1:4eefcf1d7351 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcc6 1:4eefcf1d7351 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcc6 1:4eefcf1d7351 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcc6 1:4eefcf1d7351 17 */
bcc6 0:4f87d5af61b1 18 #ifndef AK09970_H
bcc6 0:4f87d5af61b1 19 #define AK09970_H
bcc6 0:4f87d5af61b1 20
bcc6 0:4f87d5af61b1 21 #include "mbed.h"
bcc6 0:4f87d5af61b1 22
bcc6 0:4f87d5af61b1 23
bcc6 0:4f87d5af61b1 24 #define AK09970_SLAVE_ADDR 0x18 // 0001_1000b
bcc6 0:4f87d5af61b1 25
bcc6 0:4f87d5af61b1 26
bcc6 0:4f87d5af61b1 27 class AK09970 {
bcc6 0:4f87d5af61b1 28 public:
bcc6 0:4f87d5af61b1 29 struct Data {
bcc6 0:4f87d5af61b1 30 float x; // uT/LSB
bcc6 0:4f87d5af61b1 31 float y;
bcc6 0:4f87d5af61b1 32 float z;
bcc6 0:4f87d5af61b1 33 };
bcc6 0:4f87d5af61b1 34
bcc6 0:4f87d5af61b1 35 static const uint8_t DEVICE_ID = 0xC0;
bcc6 0:4f87d5af61b1 36
bcc6 0:4f87d5af61b1 37 AK09970(I2C &i2c, PinName int1 = NC);
bcc6 0:4f87d5af61b1 38
bcc6 0:4f87d5af61b1 39 void ConfigDevice();
bcc6 0:4f87d5af61b1 40 void GetDeviceID(uint8_t *id);
bcc6 0:4f87d5af61b1 41 void GetData(Data *data);
bcc6 0:4f87d5af61b1 42
bcc6 0:4f87d5af61b1 43 private:
bcc6 0:4f87d5af61b1 44 I2C &_i2c;
bcc6 0:4f87d5af61b1 45 InterruptIn _int1;
bcc6 0:4f87d5af61b1 46
bcc6 0:4f87d5af61b1 47 float ConvertAdcToMagnetic(int16_t adc);
bcc6 0:4f87d5af61b1 48
bcc6 0:4f87d5af61b1 49 void RegWrite(char reg, char val);
bcc6 0:4f87d5af61b1 50 void RegWrite(char reg, char *val, int len);
bcc6 0:4f87d5af61b1 51 void RegRead (char reg, char *val, int len);
bcc6 0:4f87d5af61b1 52 void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
bcc6 0:4f87d5af61b1 53 };
bcc6 0:4f87d5af61b1 54
bcc6 0:4f87d5af61b1 55 #endif