a simple test program against eeprom class
Fork of ou_mbed_eeprom by
Diff: main.cpp
- Revision:
- 0:ae0174689639
- Child:
- 2:47ee605d0830
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 15 23:05:58 2018 +0000 @@ -0,0 +1,64 @@ +#include "mbed.h" +#include "eeprom.h" + +DigitalOut myled(LED2); + +// for LPCXpresso LPC1114 board +// UART TX: xp9, dp16 +// UART RX: xp10, dp15 +// ************************************* +// ** serial port: 9600, 8, N, 1, N +// ************************************* +//Serial pc(xp9, xp10); +I2C i2c(dp5, dp27); +eeprom epm(i2c); + +int main() { + myled = 1; + printf("LPC1114 demo \r\n"); + i2c.frequency(1000 * 1000); + + uint8_t data[13] = { 0, 0, 0, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5}; + + epm.page_write(12288, TWO_BYTES_ADDRESS, data, 10); + //wait(0.008); + epm.ack_polling(); + + epm.write_address(12288, TWO_BYTES_ADDRESS); + + for (int i=0; i< 64; i++) { + printf("%.2x ", epm.current_read()); + } + printf("\n\r"); + + epm.write_address(13312, TWO_BYTES_ADDRESS); + + uint8_t buffer[64]; + epm.sequential_read(buffer, 64); + for (int i=0; i<64; i++) { + printf("%.2x ", buffer[i]); + } + printf("\n\r"); + + epm.random_read(12288, TWO_BYTES_ADDRESS, buffer, 64); + for (int i=0; i<64; i++) { + printf("%.2x ", buffer[i]); + } + printf("\n\r"); + + myled = 0; + + while (1); +/* + while(1) { + myled = 1; + printf("led on\n"); + for (int i=0; i<10000; i++); + //wait(1); + myled = 0; + printf("led off\n"); + for (int i=0; i<10000; i++); + //wait(1); + } + */ +}