Nut/OS  5.0.5
API Reference
XgSpiNodeAt45d

Data Structures

struct  _AT45D_DCB

Defines

#define SPI_RATE_AT45D0   33000000
#define SPI_MODE_AT45D0   SPI_MODE_3
#define SPI_RATE_AT45D1   33000000
#define SPI_MODE_AT45D1   SPI_MODE_3
#define SPI_RATE_AT45D2   33000000
#define SPI_MODE_AT45D2   SPI_MODE_3
#define SPI_RATE_AT45D3   33000000
#define SPI_MODE_AT45D3   SPI_MODE_3

Typedefs

typedef struct _AT45D_DCB AT45D_DCB

Functions

int At45dNodeLock (NUTSPINODE *node)
void At45dNodeUnlock (NUTSPINODE *node)
int At45dNodeTransfer (NUTSPINODE *node, uint8_t op, uint32_t parm, uint_fast8_t oplen, const void *txbuf, void *rxbuf, int xlen)
 Execute DataFlash command with data transfer.
int At45dNodeCommand (NUTSPINODE *node, uint8_t op, uint32_t parm, uint_fast8_t oplen)
 Execute DataFlash command without data.
uint8_t At45dNodeStatus (NUTSPINODE *node)
 Query the status of the serial flash.
int At45dNodeWaitReady (NUTSPINODE *node, uint32_t tmo, int poll)
 Wait until DataFlash memory cycle finished.
AT45D_INFOAt45dNodeProbe (NUTSPINODE *node)
 Determine the DataFlash type.

Variables

NUTSPINODE nodeAt45d0
 First AT45D DataFlash SPI node implementation structure.
NUTSPINODE nodeAt45d1
 Second AT45D DataFlash SPI node implementation structure.
NUTSPINODE nodeAt45d2
 Third AT45D DataFlash SPI node implementation structure.
NUTSPINODE nodeAt45d3
 Forth AT45D DataFlash SPI node implementation structure.

Define Documentation

#define SPI_RATE_AT45D0   33000000
#define SPI_MODE_AT45D0   SPI_MODE_3
#define SPI_RATE_AT45D1   33000000
#define SPI_MODE_AT45D1   SPI_MODE_3
#define SPI_RATE_AT45D2   33000000
#define SPI_MODE_AT45D2   SPI_MODE_3
#define SPI_RATE_AT45D3   33000000
#define SPI_MODE_AT45D3   SPI_MODE_3

Typedef Documentation

typedef struct _AT45D_DCB AT45D_DCB

Function Documentation

int At45dNodeLock ( NUTSPINODE node)

References _AT45D_DCB::dcb_lock, _NUTSPINODE::node_dcb, NUT_WAIT_INFINITE, and NutEventWait().

Here is the call graph for this function:

void At45dNodeUnlock ( NUTSPINODE node)

References _AT45D_DCB::dcb_lock, _NUTSPINODE::node_dcb, and NutEventPost().

Here is the call graph for this function:

int At45dNodeTransfer ( NUTSPINODE node,
uint8_t  op,
uint32_t  parm,
uint_fast8_t  oplen,
const void *  txbuf,
void *  rxbuf,
int  xlen 
)

Execute DataFlash command with data transfer.

Parameters:
nodeSpecifies the SPI node.
opCommand code.
parmCommand parameter.
oplenCommand length.
txbufPointer to the transmit data buffer, may be set to NULL.
rxbufPointer to the receive data buffer, may be set to NULL.
xlenNumber of byte to receive and/or transmit.
Returns:
0 on success, -1 on errors.

References _NUTSPIBUS::bus_alloc, _NUTSPIBUS::bus_release, _NUTSPIBUS::bus_transfer, _NUTSPINODE::node_bus, NULL, NUTASSERT, and rc.

Referenced by At45dNodeCommand().

int At45dNodeCommand ( NUTSPINODE node,
uint8_t  op,
uint32_t  parm,
uint_fast8_t  oplen 
)

Execute DataFlash command without data.

Parameters:
nodeSpecifies the SPI node.
opCommand operation code.
parmOptional command parameter.
oplenCommand length.
Returns:
0 on success, -1 on errors.

References At45dNodeTransfer(), and NULL.

Here is the call graph for this function:

uint8_t At45dNodeStatus ( NUTSPINODE node)

Query the status of the serial flash.

Parameters:
nodeSpecifies the SPI node.
Returns:
0 on success or -1 in case of an error.

References _NUTSPIBUS::bus_alloc, _NUTSPIBUS::bus_release, _NUTSPIBUS::bus_transfer, _NUTSPIBUS::bus_wait, DFCMD_READ_STATUS, _NUTSPINODE::node_bus, NULL, NUT_WAIT_INFINITE, NUTASSERT, and rc.

Referenced by At45dNodeProbe(), and At45dNodeWaitReady().

int At45dNodeWaitReady ( NUTSPINODE node,
uint32_t  tmo,
int  poll 
)

Wait until DataFlash memory cycle finished.

Parameters:
nodeSpecifies the SPI node.
tmoNumber of loops (or milliseconds) to wait at max.
pollIf 0, the current thread will be suspended for 1 millisecond between each retry. Otherwise the polling loop will not sleep, but may be still suspended by the lower level SPI bus driver.
Returns:
0 on success or -1 in case of an error.

References At45dNodeStatus(), and NutSleep().

Referenced by At45dNodeProbe().

Here is the call graph for this function:

AT45D_INFO* At45dNodeProbe ( NUTSPINODE node)

Determine the DataFlash type.

If the board contains a known DataFlash chip, but couldn't be determined by this routine, then most probably the chip select configuration is wrong.

Parameters:
nodeSpecifies the SPI node.
Returns:
Pointer to a AT45D_INFO structure, which contains the relevant DataFlash parameters. If no known DataFlash is available, then NULL is returned.

References at45d_info, at45d_known_types, AT45D_STATUS_DENSITY, AT45D_STATUS_PAGE_SIZE, At45dNodeStatus(), At45dNodeWaitReady(), and NULL.

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    NULL,                       
    NULL,                       
    SPI_RATE_AT45D0,            
    SPI_MODE_AT45D0,            
    8,                          
    0,                          
    &dcbAt45d0                  
}

First AT45D DataFlash SPI node implementation structure.

Initial value:
 {
    NULL,                       
    NULL,                       
    SPI_RATE_AT45D1,            
    SPI_MODE_AT45D1,            
    8,                          
    0,                          
    &dcbAt45d1                  
}

Second AT45D DataFlash SPI node implementation structure.

Initial value:
 {
    NULL,                       
    NULL,                       
    SPI_RATE_AT45D2,            
    SPI_MODE_AT45D2,            
    8,                          
    0,                          
    &dcbAt45d2                  
}

Third AT45D DataFlash SPI node implementation structure.

Initial value:
 {
    NULL,                       
    NULL,                       
    SPI_RATE_AT45D3,            
    SPI_MODE_AT45D3,            
    8,                          
    0,                          
    &dcbAt45d3                  
}

Forth AT45D DataFlash SPI node implementation structure.