Nut/OS  5.0.5
API Reference
at25df.c File Reference
#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>
Include dependency graph for at25df.c:

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 Documentation

#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

Function Documentation

int At25dfInit ( NUTDEVICE dev)

Initialize dataflash at specified interface and chip select.

Parameters:
spibasInterface base address. For ARM MCUs this may be the I/O base address of the hardware SPI.
spipcsDevice chip select.
Returns:
Device descriptor or -1 in case of an error.

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 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 
)

Variable Documentation

Initial value:
 {
    {12, 2048, 4096, 0x48}, 
}

Parameter table of known DataFlash types.

Number of known Dataflash types.

Referenced by At25dfInit().

Initial value:
 {
    NULL,   
    NULL,   
    1000000,
    0,  
    8,  
    0   
}