spi_flash.h File Reference

SPI Flash Driver complaint with FAT-FS System. More...

#include <stdint.h>
#include <stdbool.h>
#include "diskioStructs.h"
Include dependency graph for spi_flash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

DSTATUS flash_initialize ()
 
DRESULT flash_read_sectors (unsigned char *pData, int sectorNum, int sectorCount)
 
DRESULT flash_write_sectors (unsigned char *pData, int sectorNum, int sectorCount)
 
DRESULT flash_ioctl (BYTE ctrl, void *buff)
 
void flash_write_permanent_id (char *id_64bytes)
 
void flash_read_permanent_id (char *id_64bytes)
 
void flash_chip_erase (void)
 
uint32_t flash_get_page_count (void)
 
uint32_t flash_get_page_size (void)
 
bool flash_supports_metadata (void)
 
uint32_t flash_get_page_write_count (uint32_t page_number)
 

Detailed Description

SPI Flash Driver complaint with FAT-FS System.

Function Documentation

void flash_chip_erase ( void  )

This will ERASE the entire chip, including the meta-data!! This can take several seconds to perform the chip erase...

uint32_t flash_get_page_count ( void  )

Flash memory metadata functions If the flash memory contains additional space for each page, then each time a page is written, we also write its write-counter value. You can then retrieve the page write count values by the page number.

uint32_t flash_get_page_size ( void  )
uint32_t flash_get_page_write_count ( uint32_t  page_number)
Warning
DO NOT USE THIS FUNCTION WITHOUT THE SPI SEMAPHORE!!!
DSTATUS flash_initialize ( )

Initializes the Flash Memory

DRESULT flash_ioctl ( BYTE  ctrl,
void *  buff 
)

Gets control information from this flash memory drive, such as sector count, sector size

Parameters
ctrlThe type of information to get
buffThe pointer to save the requested information to
void flash_read_permanent_id ( char *  id_64bytes)

Reads the permanent ID programmed into the SPI flash

Warning
DO NOT USE THIS FUNCTION WITHOUT THE SPI SEMAPHORE!!!
DRESULT flash_read_sectors ( unsigned char *  pData,
int  sectorNum,
int  sectorCount 
)

Reads a sector from the Flash Memory

Parameters
pDataThe pointer to the data to save the read
sectorNumThe sector number to read with each sector being 512 bytes
sectorCountThe number of sectors to read
bool flash_supports_metadata ( void  )
void flash_write_permanent_id ( char *  id_64bytes)

Writes a permanent ID on the SPI Flash

Warning
THIS CAN ONLY BE DONE ONCE IN A LIFETIME OF THE SPI FLASH
DO NOT USE THIS FUNCTION WITHOUT THE SPI SEMAPHORE!!!
DRESULT flash_write_sectors ( unsigned char *  pData,
int  sectorNum,
int  sectorCount 
)

Writes a sector to the Flash Memory

Parameters
pDataThe pointer to the data to write
sectorNumThe sector number to write with each sector being 512 bytes
sectorCountThe number of sectors to write