Nut/OS  5.0.5
API Reference
XgUFlash

Data Structures

struct  _BLOCK_USAGE
 Internal block usage cache structure. More...
struct  _BLOCKHEAD
 UFLASH block header. More...
struct  _BLOCKFOOT
 UFLASH block footer. More...
struct  _ENTRYHEAD
struct  _UFLASHENTRY
 File system entry descriptor. More...
struct  _UFLASHVOLUME
 Volume info structure. More...
struct  _UFLASHFIND
 Entry search structure. More...

Defines

#define UFLASH_MAX_BLOCKS   8192
 Max. number of blocks per file system.
#define UFLASH_BLOCK_UNITS   4
 Number of units per block.
#define UFLASH_ENTRIES   128
 Number of file system entries.
#define UFLASH_USAGE_CACHE   32
 Size of the least used buffer.
#define UFLASH_MAX_PATH   0
 Maximum lenght of a full absolute path.
#define UFLASH_BLOCK_INVALID   ((blknum_t)-1)
#define UFLASH_VOLF_FIXED   0x80

Typedefs

typedef uint16_t blknum_t
typedef uint_fast16_t blknum_fast_t
typedef struct _BLOCK_USAGE BLOCK_USAGE
 Internal block usage cache structure.
typedef struct _BLOCKHEAD BLOCKHEAD
 UFLASH block header.
typedef struct _BLOCKFOOT BLOCKFOOT
 UFLASH block footer.
typedef struct _ENTRYHEAD ENTRYHEAD
typedef struct _UFLASHENTRY UFLASHENTRY
 File system entry descriptor.
typedef struct _UFLASHVOLUME UFLASHVOLUME
 Volume info structure type.
typedef struct _UFLASHFIND UFLASHFIND
 Entry search structure.

Functions

int UFlashAttach (NUTDEVICE *dev, NUTSERIALFLASH *sfi, NUTSPIBUS *bus)
 Attach an UFLASH file system to a serial flash device.
void UFlashDetach (NUTDEVICE *dev)
 Detach an UFLASH file system from a serial flash device.
int UFlashFormat (NUTDEVICE *dev, NUTSERIALFLASH *sfi, NUTSPIBUS *bus)
 Format an UFLASH volume.

Variables

NUTDEVICE devUFlash0
 UFLASH0 file system device.
NUTDEVICE devUFlash1
 UFLASH1 file system device.

Define Documentation

#define UFLASH_MAX_BLOCKS   8192

Max. number of blocks per file system.

Referenced by UFlashFormat().

#define UFLASH_BLOCK_UNITS   4

Number of units per block.

Referenced by UFlashFormat().

#define UFLASH_ENTRIES   128

Number of file system entries.

#define UFLASH_USAGE_CACHE   32

Size of the least used buffer.

#define UFLASH_MAX_PATH   0

Maximum lenght of a full absolute path.

If not defined, a variable path name length is used. Note, that the total size of the name is still limited, because the block header and the entry header must fit into the first unit of the file system block.

#define UFLASH_BLOCK_INVALID   ((blknum_t)-1)
#define UFLASH_VOLF_FIXED   0x80

Typedef Documentation

typedef uint16_t blknum_t
typedef struct _BLOCK_USAGE BLOCK_USAGE

Internal block usage cache structure.

typedef struct _BLOCKHEAD BLOCKHEAD

UFLASH block header.

Each used block starts with a BLOCKHEAD structure.

typedef struct _BLOCKFOOT BLOCKFOOT

UFLASH block footer.

Each block ends with a BLOCKFOOT structure.

typedef struct _ENTRYHEAD ENTRYHEAD
typedef struct _UFLASHENTRY UFLASHENTRY

File system entry descriptor.

typedef struct _UFLASHVOLUME UFLASHVOLUME

Volume info structure type.

typedef struct _UFLASHFIND UFLASHFIND

Entry search structure.


Function Documentation

int UFlashAttach ( NUTDEVICE dev,
NUTSERIALFLASH sfi,
NUTSPIBUS bus 
)

Attach an UFLASH file system to a serial flash device.

This function will initialize the hardware and mount the volume.

Parameters:
devSpecifies the file system device.
sfiSpecifies the serial flash interface.
busSpecifies the SPI bus driver.
Returns:
0 on success, -1 on errors.

References _NUTSPIBUS::bus_initnode, _NUTSPIBUS::bus_mutex, _NUTDEVICE::dev_icb, _NUTSPINODE::node_bus, NULL, NUTASSERT, NutEventPost(), _NUTSERIALFLASH::sf_init, and _NUTSERIALFLASH::sf_node.

Here is the call graph for this function:

void UFlashDetach ( NUTDEVICE dev)

Detach an UFLASH file system from a serial flash device.

This function will unmount the volume and release all occupied resources.

Parameters:
devSpecifies the file system device.
Returns:
0 on success, -1 on errors.

References _NUTDEVICE::dev_icb, NULL, NUTASSERT, and _NUTSERIALFLASH::sf_exit.

int UFlashFormat ( NUTDEVICE dev,
NUTSERIALFLASH sfi,
NUTSPIBUS bus 
)

Format an UFLASH volume.

Formatting an UFLASH volume is easy: All blocks are simply erased. Therefore, formatting is required only to remove existing contents, which is incompatible with the current format options. The caller must make sure, that the volume is not mounted.

Parameters:
devSpecifies the file system device.
sfiSpecifies the serial flash interface.
busSpecifies the SPI bus driver.
Returns:
0 on success, -1 on errors.

References _NUTSPIBUS::bus_initnode, _NUTSPIBUS::bus_mutex, _NUTDEVICE::dev_dcb, _NUTSPINODE::node_bus, NULL, NUTASSERT, NutEventPost(), rc, _NUTSERIALFLASH::sf_exit, _NUTSERIALFLASH::sf_init, _NUTSERIALFLASH::sf_node, _NUTSERIALFLASH::sf_rsvbot, _NUTSERIALFLASH::sf_rsvtop, _NUTSERIALFLASH::sf_units, UFLASH_BLOCK_UNITS, and UFLASH_MAX_BLOCKS.

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    0,                          
    {'U', 'F', 'L', 'A', 'S', 'H', '0', 0, 0}
    ,                           
    IFTYP_FS,                   
    0,                          
    0,                          
    NULL,                       
    NULL,                       
    UFlashInit,                 
    UFlashIOCtl,                
    UFlashFileRead,             
    UFlashFileWrite,            

    UFlashFileWrite_P,          

    UFlashFileOpen,             
    UFlashFileClose,            
    UFlashFileSize              
}

UFLASH0 file system device.

Initial value:
 {
    0,                          
    {'U', 'F', 'L', 'A', 'S', 'H', '1', 0, 0}
    ,                           
    IFTYP_FS,                   
    1,                          
    0,                          
    NULL,                       
    NULL,                       
    UFlashInit,                 
    UFlashIOCtl,                
    UFlashFileRead,             
    UFlashFileWrite,            

    UFlashFileWrite_P,          

    UFlashFileOpen,             
    UFlashFileClose,            
    UFlashFileSize              
}

UFLASH1 file system device.