* Macro that toggle CS of dataflash.
* \note This is equivalent to fd->setCS(false) immediately followed by fd->setCS(true).
*/
-INLINE void CS_TOGGLE(KFileDataflash *fd)
+INLINE void CS_TOGGLE(DataFlashKFile *fd)
{
fd->setCS(false);
fd->setCS(true);
* This function send only 4 byte: opcode, page address and
* byte address.
*/
-static void send_cmd(KFileDataflash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode)
+static void send_cmd(DataFlashKFile *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode)
{
/*
* with one pulse reset long about 10usec.
*
*/
-static void dataflash_reset(KFileDataflash *fd)
+static void dataflash_reset(DataFlashKFile *fd)
{
fd->setCS(false);
/**
* Read status register of dataflah memory.
*/
-static uint8_t dataflash_stat(KFileDataflash *fd)
+static uint8_t dataflash_stat(DataFlashKFile *fd)
{
/*
* Make sure to toggle CS signal
* return status register value.
*
*/
-static uint8_t dataflash_cmd(KFileDataflash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode)
+static uint8_t dataflash_cmd(DataFlashKFile *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode)
{
uint8_t stat;
* Read \a len bytes from main data flash memory or buffer data
* flash memory, and put it in \a *block.
*/
-static void dataflash_readBlock(KFileDataflash *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode, uint8_t *block, dataflash_size_t len)
+static void dataflash_readBlock(DataFlashKFile *fd, dataflash_page_t page_addr, dataflash_offset_t byte_addr, DataFlashOpcode opcode, uint8_t *block, dataflash_size_t len)
{
send_cmd(fd, page_addr, byte_addr, opcode);
* To perform a write in main memory you must first write in dataflash buffer
* memory and then send a command to write the page in main memory.
*/
-static void dataflash_writeBlock(KFileDataflash *fd, dataflash_offset_t offset, DataFlashOpcode opcode, const uint8_t *block, dataflash_size_t len)
+static void dataflash_writeBlock(DataFlashKFile *fd, dataflash_offset_t offset, DataFlashOpcode opcode, const uint8_t *block, dataflash_size_t len)
{
ASSERT(offset + len <= mem_info[fd->dev].page_size);
/**
* Load selct page from dataflash memory to buffer.
*/
-static void dataflash_loadPage(KFileDataflash *fd, dataflash_page_t page_addr)
+static void dataflash_loadPage(DataFlashKFile *fd, dataflash_page_t page_addr)
{
dataflash_cmd(fd, page_addr, 0x00, DFO_MOV_MEM_TO_BUFF1);
}
*/
static int dataflash_flush(KFile *_fd)
{
- KFileDataflash *fd = KFILEDATAFLASH(_fd);
+ DataFlashKFile *fd = DATAFLASHKFILE(_fd);
if (fd->page_dirty)
{
dataflash_cmd(fd, fd->current_page, 0x00, DFO_WRITE_BUFF1_TO_MEM_E);
*/
static KFile *dataflash_reopen(KFile *_fd)
{
- KFileDataflash *fd = KFILEDATAFLASH(_fd);
+ DataFlashKFile *fd = DATAFLASHKFILE(_fd);
dataflash_close(_fd);
fd->current_page = 0;
*/
static size_t dataflash_read(struct KFile *_fd, void *buf, size_t size)
{
- KFileDataflash *fd = KFILEDATAFLASH(_fd);
+ DataFlashKFile *fd = DATAFLASHKFILE(_fd);
dataflash_offset_t byte_addr;
dataflash_page_t page_addr;
*/
static size_t dataflash_write(struct KFile *_fd, const void *_buf, size_t size)
{
- KFileDataflash *fd = KFILEDATAFLASH(_fd);
+ DataFlashKFile *fd = DATAFLASHKFILE(_fd);
dataflash_offset_t offset;
dataflash_page_t new_page;
* \return true if ok, false if memory density read from dataflash is not compliant with the
* configured one.
*/
-bool dataflash_init(KFileDataflash *fd, KFile *ch, DataflashType dev, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset)
+bool dataflash_init(DataFlashKFile *fd, KFile *ch, DataflashType dev, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset)
{
uint8_t stat;
/**
* Dataflash KFile context structure.
*/
-typedef struct KFileDataflash
+typedef struct DataFlashKFile
{
KFile fd; ///< File descriptor.
KFile *channel; ///< Dataflash comm channel (usually SPI).
bool page_dirty; ///< True if current_page is dirty (needs to be flushed).
dataflash_setReset_t *setReset; ///< Callback used to set reset pin of dataflash.
dataflash_setCS_t *setCS; ///< Callback used to set CS pin of dataflash.
-} KFileDataflash;
+} DataFlashKFile;
/**
* ID for dataflash.
#define KFT_DATAFLASH MAKE_ID('D', 'F', 'L', 'H')
/**
- * Convert + ASSERT from generic KFile to KFileDataflash.
+ * Convert + ASSERT from generic KFile to DataFlashKFile.
*/
-INLINE KFileDataflash * KFILEDATAFLASH(KFile *fd)
+INLINE DataFlashKFile * DATAFLASHKFILE(KFile *fd)
{
ASSERT(fd->_type == KFT_DATAFLASH);
- return (KFileDataflash *)fd;
+ return (DataFlashKFile *)fd;
}
#define RESET_PULSE_WIDTH 10 ///< Width of reset pulse in usec.
} DataflashInfo;
-bool dataflash_init(KFileDataflash *fd, KFile *ch, DataflashType type, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset);
+bool dataflash_init(DataFlashKFile *fd, KFile *ch, DataflashType type, dataflash_setCS_t *setCS, dataflash_setReset_t *setReset);
/**
* To test data falsh drive you could use