LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Filesystem Glue logic for reading http files

Detailed Description

The lwIP Filesystem implementation module implements the file system functions required for FAT file system. The webserver uses this function to fetch the files from the appropriate device.

Data Structures

struct  fs_file
 

Macros

#define LWIP_HTTPD_CUSTOM_FILES   0
 
#define LWIP_HTTPD_FILE_STATE   0
 
#define HTTPD_PRECALCULATED_CHECKSUM   0
 

Functions

int GetHTTP_Header (const char *fName, char *buff)
 Get HTTP header function.
 
int fs_init (void)
 Initialize the filesystem and device on it.
 
struct fs_filefs_open_default (void)
 Open default HTTP file function.
 
struct fs_filefs_open (const char *name)
 Open a file from the Filesystem function The function will open the file present on the file system.
 
void fs_close (struct fs_file *file)
 Closes/Frees a previously opened file function The function will close the file & free the resources.
 
int fs_read (struct fs_file *file, char *buffer, int count)
 This reads the requested number of bytes from the file function The function will read the specified number of bytes from the file.
 
int fs_bytes_left (struct fs_file *file)
 Get number of bytes yet to be read in a file function The function will return the number bytes yet to be read from the file.
 

Macro Definition Documentation

#define HTTPD_PRECALCULATED_CHECKSUM   0

HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for predefined (MSS-sized) chunks of the files to prevent having to calculate the checksums at runtime.

Definition at line 67 of file lwip_fs.h.

#define LWIP_HTTPD_CUSTOM_FILES   0

Set this to 1 and provide the functions:

  • "int fs_open_custom(struct fs_file *file, const char *name)" Called first for every opened file to allow opening files that are not included in fsdata(_custom).c
  • "void fs_close_custom(struct fs_file *file)" Called to free resources allocated by fs_open_custom().

Definition at line 53 of file lwip_fs.h.

#define LWIP_HTTPD_FILE_STATE   0

Set this to 1 to include an application state argument per file that is opened. This allows to keep a state per connection/file.

Definition at line 60 of file lwip_fs.h.

Function Documentation

static void App_SDMMC_Init ( )
static

Definition at line 301 of file lwip_fs.c.

int fs_bytes_left ( struct fs_file file)

Get number of bytes yet to be read in a file function The function will return the number bytes yet to be read from the file.

Parameters
file: Pointer to File structure of opened file
Returns
Number of byets yet to be read from the file

Get number of bytes yet to be read in a file function The function will return the number bytes yet to be read from the file.

Parameters
file: Pointer to File structure of opened file
Returns
Number of byets yet to be read from the file The function will return the number bytes yet to be read from the file.

Definition at line 356 of file lwip_fs.c.

void fs_close ( struct fs_file file)

Closes/Frees a previously opened file function The function will close the file & free the resources.

Parameters
file: Pointer to File structure of opened file
Returns
None

Closes/Frees a previously opened file function The function will close the file & free the resources.

Parameters
file: Pointer to File structure of opened file
Returns
None The function will close the file & free the resources.

Definition at line 331 of file lwip_fs.c.

int fs_init ( void  )

Initialize the filesystem and device on it.

Returns
0 on success non-Zero on failure

Definition at line 326 of file lwip_fs.c.

struct fs_file* fs_open ( const char *  name)
read

Open a file from the Filesystem function The function will open the file present on the file system.

Parameters
name: Name of the file to be opened
Returns
Pointer to File structure on success NULL on failure

Open a file from the Filesystem function The function will open the file present on the file system.

Parameters
name: Name of the file to be opened
Returns
Pointer to File structure on success NULL on failure The function will open the file present on the file system.

Definition at line 278 of file lwip_fs.c.

struct fs_file* fs_open_default ( void  )
read

Open default HTTP file function.

Returns
Pointer to File structure of default file on success NULL on failure
Note
The function will open the default file. The default file will have the HTTP content pointed by http_index_html variable. This function will be called if the HTTP files are not present in the file system.
Returns
Pointer to File structure of default file on success NULL on failure The function will open the default file. The default file will have the HTTP content pointed by http_index_html variable. This function will be called if the HTTP files are not present in the file system.

Definition at line 253 of file lwip_fs.c.

int fs_read ( struct fs_file file,
char *  buffer,
int  count 
)

This reads the requested number of bytes from the file function The function will read the specified number of bytes from the file.

Parameters
file: Pointer to File structure of opened file
buffer: pointer to memroy, where the data be stored
count: Number of bytes to be read from the file
Returns
Number of bytes successfully read

This reads the requested number of bytes from the file function The function will read the specified number of bytes from the file.

Parameters
file: Pointer to File structure of opened file
buffer: pointer to memroy, where the data be stored
count: Number of bytes to be read from the file
Returns
Number of bytes successfully read The function will read the specified number of bytes from the file.

Definition at line 345 of file lwip_fs.c.

static int get_http_headers ( const char *  fName,
char *  buff 
)
static

Generate the relevant HTTP headers for the given filename and write them into the supplied buffer.

Definition at line 176 of file lwip_fs.c.

int GetHTTP_Header ( const char *  fName,
char *  buff 
)

Get HTTP header function.

Parameters
fName: Filename for which the header be generated
buff: buffer to which the generated header be copied
Returns
Number of bytes in header
Note
The function will read the HTTP header from the file & returns with No. of bytes read
Parameters
fName: Filename for which the header be generated
buff: buffer to which the generated header be copied
Returns
Number of bytes in header The function will read the HTTP header from the file & returns with No. of bytes read

Definition at line 247 of file lwip_fs.c.

static int mutex_init ( void  )
static

Definition at line 159 of file lwip_fs.c.

static int mutex_lock ( int *  mx)
static

Definition at line 153 of file lwip_fs.c.

static void mutex_unlock ( int *  mx)
static

Definition at line 166 of file lwip_fs.c.

void SDIO_IRQHandler ( void  )

SDIO controller interrupt handler.

Returns
Nothing

Definition at line 455 of file lwip_fs.c.

static uint32_t sdmmc_irq_driven_wait ( void  )
static

A better wait callback for SDMMC driven by the IRQ flag.

Returns
0 on success, or failure condition (-1)

Definition at line 287 of file lwip_fs.c.

static void sdmmc_setup_wakeup ( void *  bits)
static

Sets up the SD event driven wakeup.

Parameters
bits: Status bits to poll for command completion
Returns
Nothing

Definition at line 273 of file lwip_fs.c.

static void sdmmc_waitms ( uint32_t  time)
static

Definition at line 249 of file lwip_fs.c.

Variable Documentation

FATFS Fatfs
static

Definition at line 60 of file lwip_fs.c.

const char http_index_html[]
static
Initial value:
=
"<html><head><title>Congrats!</title></head>"
"<body><h1>Welcome to our lwIP HTTP server!</h1>"
"<p>This is a small test page, served by httpd of "
"lwip.</p></body></html>"

Definition at line 54 of file lwip_fs.c.

int open_lock
static

Definition at line 151 of file lwip_fs.c.

mci_card_struct sdcardinfo

Type used for SD Card handle

Definition at line 75 of file lwip_fs.c.

volatile int32_t sdio_wait_exit = 0
static

Definition at line 69 of file lwip_fs.c.