Basic functions is OK. Lack interrupts function.
AK9750.h
- Committer:
- bcc6
- Date:
- 2017-01-26
- Revision:
- 1:4eefcf1d7351
- Parent:
- 0:4f87d5af61b1
- Child:
- 3:14f634433c89
File content as of revision 1:4eefcf1d7351:
/* Copyright (c) 2016 MtM Technology Corporation, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef AK9750_H #define AK9750_H #include "mbed.h" #define AK9750_SLAVE_ADDR 0xC8 // 1100_1000b class AK9750 { public: struct Data { float ir1; // pA float ir2; float ir3; float ir4; float tmp; // 'C }; static const uint8_t DEVICE_ID = 0x13; AK9750(I2C &i2c, PinName int1 = NC); void ConfigDevice(); void GetDeviceID(uint8_t *id); void GetData(Data *data); int32_t GetTriggeredAreaNum(Data *data); private: I2C &_i2c; InterruptIn _int1; float ConvertAdcToIr(int16_t adc); float ConvertAdcToTemperature(int16_t adc); void RegWrite(char reg, char val); void RegRead (char reg, char *val, int len); void RegReadModifyWrite(char reg, char clr_mask, char set_mask); }; #endif