BeRTOS
|
Function library for dataflash AT45DB family (implementation). More...
#include "dataflash.h"
#include "cfg/cfg_dataflash.h"
#include <cfg/macros.h>
#include <cfg/debug.h>
#include <cfg/module.h>
#include <cfg/log.h>
#include <drv/timer.h>
#include <fs/battfs.h>
#include <io/kfile.h>
#include <cpu/power.h>
#include <string.h>
Go to the source code of this file.
Functions | |
void | CS_TOGGLE (DataFlash *fd) |
Macro that toggle CS of dataflash. | |
static void | send_cmd (DataFlash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode) |
Send a generic command to dataflash memory. | |
static void | dataflash_reset (DataFlash *fd) |
Reset dataflash memory function. | |
static uint8_t | dataflash_stat (DataFlash *fd) |
Read status register of dataflah memory. | |
static uint8_t | dataflash_cmd (DataFlash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode) |
Send one command to data flash memory, and return status register value. | |
static void | dataflash_readBlock (DataFlash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, uint8_t *block, dataflash_size_t len) |
Read len bytes from main data flash memory or buffer data flash memory, and put it in *block. | |
static void | dataflash_writeBlock (DataFlash *fd, dataflash_offset_t offset, const uint8_t *block, dataflash_size_t len) |
Write len bytes in dataflash memory buffer. | |
static void | dataflash_loadPage (DataFlash *fd, dataflash_page_t page_addr) |
Load selected page from dataflash memory to buffer. | |
static int | dataflash_flush (KFile *_fd) |
Flush select page (stored in buffer) in data flash main memory page. | |
static int | dataflash_close (struct KFile *_fd) |
Close file fd. | |
static KFile * | dataflash_reopen (KFile *_fd) |
Reopen dataflash file fd. | |
static size_t | dataflash_read (struct KFile *_fd, void *buf, size_t size) |
Read in buf size bytes from dataflash memmory. | |
static size_t | dataflash_write (struct KFile *_fd, const void *_buf, size_t size) |
Write _buf in dataflash memory. | |
bool | dataflash_init (DataFlash *fd, KFile *ch, DataflashType dev, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset) |
Dataflash init function. | |
Variables | |
static const DataflashInfo | mem_info [] |
Array used to describe dataflash memory devices currently supported. |
Function library for dataflash AT45DB family (implementation).
Definition in file dataflash.c.
void CS_TOGGLE | ( | DataFlash * | fd | ) | [inline] |
Macro that toggle CS of dataflash.
Definition at line 106 of file dataflash.c.
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)
Definition at line 545 of file dataflash.c.
static size_t dataflash_read | ( | struct KFile * | _fd, |
void * | buf, | ||
size_t | size | ||
) | [static] |
Read in buf size bytes from dataflash memmory.
Definition at line 429 of file dataflash.c.
static void dataflash_reset | ( | DataFlash * | fd | ) | [static] |
Reset dataflash memory function.
If fd->setReset function is not NULL, this function resets data flash memory with one pulse reset long about 10usec.
Definition at line 166 of file dataflash.c.
static size_t dataflash_write | ( | struct KFile * | _fd, |
const void * | _buf, | ||
size_t | size | ||
) | [static] |
Write _buf in dataflash memory.
Definition at line 479 of file dataflash.c.
static void dataflash_writeBlock | ( | DataFlash * | fd, |
dataflash_offset_t | offset, | ||
const uint8_t * | block, | ||
dataflash_size_t | len | ||
) | [static] |
Write len bytes in dataflash memory buffer.
Definition at line 258 of file dataflash.c.
static void send_cmd | ( | DataFlash * | fd, |
dataflash_page_t | page_addr, | ||
dataflash_offset_t | byte_addr, | ||
DataFlashOpcode | opcode | ||
) | [static] |
Send a generic command to dataflash memory.
This function send only 4 byte: opcode, page address and byte address.
Definition at line 117 of file dataflash.c.