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.
main.cpp
00001 #include "mbed.h" 00002 00003 #include "AT45.h" 00004 00005 /* Tested on FRDM-KW24D512 */ 00006 00007 SPI spi(D11, D12, D13); 00008 AT45 spif(&spi, D10); 00009 00010 DigitalOut myled(LED1); 00011 00012 int main() { 00013 00014 printf("spif test\n\r"); 00015 00016 printf("spif size: %d bytes\n\r", spif.device_size()); 00017 printf("spif page erase size: %d bytes\n\r", spif.pagesize()); 00018 printf("spif pages: %d\n\r", spif.pages()); 00019 printf("spif block erase size: 4096 bytes\n\r"); 00020 printf("spif blocks: %d\n\r", spif.blocks()); 00021 printf("id: %d\n\r", spif.id()); 00022 00023 int pagesize = spif.pagesize(); 00024 00025 // Write "Hello World!" to a block 00026 char *buffer = (char*) malloc(pagesize); 00027 sprintf(buffer, "Hello World!\n"); 00028 spif.page_erase(3); 00029 spif.write_page(buffer, 3); 00030 00031 char *buffer2 = (char*) malloc(pagesize); 00032 // Read back what was stored 00033 spif.read_page(buffer2, 3); 00034 00035 printf("%s", buffer2); 00036 00037 while(1) { 00038 myled = 1; 00039 wait(0.2); 00040 myled = 0; 00041 wait(0.2); 00042 00043 } 00044 }
Generated on Sun Jul 17 2022 19:33:09 by
1.7.2