MSS
/
testI2C
Simple I2C test program. open/close/read/write supported.
dumb_i2c.h@2:218e22a54982, 2016-04-05 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Apr 05 06:53:27 2016 +0000
- Revision:
- 2:218e22a54982
- Parent:
- 1:e105ceaee6ac
condition check for read/write and bus scan added;
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 | 1:e105ceaee6ac | 21 | void frequency(uint32_t f) ; |
Rhyme | 1:e105ceaee6ac | 22 | uint32_t frequency(void) ; |
Rhyme | 0:1a2637f8e2dd | 23 | uint8_t address(void) ; |
Rhyme | 2:218e22a54982 | 24 | int read(int addr, uint8_t *data, int len) ; |
Rhyme | 2:218e22a54982 | 25 | int write(int addr, uint8_t *data, int len) ; |
Rhyme | 0:1a2637f8e2dd | 26 | private: |
Rhyme | 0:1a2637f8e2dd | 27 | I2C m_i2c; |
Rhyme | 0:1a2637f8e2dd | 28 | int m_addr; |
Rhyme | 1:e105ceaee6ac | 29 | uint32_t freq ; |
Rhyme | 2:218e22a54982 | 30 | int readRegs(int addr, uint8_t * data, int len); |
Rhyme | 2:218e22a54982 | 31 | int writeRegs(uint8_t * data, int len); |
Rhyme | 0:1a2637f8e2dd | 32 | }; |
Rhyme | 0:1a2637f8e2dd | 33 | |
Rhyme | 0:1a2637f8e2dd | 34 | #endif /* _DUMB_I2C_H_ */ |