Basic functions is OK. Lack interrupts function.

Dependents:   Mt05_MtSense07

Committer:
bcc6
Date:
Thu Mar 23 08:54:15 2017 +0000
Revision:
4:413b8ef9aed5
Parent:
3:14f634433c89
Merge from branch

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 3:14f634433c89 39 /* Interrupts */
bcc6 3:14f634433c89 40 static const unsigned INT_DR = 0x01; // Data ready
bcc6 3:14f634433c89 41 static const unsigned INT_IR24L = 0x02; // Lower threshold level
bcc6 3:14f634433c89 42 static const unsigned INT_IR24H = 0x04; // Upper threshold level
bcc6 3:14f634433c89 43 static const unsigned INT_IR13L = 0x08; // Lower threshold level
bcc6 3:14f634433c89 44 static const unsigned INT_IR13H = 0x10; // Upper threshold level
bcc6 3:14f634433c89 45
bcc6 3:14f634433c89 46 public:
bcc6 0:4f87d5af61b1 47 AK9750(I2C &i2c, PinName int1 = NC);
bcc6 0:4f87d5af61b1 48
bcc6 0:4f87d5af61b1 49 void ConfigDevice();
bcc6 0:4f87d5af61b1 50 void GetDeviceID(uint8_t *id);
bcc6 0:4f87d5af61b1 51 void GetData(Data *data);
bcc6 0:4f87d5af61b1 52 int32_t GetTriggeredAreaNum(Data *data);
bcc6 0:4f87d5af61b1 53
bcc6 3:14f634433c89 54 /* Interrupts */
bcc6 3:14f634433c89 55 void SetIntEvent(uint8_t int_enable, void(*fptr)(void));
bcc6 3:14f634433c89 56 uint8_t GetIntStatus();
bcc6 3:14f634433c89 57
bcc6 0:4f87d5af61b1 58 private:
bcc6 0:4f87d5af61b1 59 I2C &_i2c;
bcc6 0:4f87d5af61b1 60 InterruptIn _int1;
bcc6 0:4f87d5af61b1 61
bcc6 0:4f87d5af61b1 62 float ConvertAdcToIr(int16_t adc);
bcc6 0:4f87d5af61b1 63 float ConvertAdcToTemperature(int16_t adc);
bcc6 0:4f87d5af61b1 64
bcc6 0:4f87d5af61b1 65 void RegWrite(char reg, char val);
bcc6 0:4f87d5af61b1 66 void RegRead (char reg, char *val, int len);
bcc6 0:4f87d5af61b1 67 void RegReadModifyWrite(char reg, char clr_mask, char set_mask);
bcc6 0:4f87d5af61b1 68 };
bcc6 0:4f87d5af61b1 69
bcc6 0:4f87d5af61b1 70 #endif