Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed by
Diff: I2C.h
- Revision:
- 21:3944f1e2fa4f
- Parent:
- 20:029aa53d7323
- Child:
- 22:9114680c05da
diff -r 029aa53d7323 -r 3944f1e2fa4f I2C.h
--- a/I2C.h Thu Jun 03 11:17:50 2010 +0000
+++ b/I2C.h Thu Jun 17 16:23:14 2010 +0000
@@ -40,6 +40,11 @@
, MasterRead
};
+ enum Acknowledge {
+ NoACK = 0
+ , ACK = 1
+ };
+
/* Constructor: I2C
* Create an I2C Master interface, connected to the specified pins
*
@@ -72,6 +77,15 @@
*/
int read(int address, char *data, int length, bool repeated = false);
+ /* Function: read
+ * Read a single byte from the I2C bus
+ *
+ * Variables:
+ * ack - indicates if the byte is to be acknowledged (1 = acknowledge)
+ * returns - the byte read
+ */
+ int read(int ack);
+
/* Function: write
* Write to an I2C slave
*
@@ -86,7 +100,27 @@
* returns - 0 on success (ack), or non-0 on failure (nack)
*/
int write(int address, const char *data, int length, bool repeated = false);
-
+
+ /* Function: write
+ * Write single byte out on the I2C bus
+ *
+ * Variables:
+ * data - data to write out on bus
+ * returns - a '1' if an ACK was retrieved, a '0' otherwise
+ */
+ int write(int data);
+
+ /* Function: start
+ * Creates a start condition on the I2C bus
+ */
+
+ void start(void);
+
+ /* Function: stop
+ * Creates a stop condition on the I2C bus
+ */
+ void stop(void);
+
protected:
void aquire();
