dataflash.h File Reference

Function library for dataflash AT45DB family. More...

#include <cfg/compiler.h>
#include <kern/kfile.h>
#include <fs/battfs.h>

Go to the source code of this file.

Data Structures

struct  DataFlash
 Dataflash KFile context structure. More...
struct  DataflashInfo
 Structure used to describe a dataflash memory. More...

Defines

#define KFT_DATAFLASH   MAKE_ID('D', 'F', 'L', 'H')
 ID for dataflash.
#define RESET_PULSE_WIDTH   10
 Width of reset pulse in usec.
#define BUSY_BIT   0x80
 Select a busy bit in status register.
#define CMP_BIT   0x40
 Select a compare bit in status register.
#define GET_ID_DESITY_DEVICE(reg_stat)   (((reg_stat) & 0x3C) >> 2)
 Select bits 2-5 of status register.

Typedefs

typedef enum DataflashType DataflashType
 Memory definitions.
typedef struct DataFlash DataFlash
 Dataflash KFile context structure.
typedef enum DataFlashOpcode DataFlashOpcode
 Data flash opcode commands.
typedef struct DataflashInfo DataflashInfo
 Structure used to describe a dataflash memory.

typedef uint32_t dataflash_page_t
 Type definitions for dflash memory.

Enumerations

enum  DataflashType
 

Memory definitions.

More...
enum  DataFlashOpcode {
  DFO_READ_FLASH_MEM_BYTE_D = 0x0B, DFO_READ_FLASH_MEM_BYTE_B = 0xE8, DFO_READ_FLASH_MEM = 0xD2, DFO_READ_BUFF1 = 0xD4,
  DFO_READ_BUFF2 = 0xD6, DFO_WRITE_BUFF1 = 0x84, DFO_WRITE_BUFF2 = 0x87, DFO_WRITE_BUFF1_TO_MEM_E = 0x83,
  DFO_WRITE_BUFF2_TO_MEM_E = 0x86, DFO_WRITE_BUFF1_TO_MEM = 0x88, DFO_WRITE_BUFF2_TO_MEM = 0x89, DFO_ERASE_PAGE = 0x81,
  DFO_ERASE_BLOCK = 0x50, DFO_ERASE_SECTOR = 0x7C, DFO_WRITE_MEM_TR_BUFF1 = 0x82, DFO_WRITE_MEM_TR_BUFF2 = 0x85,
  DFO_MOV_MEM_TO_BUFF1 = 0x53, DFO_MOV_MEM_TO_BUFF2 = 0x55, DFO_CMP_MEM_TO_BUFF1 = 0x60, DFO_CMP_MEM_TO_BUFF2 = 0x61,
  DFO_ARW_MEM_TR_BUFF1 = 0x58, DFO_ARW_MEM_TR_BUFF2 = 0x59, DFO_PWR_DOWN = 0xB9, DFO_RESUME_PWR_DOWN = 0xAB,
  DFO_READ_STATUS = 0xD7, DFO_ID_DEV = 0x9F
}
 

Data flash opcode commands.

More...

Functions

DataFlashDATAFLASH_CAST (KFile *fd)
 Convert + ASSERT from generic KFile to DataFlash.
bool dataflash_init (DataFlash *fd, KFile *ch, DataflashType type, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset)
 Dataflash init function.
int dataflash_testSetup (void)
 To test data falsh drive you could use this functions.
int dataflash_testRun (void)
 Run dataflash test memory.
int dataflash_testTearDown (void)
 End a dataflash Test.

Detailed Description

Function library for dataflash AT45DB family.

Version:
Id
dataflash.h 2541 2009-04-17 14:00:57Z batt
Author:
Daniele Basile <asterix@develer.com>

Definition in file dataflash.h.


Define Documentation

#define GET_ID_DESITY_DEVICE ( reg_stat   )     (((reg_stat) & 0x3C) >> 2)

Select bits 2-5 of status register.

These bits indicate device density (see datasheet for more details).

Definition at line 124 of file dataflash.h.


Typedef Documentation

Memory definitions.

List of supported memory devices by this drive. Every time we call dataflash_init() we check device id to ensure we choose the right memory configuration. (see dataflash.c for more details).


Enumeration Type Documentation

Data flash opcode commands.

Enumerator:
DFO_READ_FLASH_MEM_BYTE_D 

Dataflash read commands.

Continuos array read for D type memories.

DFO_READ_FLASH_MEM_BYTE_B 

Continuos array read for B type memories.

DFO_READ_FLASH_MEM 

Main memory page read.

DFO_READ_BUFF1 

SRAM buffer 1 read.

DFO_READ_BUFF2 

SRAM buffer 2 read.

DFO_WRITE_BUFF1 

Program and erase commands data flash.

SRAM buffer 1 write.

DFO_WRITE_BUFF2 

SRAM buffer 2 write.

DFO_WRITE_BUFF1_TO_MEM_E 

Buffer 1 to main memory page program with built-in erase.

DFO_WRITE_BUFF2_TO_MEM_E 

Buffer 2 to main memory page program with built-in erase.

DFO_WRITE_BUFF1_TO_MEM 

Buffer 1 to main memory page program without built-in erase.

DFO_WRITE_BUFF2_TO_MEM 

Buffer 2 to main memory page program without built-in erase.

DFO_ERASE_PAGE 

Erase page.

DFO_ERASE_BLOCK 

Erase block.

DFO_ERASE_SECTOR 

Erase sector.

DFO_WRITE_MEM_TR_BUFF1 

Write main memory page through buffer 1.

DFO_WRITE_MEM_TR_BUFF2 

Write main memory page through buffer 2.

DFO_MOV_MEM_TO_BUFF1 

Additional dataflash commands.

Transfer main mmemory to buffer 1.

DFO_MOV_MEM_TO_BUFF2 

Transfer main mmemory to buffer 2.

DFO_CMP_MEM_TO_BUFF1 

Compare main mmemory with buffer 1.

DFO_CMP_MEM_TO_BUFF2 

Compare main mmemory with buffer 2.

DFO_ARW_MEM_TR_BUFF1 

Auto page rewrite through buffer 1.

DFO_ARW_MEM_TR_BUFF2 

Auto page rewrite through buffer 2.

DFO_PWR_DOWN 

Deep power-down.

DFO_RESUME_PWR_DOWN 

Resume from deep power-down.

DFO_READ_STATUS 

Read status register.

DFO_ID_DEV 

Read manufacturer and device ID.

Definition at line 129 of file dataflash.h.

Memory definitions.

List of supported memory devices by this drive. Every time we call dataflash_init() we check device id to ensure we choose the right memory configuration. (see dataflash.c for more details).

Definition at line 77 of file dataflash.h.


Function Documentation

bool dataflash_init ( DataFlash fd,
KFile ch,
DataflashType  dev,
dataflash_setCS_t *  setCS,
dataflash_setReset_t *  setReset 
)

Dataflash init function.

This function initialize fd with SPI channel ch and test if data flash memory density is the same specified by device dev. setCS is a callback used to set/reset CS line. setReset is a callback used to set/reset the dataflash (can be NULL if reset is unconnected)

Returns:
true if ok, false if memory density read from dataflash is not compliant with the configured one.

Definition at line 545 of file dataflash.c.

int dataflash_testRun ( void   ) 

Run dataflash test memory.

Definition at line 171 of file dataflash_hwtest.c.

int dataflash_testSetup ( void   ) 

To test data falsh drive you could use this functions.

To use these functions make sure to include in your make file the drv/datafalsh_test.c source.

(see drv/datafalsh_test.c for more detail)

Definition at line 111 of file dataflash_hwtest.c.

int dataflash_testTearDown ( void   ) 

End a dataflash Test.

(Unused)

Definition at line 193 of file dataflash_hwtest.c.