MSS
/
testI2C
Simple I2C test program. open/close/read/write supported.
dumb_i2c.h@0:1a2637f8e2dd, 2016-02-09 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Feb 09 00:23:22 2016 +0000
- Revision:
- 0:1a2637f8e2dd
- Child:
- 1:e105ceaee6ac
First working version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:1a2637f8e2dd | 1 | #ifndef _DUMB_I2C_H_ |
Rhyme | 0:1a2637f8e2dd | 2 | #define _DUMB_I2C_H_ |
Rhyme | 0:1a2637f8e2dd | 3 | |
Rhyme | 0:1a2637f8e2dd | 4 | class DUMB_I2C |
Rhyme | 0:1a2637f8e2dd | 5 | { |
Rhyme | 0:1a2637f8e2dd | 6 | public: |
Rhyme | 0:1a2637f8e2dd | 7 | /** |
Rhyme | 0:1a2637f8e2dd | 8 | * DUMB_I2C constructor |
Rhyme | 0:1a2637f8e2dd | 9 | * |
Rhyme | 0:1a2637f8e2dd | 10 | * @param sda SDA pin |
Rhyme | 0:1a2637f8e2dd | 11 | * @param sdl SCL pin |
Rhyme | 0:1a2637f8e2dd | 12 | * @param addr addr of the I2C peripheral |
Rhyme | 0:1a2637f8e2dd | 13 | */ |
Rhyme | 0:1a2637f8e2dd | 14 | DUMB_I2C(PinName sda, PinName scl, int addr); |
Rhyme | 0:1a2637f8e2dd | 15 | |
Rhyme | 0:1a2637f8e2dd | 16 | /** |
Rhyme | 0:1a2637f8e2dd | 17 | * HIH6130 destructor |
Rhyme | 0:1a2637f8e2dd | 18 | */ |
Rhyme | 0:1a2637f8e2dd | 19 | ~DUMB_I2C(); |
Rhyme | 0:1a2637f8e2dd | 20 | |
Rhyme | 0:1a2637f8e2dd | 21 | uint8_t address(void) ; |
Rhyme | 0:1a2637f8e2dd | 22 | void read(int addr, uint8_t *data, int len) ; |
Rhyme | 0:1a2637f8e2dd | 23 | void write(int addr, uint8_t *data, int len) ; |
Rhyme | 0:1a2637f8e2dd | 24 | private: |
Rhyme | 0:1a2637f8e2dd | 25 | I2C m_i2c; |
Rhyme | 0:1a2637f8e2dd | 26 | int m_addr; |
Rhyme | 0:1a2637f8e2dd | 27 | void readRegs(int addr, uint8_t * data, int len); |
Rhyme | 0:1a2637f8e2dd | 28 | void writeRegs(uint8_t * data, int len); |
Rhyme | 0:1a2637f8e2dd | 29 | }; |
Rhyme | 0:1a2637f8e2dd | 30 | |
Rhyme | 0:1a2637f8e2dd | 31 | #endif /* _DUMB_I2C_H_ */ |