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.
Dependencies: lib_i2c_slave_block
Revision 3:0288d257446a, committed 2019-02-03
- Comitter:
- Wayne Roberts
- Date:
- Sun Feb 03 16:56:15 2019 -0800
- Parent:
- 2:d7e05c75f240
- Commit message:
- indicate errors if reported by i2c
Changed in this revision
--- a/cmds.h Mon Jan 21 18:09:05 2019 -0800
+++ b/cmds.h Sun Feb 03 16:56:15 2019 -0800
@@ -5,6 +5,10 @@
#define CMD_IRQ 0x03
#define CMD_BUFFER 0x04
+#define CMD_TIMEOUT 0xfd // indication of smbus timeout
+#define CMD_ARLO 0xfe // indication of arbitration lost
+#define CMD_BUSERR 0xff // indication of start or stop during transfer
+
typedef union {
struct __attribute__((packed)) {
struct {
--- a/lib_i2c_slave_block.lib Mon Jan 21 18:09:05 2019 -0800 +++ b/lib_i2c_slave_block.lib Sun Feb 03 16:56:15 2019 -0800 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/dudmuck/code/lib_i2c_slave_block/#914409dc83b1 +https://os.mbed.com/users/dudmuck/code/lib_i2c_slave_block/#7ab789db70da
--- a/main.cpp Mon Jan 21 18:09:05 2019 -0800
+++ b/main.cpp Sun Feb 03 16:56:15 2019 -0800
@@ -1,7 +1,6 @@
#include <mbed.h>
#include "smbus.h"
-#include "cmds.h"
#define IRQ_OUT_PIN D6
@@ -70,6 +69,16 @@
case CMD_BUFFER:
memcpy(test_buf, req, sizeof(test_buf));
break;
+ /* failures: */
+ case CMD_BUSERR:
+ pc.printf("BUSERR%u\r\n", req[0]);
+ break;
+ case CMD_ARLO:
+ pc.printf("ARLO%u\r\n", req[0]); // req[0] tx_cndtr
+ break;
+ case CMD_TIMEOUT:
+ pc.printf("TIMEOUT%u\r\n", req[0]); // req[0] tx_cndtr
+ break;
default:
pc.printf("??%02x??\r\n", cmd);
break;
@@ -85,7 +94,7 @@
pc.baud(115200);
pc.printf("\r\nreset\r\n");
- res = smbus_init(SLAVE_ADDRESS);
+ res = smbus_init(I2C_SDA, I2C_SCL, SLAVE_ADDRESS);
pc.printf("%d = smbus_init()\r\n", res);
but = button.read();