aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/include
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-20 16:34:15 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-22 14:06:10 -0400
commita3344f4ab3ab90b1aec05c97cb026cec9ec73e9e (patch)
treeaf01e37230f66713d00c8a7ef0c779d032a8cab9 /libmaple/include
parent0262fe55fa5c87264b3e93358474a77289603d20 (diff)
downloadlibrambutan-a3344f4ab3ab90b1aec05c97cb026cec9ec73e9e.tar.gz
librambutan-a3344f4ab3ab90b1aec05c97cb026cec9ec73e9e.zip
libmaple/i2c.h: Better comments.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/include')
-rw-r--r--libmaple/include/libmaple/i2c.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/libmaple/include/libmaple/i2c.h b/libmaple/include/libmaple/i2c.h
index 8ea77d7..859edcd 100644
--- a/libmaple/include/libmaple/i2c.h
+++ b/libmaple/include/libmaple/i2c.h
@@ -28,6 +28,13 @@
/**
* @file libmaple/include/libmaple/i2c.h
* @brief Inter-Integrated Circuit (I2C) peripheral support
+ *
+ * Currently master-only. Usage notes:
+ *
+ * - Enable an I2C device with i2c_master_enable().
+ * - Initialize an array of struct i2c_msg to suit the bus
+ * transactions (reads/writes) you wish to perform.
+ * - Call i2c_master_xfer() to do the work.
*/
#ifndef _LIBMAPLE_I2C_H_
@@ -72,10 +79,15 @@ typedef struct i2c_reg_map {
*/
typedef struct i2c_msg {
uint16 addr; /**< Address */
+
#define I2C_MSG_READ 0x1
#define I2C_MSG_10BIT_ADDR 0x2
- uint16 flags; /**< Bitwise OR of I2C_MSG_READ and
- I2C_MSG_10BIT_ADDR */
+ /**
+ * Bitwise OR of:
+ * - I2C_MSG_READ (write is default)
+ * - I2C_MSG_10BIT_ADDR (7-bit is default) */
+ uint16 flags;
+
uint16 length; /**< Message length */
uint16 xferred; /**< Messages transferred */
uint8 *data; /**< Data */
@@ -165,6 +177,8 @@ typedef struct i2c_msg {
* Convenience routines
*/
+/* Main I2C API */
+
/* I2C enable options */
#define I2C_FAST_MODE 0x1 // 400 khz
#define I2C_DUTY_16_9 0x2 // 16/9 duty ratio