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: AT24C1024 mbed-rtos mbed
Diff: main.cpp
- Revision:
- 0:61561880f5ea
- Child:
- 1:c671dcf90b11
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Nov 25 05:08:33 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "AT24C1024.h"
+
+I2C i2c(D14, D15); // SDA, SCL
+AT24C1024 at24c1024(i2c); // Atmel 1Mbit EE-PROM
+
+DigitalOut led1(LED1);
+
+int main()
+{
+ printf("\r\n*** AT24C1024 Test ***\r\n");
+ uint8_t dt = 0x55;
+
+ printf("Byte Write: %02x\r\n", dt);
+ at24c1024.write(0, dt); // write addr=0 data=dt
+ wait_ms(5);
+ dt = at24c1024.read(0); // read addr=0
+ printf("Byte Read: %02x\r\n", dt);
+
+ uint32_t addr = 0;
+ while(1) {
+ uint8_t data = addr & 0xff;
+ at24c1024.write(addr, data);
+ wait_ms(5);
+ uint8_t rdata = at24c1024.read(addr);
+ if (data != rdata) {
+ printf("error: addr:%u data:%u rdata:%u\r\n", addr, data, rdata);
+ }
+ addr++;
+ if (addr == 0x1ffff) {
+ addr = 0;
+ }
+ }
+}