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:
- 0:81685bb49271
- Child:
- 1:2651ad0f52c0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 23 09:25:26 2018 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +Serial pc(USBTX, USBRX); +I2C i2c(D14, D15); + +// main() runs in its own thread in the OS +int main() { + char buf[10]; + buf[0] = 0; + pc.printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); + for (int adrs = 0; adrs < 0x80; adrs += 16) { + pc.printf("%02x: ", adrs); + for (int i = 0; i < 16; i++) { + i2c.write(((adrs + i) << 1), buf, 1); + int ret = i2c.read(((adrs + i) << 1), buf, 2); + if ((adrs+i) == 0 || (adrs+i) == 1 || (adrs+i) == 2) { + pc.printf(" "); + continue; + } + if ((adrs+i) >= 0x78) { + pc.printf("\n"); + break; + } + if (ret == 1) { + pc.printf("-- "); + } + if (ret == 0) { + pc.printf("%02x ", (adrs + i)); + } + } + pc.printf("\n"); + } + + while (true) { + led1 = !led1; + wait(0.5); + } +} +