summaryrefslogtreecommitdiff
path: root/nuttx/include/nuttx/i2c.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-26 12:45:54 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-26 12:45:54 +0000
commitaa523fbad99cbf5ee95d28bb11b6955a19bf6347 (patch)
tree8b62ef8f4ea621fcbe6977e6092a55de445462bd /nuttx/include/nuttx/i2c.h
parenta3c42414f1a88d9c15343488d2be574bfa143093 (diff)
downloadnuttx-aa523fbad99cbf5ee95d28bb11b6955a19bf6347.tar.gz
nuttx-aa523fbad99cbf5ee95d28bb11b6955a19bf6347.tar.bz2
nuttx-aa523fbad99cbf5ee95d28bb11b6955a19bf6347.zip
Extend I2C interface definition
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2700 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include/nuttx/i2c.h')
-rw-r--r--nuttx/include/nuttx/i2c.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/nuttx/include/nuttx/i2c.h b/nuttx/include/nuttx/i2c.h
index 8ebf65aa1..471d25619 100644
--- a/nuttx/include/nuttx/i2c.h
+++ b/nuttx/include/nuttx/i2c.h
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/i2c.h
*
- * Copyright(C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright(C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -71,6 +71,11 @@
#define I2C_READADDR10H(a) (I2C_ADDR10H(a) | I2C_READBIT)
#define I2C_READADDR10L(a) I2C_ADDR10L(a)
+/* Bit definitions for the flags field in struct i2c_ops_s */
+
+#define I2C_M_READ 0x0001 /* read data, from slave to master */
+#define I2C_M_TEN 0x0002 /* ten bit address */
+
/* Access macros */
/****************************************************************************
@@ -153,18 +158,56 @@
#define I2C_READ(d,b,l) ((d)->ops->read(d,b,l))
/****************************************************************************
+ * Name: I2C_TRANSFER
+ *
+ * Description:
+ * Perform a sequence of I2C transfers, each transfer is started with a
+ * START and the final transfer is completed with a STOP. Each sequence
+ * will be an 'atomic' operation in the sense that any other I2C actions
+ * will be serialized and pend until this read completes. Optional.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * msgs - A pointer to a set of message descriptors
+ * msgcount - The number of transfers to perform
+ *
+ * Returned Value:
+ * The number of transfers completed
+ *
+ ****************************************************************************/
+
+#define I2C_TRANSFER(d,m,c) ((d)->ops->transfer(d,m,c))
+
+/****************************************************************************
* Public Types
****************************************************************************/
/* The I2C vtable */
struct i2c_dev_s;
+struct i2c_msg_s;
struct i2c_ops_s
{
uint32_t (*setfrequency)(FAR struct i2c_dev_s *dev, uint32_t frequency);
int (*setaddress)(FAR struct i2c_dev_s *dev, int addr, int nbits);
int (*write)(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int buflen);
int (*read)(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen);
+#ifdef CONFIG_I2C_TRANSFER
+ int (*transfer)(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *msgs, int count);
+#endif
+};
+
+/* I2C transaction segment beginning with a START. A number of these can
+ * be transfered together to form an arbitrary sequence of write/read transfer
+ * to an I2C slave device.
+ */
+
+struct i2c_msg_s
+{
+ uint16_t addr; /* Slave address */
+ uint16_t flags; /* See I2C_M_* definitions */
+ uint8_t *buffer;
+ int length;
};
/* I2C private data. This structure only defines the initial fields of the