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.
Diff: main.cpp
- Revision:
- 3:01b322df3731
- Parent:
- 2:49bb6ee1191c
- Child:
- 4:f537311ddc53
--- a/main.cpp Mon Oct 13 14:34:40 2014 +0000
+++ b/main.cpp Mon Oct 13 14:50:01 2014 +0000
@@ -9,7 +9,7 @@
const int I2C_FREQUENCY = 100000;
const int I2C_BUFFER_SIZE = 10;
-enum COMMAND { PUSH, PULL, CLEAR };
+enum COMMAND { PUSH, PULL, CLEAR, PRINT };
int memory[MEMORY_SIZE];
@@ -19,7 +19,17 @@
void initializeMemory(void)
{
for (int i = 0; i < MEMORY_SIZE; i++) {
- memory[i] = 0x55;
+ memory[i] = -1;
+ }
+}
+
+/*
+ * Print current memory content
+ */
+void printMemory(void)
+{
+ for (int i = 0; i < MEMORY_SIZE; i++) {
+ pc.printf("%d@0x%x\r\n", memory[i], i);
}
}
@@ -39,6 +49,7 @@
// Make sure memory buffer is zeroed
initializeMemory();
+ printMemory();
// I2C buffer
char buffer[I2C_BUFFER_SIZE];
@@ -68,6 +79,10 @@
}
break;
+ case PRINT:
+ printMemory();
+ break;
+
default:
pc.printf("Unknown command byte\r\n");
}