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.
Revision 1:b7e586fffbf2, committed 2014-07-12
- Comitter:
- jaerts
- Date:
- Sat Jul 12 15:26:34 2014 +0000
- Parent:
- 0:f94c714b3b4d
- Commit message:
- Update example code
Changed in this revision
| I2CSlaveX.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/I2CSlaveX.h Sat Jul 12 15:09:06 2014 +0000
+++ b/I2CSlaveX.h Sat Jul 12 15:26:34 2014 +0000
@@ -7,9 +7,46 @@
/** An I2C Slave, used for communicating with an I2C Master device with support for Interrupts and multiple slave addresses
*
+ * Warning: Currently only somewhat tested with LPC1347. This should be concidered a proof of concept. Ideally this would
+ * be merged into the original I2CSlave library.
+ *
* Example:
* @code
- * TBD EXAMPLE
+ * // Simple Simulated I2C Read-Only EEPROM
+ * #include <mbed.h>
+ * #include "I2CSlaveX.h"
+ *
+ * I2CSlaveX slave(p9, p10);
+ *
+ * uint8_t eeprom_data[16] = {0);
+ * uint8_t eeprom_addr = 0;
+ *
+ * void receive_handler() {
+ * char addr;
+ * int i = slave.receive(&addr);
+ * switch (i) {
+ * case I2CSlave::ReadAddressed:
+ * slave.write(&eeprom_data[eeprom_addr], 1);
+ * printf("Write @ %02X [%02X] : %02X\n", addr, eeprom_addr, eeprom_data[eeprom_addr]);
+ * break;
+ * case I2CSlave::WriteAddressed:
+ * slave.read(&eeprom_addr, 1);
+ * printf("Read @ %02X [%02X]\n", addr, eeprom_addr);
+ * break;
+ * }
+ * }
+ *
+ * int main() {
+ * slave.address(0xA0, 0);
+ * slave.address(0x30, 1);
+ * slave.attach(&receive_handler);
+ *
+ * while(1) {
+ * printf("Nothing to do really...");
+ * eeprom_data[0]++;
+ * wait(1);
+ * }
+ * }
* @endcode
*/
class I2CSlaveX : public I2CSlave