fs.h File Reference

File System. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _fsFILE
 
struct  REGIS
 
struct  UNIT
 

Macros

#define FSMARK   0xDADA
 
#define BOOTSECTOR   0x0000
 
#define FSFM_OFF   0x0000
 Format mark. More...
 
#define FSDT_OFF   0x0002
 date time More...
 
#define FSTZ_OFF   0x000A
 Time zone. More...
 
#define FSDN_OFF   0x000E
 Device number. More...
 
#define FSOK   0
 
#define FSNOSPACE   1
 
#define FSINVALID   2
 
#define FSNOTFOUND   3
 
#define FSNOCHIP   4
 
#define FSEOF   5
 
#define FSAPPEND   1
 
#define FSRW   0
 
#define FSEXIST   2
 
#define FSSET   0
 
#define FSCUR   1
 
#define FSEND   2
 
#define REGSPA   1
 
#define DEFMAXREGIS   (REGSPA+500)
 
#define UNITSPA   (DEFMAXREGIS)
 
#define DEFMAXUNIT   (UNITSPA+11)
 
#define BADPAGE   0xAA
 
#define REGCRL_OFF   258
 
#define UNICRL_OFF   261
 
#define U_ENABLE   0x80
 
#define U_DISABLE   0x00
 
#define DBREGIS   1
 
#define DBUNIT   2
 

Typedefs

typedef _fsFILEfsFILE
 

Functions

BYTE FS_Init (void)
 
void FS_Format (void)
 
BYTE FS_Open (BYTE file)
 
BYTE FS_Close (BYTE file)
 
BYTE FS_AppendRegis (REGIS *data)
 
BYTE FS_AppendUnit (UNIT *data)
 
void FS_ZapRegis (void)
 
BYTE FS_ReadRegis (REGIS *data)
 
BYTE FS_WriteUnit (UNIT *data)
 
BYTE FS_ReadUnit (UNIT *data)
 
void FS_SetBoot (WORD Offset, BYTE *data, BYTE size)
 
void FS_GetBoot (WORD Offset, BYTE *data, BYTE size)
 
void FS_Check (void)
 
void FS_Length (BYTE file, WORD *p)
 
void FS_WaitReady (void)
 

Variables

bank3 WORD gRcp
 
bank3 WORD gRnor
 
bank3 WORD gRcb
 
bank3 WORD gUcp
 
bank3 WORD gUnor
 
bank3 WORD gUcb
 

Detailed Description

File System.

This file is part of JADEKU Portable ADQ device for Routines Control.

Copyright (C) 2006-2009, Hernan Monserrat hemonserrat<at>gmail<dot>com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file fs.h.

Macro Definition Documentation

◆ BADPAGE

#define BADPAGE   0xAA

Definition at line 61 of file fs.h.

◆ BOOTSECTOR

#define BOOTSECTOR   0x0000

a file mark 3Fxx where xx is the file number.

Definition at line 33 of file fs.h.

◆ DBREGIS

#define DBREGIS   1

Definition at line 89 of file fs.h.

◆ DBUNIT

#define DBUNIT   2

Definition at line 90 of file fs.h.

◆ DEFMAXREGIS

#define DEFMAXREGIS   (REGSPA+500)

Definition at line 58 of file fs.h.

◆ DEFMAXUNIT

#define DEFMAXUNIT   (UNITSPA+11)

Definition at line 60 of file fs.h.

◆ FSAPPEND

#define FSAPPEND   1

Definition at line 47 of file fs.h.

◆ FSCUR

#define FSCUR   1

Definition at line 52 of file fs.h.

◆ FSDN_OFF

#define FSDN_OFF   0x000E

Device number.

Definition at line 38 of file fs.h.

◆ FSDT_OFF

#define FSDT_OFF   0x0002

date time

Definition at line 36 of file fs.h.

◆ FSEND

#define FSEND   2

Definition at line 53 of file fs.h.

◆ FSEOF

#define FSEOF   5

Definition at line 45 of file fs.h.

◆ FSEXIST

#define FSEXIST   2

Definition at line 49 of file fs.h.

◆ FSFM_OFF

#define FSFM_OFF   0x0000

Format mark.

Definition at line 35 of file fs.h.

◆ FSINVALID

#define FSINVALID   2

Definition at line 42 of file fs.h.

◆ FSMARK

#define FSMARK   0xDADA

First mark of file system

Definition at line 29 of file fs.h.

◆ FSNOCHIP

#define FSNOCHIP   4

Definition at line 44 of file fs.h.

◆ FSNOSPACE

#define FSNOSPACE   1

Definition at line 41 of file fs.h.

◆ FSNOTFOUND

#define FSNOTFOUND   3

Definition at line 43 of file fs.h.

◆ FSOK

#define FSOK   0

Definition at line 40 of file fs.h.

◆ FSRW

#define FSRW   0

Definition at line 48 of file fs.h.

◆ FSSET

#define FSSET   0

Definition at line 51 of file fs.h.

◆ FSTZ_OFF

#define FSTZ_OFF   0x000A

Time zone.

Definition at line 37 of file fs.h.

◆ REGCRL_OFF

#define REGCRL_OFF   258

Definition at line 62 of file fs.h.

◆ REGSPA

#define REGSPA   1

Definition at line 57 of file fs.h.

◆ U_DISABLE

#define U_DISABLE   0x00

Definition at line 87 of file fs.h.

◆ U_ENABLE

#define U_ENABLE   0x80

Definition at line 86 of file fs.h.

◆ UNICRL_OFF

#define UNICRL_OFF   261

Definition at line 63 of file fs.h.

◆ UNITSPA

#define UNITSPA   (DEFMAXREGIS)

Definition at line 59 of file fs.h.

Typedef Documentation

◆ fsFILE

typedef _fsFILE* fsFILE

Definition at line 74 of file fs.h.

Function Documentation

◆ FS_AppendRegis()

BYTE FS_AppendRegis ( REGIS data)

Append data to the REGIS stream.

Parameters
data- buffer to extract data.
Returns
FSOK, FSEOF

Definition at line 324 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_AppendUnit()

BYTE FS_AppendUnit ( UNIT data)

Append data to the UNIT stream.

Parameters
data- buffer to extract data.
Returns
FSOK, FSEOF

Definition at line 392 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_Check()

void FS_Check ( void  )

Periodic function to check and health the file system structure.

Remarks
Use algorithm 2 from Serial data flash devices.

Definition at line 54 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_Close()

BYTE FS_Close ( BYTE  file)

Close the given stream.

Parameters
file- stream descriptor pointer.
Returns
FSOK FSNOTFOUND

Definition at line 228 of file fs.c.

Here is the caller graph for this function:

◆ FS_Format()

void FS_Format ( void  )

Initialize and formats the storage device

Parameters
nops- Number of pages for files.

Definition at line 143 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_GetBoot()

void FS_GetBoot ( WORD  Offset,
BYTE data,
BYTE  size 
)

Get boot sector information

Parameters
Offset- from buffer
data- buffer to store data
size- number of bytes to read
Remarks
Use Buffer 1 to mirror.

Definition at line 132 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_Init()

BYTE FS_Init ( void  )

Function prototypes

Initialize file system

Returns
FSOK
FSNOCHIP
Remarks
if no valid boot sector found then formats

Definition at line 72 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_Length()

void FS_Length ( BYTE  file,
WORD p 
)

Return the number of records in the stream

Parameters
file- stream descriptor pointer.
p- pointer to a word

Definition at line 246 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_Open()

BYTE FS_Open ( BYTE  file)

Open a file stream

Parameters
file- stream descriptor pointer.
Returns
FSOK

Definition at line 204 of file fs.c.

Here is the caller graph for this function:

◆ FS_ReadRegis()

BYTE FS_ReadRegis ( REGIS data)

Read a number of bytes from the REGIS stream

Parameters
data- buffer to store data.
Returns
FSOK FSEOF

Definition at line 364 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_ReadUnit()

BYTE FS_ReadUnit ( UNIT data)

Read a number of bytes from the UNIT stream

Parameters
data- buffer to store data.
Returns
FSOK FSEOF

Definition at line 454 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_SetBoot()

void FS_SetBoot ( WORD  Offset,
BYTE data,
BYTE  size 
)

Sets boot sector information

Parameters
Offset- from buffer
data- buffer to extract data
size- number of bytes to write
Remarks
Use buffer 1 to mirror.

Definition at line 107 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_WaitReady()

void FS_WaitReady ( void  )

POLL Flash status device to see if ready

Remarks
Need to implement a timeout, now if fails, blocks for ever.

Definition at line 42 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_WriteUnit()

BYTE FS_WriteUnit ( UNIT data)

Write data to the UNIT stream.

Parameters
data- buffer to extract data.
Returns
FSOK, FSEOF

Definition at line 428 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FS_ZapRegis()

void FS_ZapRegis ( void  )

Deletes records on REGIS stream

Definition at line 295 of file fs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gRcb

bank3 WORD gRcb

Definition at line 27 of file fs.c.

◆ gRcp

bank3 WORD gRcp

Definition at line 25 of file fs.c.

◆ gRnor

bank3 WORD gRnor

Definition at line 26 of file fs.c.

◆ gUcb

bank3 WORD gUcb

Definition at line 30 of file fs.c.

◆ gUcp

bank3 WORD gUcp

Definition at line 28 of file fs.c.

◆ gUnor

bank3 WORD gUnor

Definition at line 29 of file fs.c.