diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-04-04 20:27:37 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-04-04 20:27:37 +0000 |
commit | 256f0e1d7c705832b7cefe68dca56056b1855301 (patch) | |
tree | b3df27748a29c6490f351d57bf5d5ab7ae3c77fd /nuttx/include | |
parent | d1cad1a8405df91cd4d18c474e8994c445735973 (diff) | |
download | px4-nuttx-256f0e1d7c705832b7cefe68dca56056b1855301.tar.gz px4-nuttx-256f0e1d7c705832b7cefe68dca56056b1855301.tar.bz2 px4-nuttx-256f0e1d7c705832b7cefe68dca56056b1855301.zip |
Add eZ80 I2C driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1679 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/i2c.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/nuttx/include/nuttx/i2c.h b/nuttx/include/nuttx/i2c.h index 96c3bf735..e44684cbd 100644 --- a/nuttx/include/nuttx/i2c.h +++ b/nuttx/include/nuttx/i2c.h @@ -47,10 +47,28 @@ * Definitions ****************************************************************************/ -/* I2C address calculation. Convert 7-bit address to 8-bit read/write address */ +/* I2C address calculation. Convert 7- and 10-bit address to 8-bit and + * 16-bit read/write address + */ + +#define I2C_READBIT 0x01 + +/* Conver 7- to 8-bit address */ + +#define I2C_ADDR8(a) ((a) << 1) +#define I2C_WRITEADDR8(a) I2C_ADDR8(a) +#define I2C_READADDR8(a) (I2C_ADDR8(a) | I2C_READBIT) + +/* Convert 10- to 16-bit address */ + +#define I2C_ADDR10H(a) (0xf0 | (((a) >> 7) & 0x06)) +#define I2C_ADDR10L(a) ((a) & 0xff) + +#define I2C_WRITEADDR10H(a) I2C_ADDR10H(a) +#define I2C_WRITEADDR10L(a) I2C_ADDR10L(a) -#define I2C_READADDR(a) (((a) << 1) | 1) -#define I2C_WRITEADDR(a) ((a) << 1) +#define I2C_READADDR10H(a) (I2C_ADDR10H(a) | I2C_READBIT) +#define I2C_READADDR10L(a) I2C_ADDR10L(a) /* Access macros */ @@ -82,13 +100,14 @@ * Input Parameters: * dev - Device-specific state data * address - The I2C slave address + * nbits - The number of address bits provided (7 or 10) * * Returned Value: * Returns the actual frequency selected * ****************************************************************************/ -#define I2C_SETADDRESS(d,f) ((d)->ops->setaddress(d,f)) +#define I2C_SETADDRESS(d,f,b) ((d)->ops->setaddress(d,f,b)) /**************************************************************************** * Name: I2C_WRITE @@ -142,7 +161,7 @@ struct i2c_dev_s; struct i2c_ops_s { uint32 (*setfrequency)(FAR struct i2c_dev_s *dev, uint32 frequency); - int (*setaddress)(FAR struct i2c_dev_s *dev, int addr); + int (*setaddress)(FAR struct i2c_dev_s *dev, int addr, int nbits); int (*write)(FAR struct i2c_dev_s *dev, const ubyte *buffer, int buflen); int (*read)(FAR struct i2c_dev_s *dev, ubyte *buffer, int buflen); }; |