BeRTOS
Data Structures | Defines | Typedefs | Enumerations | Functions
flash25.h File Reference

Function library for serial Flash memory. More...

#include "cfg/cfg_flash25.h"
#include <cfg/compiler.h>
#include <io/kfile.h>

Go to the source code of this file.

Data Structures

struct  Flash25
 Flash25 KFile context structure. More...

Defines

#define KFT_FLASH25   MAKE_ID('F', 'L', '2', '5')
 ID for dataflash.
#define FLASH25_AT25F2048   1
 Memory definition.

Typedefs

typedef uint32_t flash25Addr_t
 Type definition for serial flash memory.

Enumerations

enum  Flash25Opcode {
  FLASH25_WREN = 0x6, FLASH25_WRDI = 0x4, FLASH25_RDSR = 0x5, FLASH25_WRSR = 0x1,
  FLASH25_READ = 0x3, FLASH25_PROGRAM = 0x2, FLASH25_SECTORE_ERASE = 0x52, FLASH25_CHIP_ERASE = 0x62,
  FLASH25_RDID = 0x15
}
 Serial flash opcode commands. More...
enum  Flash25Sector { FLASH25_SECT1 = 0x0, FLASH25_SECT2 = 0x10000, FLASH25_SECT3 = 0x20000, FLASH25_SECT4 = 0x30000 }
 Serial flash sector memory address. More...

Functions

Flash25FLASH25_CAST (KFile *fd)
 Convert + ASSERT from generic KFile to Flash25.
void flash25_init (Flash25 *fd, KFile *ch)
 Init data flash memory interface.
void flash25_chipErase (Flash25 *fd)
 Chip erase function.
void flash25_sectorErase (Flash25 *fd, Flash25Sector sector)
 Sector erase function.
bool flash25_test (KFile *channel)
 Test function for flash25.

Detailed Description

Function library for serial Flash memory.

Author:
Daniele Basile <asterix@develer.com>

Definition in file flash25.h.


Define Documentation

#define FLASH25_AT25F2048   1

Memory definition.

Note:
Below are defined valid serial flash memory support to this drive. Every time we call flash25_init() function we check if memory defined are right (see flash25.c form more detail).

Definition at line 92 of file flash25.h.


Enumeration Type Documentation

Serial flash opcode commands.

Enumerator:
FLASH25_WREN 

Set write enable latch.

FLASH25_WRDI 

Reset enable write latch.

FLASH25_RDSR 

Read status register.

FLASH25_WRSR 

Write status register.

FLASH25_READ 

Read data from memory array.

FLASH25_PROGRAM 

Program data into memory array.

FLASH25_SECTORE_ERASE 

Erase one sector in memory array.

FLASH25_CHIP_ERASE 

Erase all sector in memory array.

FLASH25_RDID 

Read Manufacturer and product ID.

Definition at line 111 of file flash25.h.

Serial flash sector memory address.

Enumerator:
FLASH25_SECT1 

Sector 1 (0x0 -0xFFFF)

FLASH25_SECT2 

Sector 2 (0x10000 -0x1FFFF)

FLASH25_SECT3 

Sector 3 (0x20000 -0x2FFFF)

FLASH25_SECT4 

Sector 4 (0x30000 -0x3FFFF)

Definition at line 130 of file flash25.h.


Function Documentation

void flash25_chipErase ( Flash25 fd)

Chip erase function.

Erase all sector of serial flash memory.

Note:
This operation could take a while.

Definition at line 337 of file flash25.c.

void flash25_sectorErase ( Flash25 fd,
Flash25Sector  sector 
)

Sector erase function.

Erase a select sector of serial flash memory.

Note:
A sector size is FLASH25_SECTOR_SIZE. This operation could take a while.

Definition at line 291 of file flash25.c.

bool flash25_test ( KFile channel)

Test function for flash25.

Note:
: This implentation use a SPI channel.

Definition at line 53 of file flash25_hwtest.c.