You are viewing an older revision! See the latest version

W25X40BV

Table of Contents

  1. API

The is a simple read/write API for the Winbond W25X40BV SPI Flash IC (datasheet).

The W25X40BV IC is one of the few commercially available SPI Flash ICs that comes in DIP packaging, ideal for those hobbyists who want to prototype flash memory without dealing with surface mount devices (SMD). This IC can be purchased from digikey.

This simple API does not utilize the performance benefits of the dual I/O SPI functionality provided by the IC.

You can import the this published library at W25X40BV API.

API

Public Member Functions

/media/uploads/jyam/windbond_spi_flash_api.png

Example usage

#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;
}


All wikipages