I2C sensor test program, derived from testI2C program. Simple test for FXOS8700CQ, HIH6130, MAG3110, MMA8451Q, MMA8452Q, MPL3115A2, MAX44000, MAX44005, MAX44008, MAX30101 included beside simple I2C read/write from testI2C.
Dependencies: FXOS8700CQ HIH6130 IS31SE5000 MAG3110 MAX44000 MAX44005 MAX44008 MMA8451Q MMA8452Q MPL3115A2 VEML6040 VEML6075 mbed vt100 LM75B FXAS21002 MAX30101 VCNL4020 VCNL4100
Diff: dumb_i2c.h
- Revision:
- 0:d4bbd473a83c
- Child:
- 18:ee6f43cbfcc1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dumb_i2c.h Tue Apr 26 02:38:14 2016 +0000 @@ -0,0 +1,34 @@ +#ifndef _DUMB_I2C_H_ +#define _DUMB_I2C_H_ + +class DUMB_I2C +{ +public: + /** + * DUMB_I2C constructor + * + * @param sda SDA pin + * @param sdl SCL pin + * @param addr addr of the I2C peripheral + */ + DUMB_I2C(PinName sda, PinName scl, int addr); + + /** + * HIH6130 destructor + */ + ~DUMB_I2C(); + + void frequency(uint32_t f) ; + uint32_t frequency(void) ; + uint8_t address(void) ; + int read(int addr, uint8_t *data, int len) ; + int write(int addr, uint8_t *data, int len) ; +private: + I2C m_i2c; + int m_addr; + uint32_t freq ; + int readRegs(int addr, uint8_t * data, int len); + int writeRegs(uint8_t * data, int len); +}; + +#endif /* _DUMB_I2C_H_ */ \ No newline at end of file