Simple test program for the W25X40BV API. The library files can be found in the next column or [[http://mbed.org/users/jyam/libraries/W25X40BV/m73pwt|here]].

Dependencies:   mbed

main.cpp

Committer:
jyam
Date:
2012-03-19
Revision:
1:78c4315e6114
Parent:
0:0da0b91683f8

File content as of revision 1:78c4315e6114:

#include "mbed.h"
#include"W25X40BV.h"

Serial pc(USBTX, USBRX); // tx, rx

int main() {
    W25X40BV flash(p5, p6, p7, p8);
    pc.printf("SPI init done\n");
   
    flash.chipErase();
    pc.printf("Erase done\n");
    
    pc.printf("%d\n", flash.readByte(0x00,0x00,0x06));
    pc.printf("%d\n", flash.readByte(0x06));
   
    flash.writeByte(0x0, 0x0, 0x06,'a');
    flash.writeByte(0x11,'b');
   
    pc.printf("%c\n", flash.readByte(0x06));
    pc.printf("%c\n", flash.readByte(0x00,0x00,0x06));
    
    pc.printf("%c\n", flash.readByte(0x11));
    pc.printf("%c\n", flash.readByte(0x00,0x00,0x11));
    
    char string[] = "Hello World";
    flash.write(0x168, string, 11);
    
    char str[11];
    flash.read(0x168, str, 11);
    pc.printf("%s\n",str); 
    
    return 0;
}