Simple I2C test program. open/close/read/write supported.

Dependencies:   mbed vt100

Committer:
Rhyme
Date:
Tue Apr 05 02:11:20 2016 +0000
Revision:
1:e105ceaee6ac
Parent:
0:1a2637f8e2dd
Child:
2:218e22a54982
doWrite bug fix;

Who changed what in which revision?

UserRevisionLine numberNew 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 0:1a2637f8e2dd 24 void read(int addr, uint8_t *data, int len) ;
Rhyme 0:1a2637f8e2dd 25 void 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 0:1a2637f8e2dd 30 void readRegs(int addr, uint8_t * data, int len);
Rhyme 0:1a2637f8e2dd 31 void writeRegs(uint8_t * data, int len);
Rhyme 0:1a2637f8e2dd 32 };
Rhyme 0:1a2637f8e2dd 33
Rhyme 0:1a2637f8e2dd 34 #endif /* _DUMB_I2C_H_ */