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:
3:14f634433c89
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 AK9750_H
bcc6 0:4f87d5af61b1 19 #define AK9750_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 AK9750_SLAVE_ADDR 0xC8 // 1100_1000b
bcc6 0:4f87d5af61b1 25
bcc6 0:4f87d5af61b1 26
bcc6 0:4f87d5af61b1 27 class AK9750 {
bcc6 0:4f87d5af61b1 28 public:
bcc6 0:4f87d5af61b1 29 struct Data {
bcc6 0:4f87d5af61b1 30 float ir1; // pA
bcc6 0:4f87d5af61b1 31 float ir2;
bcc6 0:4f87d5af61b1 32 float ir3;
bcc6 0:4f87d5af61b1 33 float ir4;
bcc6 0:4f87d5af61b1 34 float tmp; // 'C
bcc6 0:4f87d5af61b1 35 };
bcc6 0:4f87d5af61b1 36
bcc6 0:4f87d5af61b1 37 static const uint8_t DEVICE_ID = 0x13;
bcc6 0:4f87d5af61b1 38
bcc6 0:4f87d5af61b1 39 AK9750(I2C &i2c, PinName int1 = NC);
bcc6 0:4f87d5af61b1 40
bcc6 0:4f87d5af61b1 41 void ConfigDevice();
bcc6 0:4f87d5af61b1 42 void GetDeviceID(uint8_t *id);
bcc6 0:4f87d5af61b1 43 void GetData(Data *data);
bcc6 0:4f87d5af61b1 44 int32_t GetTriggeredAreaNum(Data *data);
bcc6 0:4f87d5af61b1 45
bcc6 0:4f87d5af61b1 46 private:
bcc6 0:4f87d5af61b1 47 I2C &_i2c;
bcc6 0:4f87d5af61b1 48 InterruptIn _int1;
bcc6 0:4f87d5af61b1 49
bcc6 0:4f87d5af61b1 50 float ConvertAdcToIr(int16_t adc);
bcc6 0:4f87d5af61b1 51 float ConvertAdcToTemperature(int16_t adc);
bcc6 0:4f87d5af61b1 52
bcc6 0:4f87d5af61b1 53 void RegWrite(char reg, char val);
bcc6 0:4f87d5af61b1 54 void RegRead (char reg, char *val, int len);
bcc6 0:4f87d5af61b1 55 void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
bcc6 0:4f87d5af61b1 56 };
bcc6 0:4f87d5af61b1 57
bcc6 0:4f87d5af61b1 58 #endif