Prof Greg Egan I2C code, prevents I2C freeze when using interrupt in
Diff: MyI2C.h
- Revision:
- 0:1c722325e933
diff -r 000000000000 -r 1c722325e933 MyI2C.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyI2C.h Tue Aug 27 09:31:56 2013 +0000 @@ -0,0 +1,28 @@ +#ifndef MyI2C_H +#define MyI2C_H + +#include "mbed.h" + +#define I2C_ACK true +#define I2C_NACK false + +#define I2C_WRITE 0 +#define I2C_READ 1 + +extern bool I2C0AddressResponds(uint8_t); + +class MyI2C +{ +private: + bool waitclock(void); +public: + //void frequency(uint32_t f); + void start(void); + void stop(void); + uint8_t blockread(uint8_t r, char* b, uint8_t); + uint8_t read(uint8_t r); + bool blockwrite(uint8_t a, const char* b, uint8_t l); + uint8_t write(uint8_t d); +}; + +#endif \ No newline at end of file