ported for ff-lpc546xx

Dependencies:   AT45

/media/uploads/gorazdko/capture111.png

Files at this revision

API Documentation at this revision

Comitter:
maclobdell
Date:
Tue Nov 14 14:58:48 2017 +0000
Child:
1:1f267b9c975a
Commit message:
Very simple example application that extracts details from AT45 SPI Flash and writes/reads a string to it.

Changed in this revision

AT45.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AT45.lib	Tue Nov 14 14:58:48 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/maclobdell/code/AT45/#f8e562ae5cc3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 14 14:58:48 2017 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+#include "AT45.h"
+
+/* Tested on FRDM-KW24D512 */
+
+SPI spi(D11, D12, D13); 
+AT45 spif(&spi, D10);
+
+DigitalOut myled(LED1);
+
+int main() {
+
+    printf("spif test\n\r");
+  
+    printf("spif size: %d bytes\n\r",         spif.device_size());
+    printf("spif page erase size: %d bytes\n\r",    spif.pagesize());
+    printf("spif pages: %d\n\r",    spif.pages());
+    printf("spif block erase size: 4096 bytes\n\r");
+    printf("spif blocks: %d\n\r", spif.blocks());
+    printf("id: %d\n\r",   spif.id());
+
+    int pagesize = spif.pagesize();
+    
+    // Write "Hello World!" to a block
+    char *buffer = (char*) malloc(pagesize);
+    sprintf(buffer, "Hello World!\n");
+    spif.page_erase(3);
+    spif.write_page(buffer, 3);
+
+    char *buffer2 = (char*) malloc(pagesize);
+    // Read back what was stored
+    spif.read_page(buffer2, 3);
+
+    printf("%s", buffer2);
+
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+                
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Nov 14 14:58:48 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/armmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a