#include <cfg/os.h>
#include <cfg/memory.h>
#include <sys/timer.h>
#include <string.h>
#include <stdlib.h>
#include <dev/at25df.h>
#include <dev/blockdev.h>
#include <dev/spibus.h>
#include <sys/nutdebug.h>
Defines | |
#define | MAX_AT25_CMDLEN 6 |
#define | AT25_ERASE_WAIT 3000 |
#define | AT25_CHIP_ERASE_WAIT 50000 |
#define | AT25_WRITE_POLLS 1000 |
#define | MOUNT_OFFSET_AT45D0 0 |
#define | MOUNT_TOP_RESERVE_AT45D0 0 |
Functions | |
int | At25dfInit (NUTDEVICE *dev) |
Initialize dataflash at specified interface and chip select. | |
int | SpiAt25PageRead (NUTDEVICE *dev, uint32_t pgn, void *data, int len) |
int | SpiAt25PageWrite (NUTDEVICE *dev, uint32_t pgn, const void *data, int len) |
int | SpiAt25PageWrite_P (NUTDEVICE *dev, uint32_t pgn, PGM_P data, int len) |
int | SpiAt25IOCtl (NUTDEVICE *dev, int req, void *conf) |
Variables | |
AT25D_INFO | at25d_info [] |
Parameter table of known DataFlash types. | |
uint_fast8_t | at25d_known_types = sizeof(at25d_info) / sizeof(AT25D_INFO) |
Number of known Dataflash types. | |
NUTSPINODE | at25df |
NUTDEVICE | devDataFlash0 |
AT25 DataFlash Commands | |
#define | DFCMD_READ_PAGE 0x0B |
Continuos read (high frequency). | |
#define | DFCMD_BLOCK_ERASE_4K 0x20 |
Block erase 4k. | |
#define | DFCMD_BLOCK_ERASE_32K 0x52 |
Block erase 32k. | |
#define | DFCMD_BLOCK_ERASE_64K 0xd8 |
Block erase 64k. | |
#define | DFCMD_CHIP_ERASE 0xC7 |
Chip erase. | |
#define | DFCMD_WRITE 0x02 |
Write bytes/page. | |
#define | DFCMD_READ_STATUS 0x05 |
Read status register. | |
#define | DFCMD_READ_DEVICEID 0x9F |
#define | DFCMD_WRITE_ENABLE 0x06 |
#define | DFCMD_WRITE_DISABLE 0x04 |
#define MAX_AT25_CMDLEN 6 |
#define AT25_ERASE_WAIT 3000 |
#define AT25_CHIP_ERASE_WAIT 50000 |
#define AT25_WRITE_POLLS 1000 |
Referenced by SpiAt25PageWrite().
#define DFCMD_READ_PAGE 0x0B |
Continuos read (high frequency).
Reads a continous stream in high speed mode.
Referenced by SpiAt25PageRead().
#define DFCMD_BLOCK_ERASE_4K 0x20 |
Block erase 4k.
Referenced by SpiAt25PageWrite().
#define DFCMD_BLOCK_ERASE_32K 0x52 |
Block erase 32k.
#define DFCMD_BLOCK_ERASE_64K 0xd8 |
Block erase 64k.
#define DFCMD_CHIP_ERASE 0xC7 |
Chip erase.
#define DFCMD_WRITE 0x02 |
Write bytes/page.
Referenced by SpiAt25PageWrite().
#define DFCMD_READ_STATUS 0x05 |
Read status register.
#define DFCMD_READ_DEVICEID 0x9F |
#define DFCMD_WRITE_ENABLE 0x06 |
Referenced by SpiAt25PageWrite().
#define DFCMD_WRITE_DISABLE 0x04 |
#define MOUNT_OFFSET_AT45D0 0 |
#define MOUNT_TOP_RESERVE_AT45D0 0 |
int At25dfInit | ( | NUTDEVICE * | dev | ) |
Initialize dataflash at specified interface and chip select.
spibas | Interface base address. For ARM MCUs this may be the I/O base address of the hardware SPI. |
spipcs | Device chip select. |
References at25d_known_types, _AT25D_INFO::at25d_pages, _AT25D_INFO::at25d_psize, _NUTBLOCKIO::blkio_blk_cnt, _NUTBLOCKIO::blkio_blk_siz, _NUTBLOCKIO::blkio_info, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, NULL, and NUTASSERT.
int SpiAt25IOCtl | ( | NUTDEVICE * | dev, |
int | req, | ||
void * | conf | ||
) |
References NULL, NUTASSERT, NUTBLKDEV_MEDIAAVAIL, NUTBLKDEV_MEDIACHANGE, and rc.
{ {12, 2048, 4096, 0x48}, }
Parameter table of known DataFlash types.
uint_fast8_t at25d_known_types = sizeof(at25d_info) / sizeof(AT25D_INFO) |
Number of known Dataflash types.
Referenced by At25dfInit().
{ 0, {'a', 't', '2', '5', 'd', 'f', '0', 0, 0}, IFTYP_BLKIO, 0, 0, &at25df, &blkIoAt25df, At25dfInit, NutBlockDeviceIOCtl, NutBlockDeviceRead, NutBlockDeviceWrite, NutBlockDeviceWrite_P, NutBlockDeviceOpen, NutBlockDeviceClose, NutBlockDeviceSize }