A hacked library to offer I2C functionality similar to the standard mbed library for I2C1 only. Is seemingly required when using the v29 beta mbed library as of 12.05.2011, as the I2C does not seem to work otherwise. Has been developed and tested with the ADXL345 accelerometer.

Dependents:   SensorsThingSpeak

Committer:
ShockSoc
Date:
Thu May 12 09:24:27 2011 +0000
Revision:
0:375ecd0ed73d

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ShockSoc 0:375ecd0ed73d 1 /**
ShockSoc 0:375ecd0ed73d 2 * Author: Rob Hyams
ShockSoc 0:375ecd0ed73d 3 * Date: 12.05.2011
ShockSoc 0:375ecd0ed73d 4 * This is a beta library for use with I2C1. The standard mbed I2C
ShockSoc 0:375ecd0ed73d 5 * is not currently functioning when using the v29 beta library.
ShockSoc 0:375ecd0ed73d 6 * Therefore, this has been developed as a drop in replacement.
ShockSoc 0:375ecd0ed73d 7 * Code is not particularly robust, but will handle incorrect
ShockSoc 0:375ecd0ed73d 8 * communication by checking states.
ShockSoc 0:375ecd0ed73d 9 *
ShockSoc 0:375ecd0ed73d 10 * Has been developed and tested with ADXL345 accelerometer
ShockSoc 0:375ecd0ed73d 11 */
ShockSoc 0:375ecd0ed73d 12
ShockSoc 0:375ecd0ed73d 13
ShockSoc 0:375ecd0ed73d 14
ShockSoc 0:375ecd0ed73d 15 #ifndef I2CR_H
ShockSoc 0:375ecd0ed73d 16 #define I2CR_H
ShockSoc 0:375ecd0ed73d 17
ShockSoc 0:375ecd0ed73d 18 #include "mbed.h"
ShockSoc 0:375ecd0ed73d 19
ShockSoc 0:375ecd0ed73d 20 class I2CR {
ShockSoc 0:375ecd0ed73d 21
ShockSoc 0:375ecd0ed73d 22 public:
ShockSoc 0:375ecd0ed73d 23 //Constructor
ShockSoc 0:375ecd0ed73d 24 I2CR();
ShockSoc 0:375ecd0ed73d 25
ShockSoc 0:375ecd0ed73d 26 //Write function
ShockSoc 0:375ecd0ed73d 27 int write(int address, const char* data, int length);
ShockSoc 0:375ecd0ed73d 28
ShockSoc 0:375ecd0ed73d 29 //Read function
ShockSoc 0:375ecd0ed73d 30 int read(int address, char* data, int length);
ShockSoc 0:375ecd0ed73d 31
ShockSoc 0:375ecd0ed73d 32 };
ShockSoc 0:375ecd0ed73d 33
ShockSoc 0:375ecd0ed73d 34 #endif