Norimasa Okamoto / USBLocalFileSystem

Dependencies:   USBDevice

Dependents:   KL46Z-lpc81isp lpcterm2

Embed: (wiki syntax)

« Back to documentation index

USBLocalFileSystem Class Reference

USBLocalFileSystem Class Reference

Access the LocalFileSystem using RamDisk(64KB) More...

#include <USBLocalFileSystem.h>

Public Member Functions

 USBLocalFileSystem (const char *name="local")
 Create the Local File System using RamDisk(64KB)
 USBLocalFileSystem (PinName mosi, PinName miso, PinName sclk, PinName cs, const char *name="local")
 Create the Local File System for accessing an SD Card using SPI.
 USBLocalFileSystem (StorageInterface *storage, const char *name="local")
 Create the Local File System using StorageInterface.
int readable ()
 Determine if there is a character available to read.
int writeable ()
 Determine if there is space available to write a character.
int getc ()
 Read a char from the serial port.
int putc (int c)
 Write a char to the serial port.
int puts (const char *str)
 Write a string to the serial port.

Detailed Description

Access the LocalFileSystem using RamDisk(64KB)

 #include "USBLocalFileSystem.h"

 int main() {
     USBLocalFileSystem* usb_local = new USBLocalFileSystem(); // RamDisk(64KB) 

     FILE *fp = fopen("/local/mbed.txt", "a");
     fprintf(fp, "Hello World!\n");
     fclose(fp);
 }

Definition at line 18 of file USBLocalFileSystem.h.


Constructor & Destructor Documentation

USBLocalFileSystem ( const char *  name = "local" )

Create the Local File System using RamDisk(64KB)

Parameters:
nameThe name used to access the virtual filesystem

Definition at line 6 of file USBLocalFileSystem.cpp.

USBLocalFileSystem ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
const char *  name = "local" 
)

Create the Local File System for accessing an SD Card using SPI.

Parameters:
mosiSPI mosi pin connected to SD Card
misoSPI miso pin conencted to SD Card
sclkSPI sclk pin connected to SD Card
csDigitalOut pin used as SD Card chip select
nameThe name used to access the virtual filesystem

Definition at line 12 of file USBLocalFileSystem.cpp.

USBLocalFileSystem ( StorageInterface *  storage,
const char *  name = "local" 
)

Create the Local File System using StorageInterface.

Parameters:
storageStorageInterface
nameThe name used to access the virtual filesystem

Definition at line 19 of file USBLocalFileSystem.cpp.


Member Function Documentation

int getc (  )

Read a char from the serial port.

Returns:
The char read from the serial port

Definition at line 60 of file USBLocalFileSystem.cpp.

int putc ( int  c )

Write a char to the serial port.

Parameters:
cThe char to write
Returns:
The written char or -1 if an error occured

Definition at line 65 of file USBLocalFileSystem.cpp.

int puts ( const char *  str )

Write a string to the serial port.

Parameters:
strThe string to write
Returns:
0 if the write succeeds, EOF for error

Definition at line 71 of file USBLocalFileSystem.cpp.

int readable (  )

Determine if there is a character available to read.

Returns:
1 if there is a character available to read, 0 otherwise

Definition at line 50 of file USBLocalFileSystem.cpp.

int writeable (  )

Determine if there is space available to write a character.

Returns:
1 if there is space to write a character, 0 otherwise

Definition at line 55 of file USBLocalFileSystem.cpp.