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 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 | |
| DataFlash * | DATAFLASH_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
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.
Enumeration Type Documentation
| enum DataFlashOpcode |
Data flash opcode commands.
- Enumerator:
Definition at line 129 of file dataflash.h.
| enum DataflashType |
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 | ) |
| 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 | ) |
