diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-28 15:01:43 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-28 15:01:43 +0000 |
commit | 82fb23b2cc78fade702316d00510efcf9d65954f (patch) | |
tree | a997a6f40b080a1e31890359dde9fc466e726221 /nuttx/include/nuttx/i2c.h | |
parent | b197eb1609652b2b766bb79caf00b23ef07eed40 (diff) | |
download | nuttx-82fb23b2cc78fade702316d00510efcf9d65954f.tar.gz nuttx-82fb23b2cc78fade702316d00510efcf9d65954f.tar.bz2 nuttx-82fb23b2cc78fade702316d00510efcf9d65954f.zip |
More changes from Uros
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3431 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include/nuttx/i2c.h')
-rw-r--r-- | nuttx/include/nuttx/i2c.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/nuttx/include/nuttx/i2c.h b/nuttx/include/nuttx/i2c.h index b4aadb709..379105fc6 100644 --- a/nuttx/include/nuttx/i2c.h +++ b/nuttx/include/nuttx/i2c.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/i2c.h * - * Copyright(C) 2009-2010 Gregory Nutt. All rights reserved. + * Copyright(C) 2009-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -109,13 +109,39 @@ * nbits - The number of address bits provided (7 or 10) * * Returned Value: - * Returns the actual frequency selected + * Returns OK on success; a negated errno on failure. * ****************************************************************************/ #define I2C_SETADDRESS(d,f,b) ((d)->ops->setaddress(d,f,b)) /**************************************************************************** + * Name: I2C_SETOWNADDRESS + * + * Description: + * Set our own I2C address. Calling this function enables Slave mode and + * disables Master mode on given instance (note that I2C is a bus, where + * multiple masters and slave may be handled by one device driver). + * + * One may register callback to be notifyed about reception. During the + * slave mode reception, the function READ and WRITE must be used to + * to handle reads and writes from a master. + * + * Input Parameters: + * dev - Device-specific state data + * address - Our own slave address; If it is 0x00, then the device driver + * listens to general call + * nbits - The number of address bits provided (7 or 10) + * + * Returned Value: + * OK on valid address and if the same address has not been assigned + * to other existance sharing the same port. Otherwise ERROR is returned. + * + ****************************************************************************/ + +#define I2C_SETOWNADDRESS(d,f,b) ((d)->ops->setownaddress(d,f,b)) + +/**************************************************************************** * Name: I2C_WRITE * * Description: @@ -192,9 +218,17 @@ struct i2c_ops_s 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_WRITEREAD + int (*writeread)(FAR struct i2c_dev_s *inst, const uint8_t *wbuffer, int wbuflen, + uint8_t *rbuffer, int rbuflen); +#endif #ifdef CONFIG_I2C_TRANSFER int (*transfer)(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *msgs, int count); #endif +#ifdef CONFIG_I2C_SLAVE + int (*setownaddress)(FAR struct i2c_dev_s *dev, int addr, int nbits); + int (*registercallback)(FAR struct i2c_dev_s *dev, int (*callback)(void) ); +#endif }; /* I2C transaction segment beginning with a START. A number of these can |