MMEx with SPI Slave to allow legacy devices to communicate with modern media such as USB, SD cards, the internet and all of the mbed\'s other interfaces

Dependencies:   NetServices MSCUsbHost mbed TMP102 SDFileSystem

Committer:
DeMein
Date:
Sun Feb 27 18:54:40 2011 +0000
Revision:
0:67a55a82ce06
Version as submitted to the NXP Design Challenge

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DeMein 0:67a55a82ce06 1 /* MMEx for MBED - File I/O Command processing
DeMein 0:67a55a82ce06 2 * Copyright (c) 2011 MK
DeMein 0:67a55a82ce06 3 *
DeMein 0:67a55a82ce06 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
DeMein 0:67a55a82ce06 5 * of this software and associated documentation files (the "Software"), to deal
DeMein 0:67a55a82ce06 6 * in the Software without restriction, including without limitation the rights
DeMein 0:67a55a82ce06 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
DeMein 0:67a55a82ce06 8 * copies of the Software, and to permit persons to whom the Software is
DeMein 0:67a55a82ce06 9 * furnished to do so, subject to the following conditions:
DeMein 0:67a55a82ce06 10 *
DeMein 0:67a55a82ce06 11 * The above copyright notice and this permission notice shall be included in
DeMein 0:67a55a82ce06 12 * all copies or substantial portions of the Software.
DeMein 0:67a55a82ce06 13 *
DeMein 0:67a55a82ce06 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
DeMein 0:67a55a82ce06 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
DeMein 0:67a55a82ce06 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
DeMein 0:67a55a82ce06 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
DeMein 0:67a55a82ce06 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DeMein 0:67a55a82ce06 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
DeMein 0:67a55a82ce06 20 * THE SOFTWARE.
DeMein 0:67a55a82ce06 21 */
DeMein 0:67a55a82ce06 22
DeMein 0:67a55a82ce06 23 /**
DeMein 0:67a55a82ce06 24 \file ffuncs.h
DeMein 0:67a55a82ce06 25 \brief header file for ffuncs
DeMein 0:67a55a82ce06 26 */
DeMein 0:67a55a82ce06 27
DeMein 0:67a55a82ce06 28 #ifndef FFUNCS_H
DeMein 0:67a55a82ce06 29 #define FFUNCS_H
DeMein 0:67a55a82ce06 30
DeMein 0:67a55a82ce06 31 #include "mmex.h"
DeMein 0:67a55a82ce06 32
DeMein 0:67a55a82ce06 33 // definition of the F-functions
DeMein 0:67a55a82ce06 34 #define fmount 'M' // mount filesystem
DeMein 0:67a55a82ce06 35 #define funmount 'U' // Unmount filesystem
DeMein 0:67a55a82ce06 36 #define ffopen 'O' // File Open
DeMein 0:67a55a82ce06 37 #define ffread 'R' // File Read
DeMein 0:67a55a82ce06 38 #define ffwrite 'W' // File Write
DeMein 0:67a55a82ce06 39 #define ffclose 'C' // File Close
DeMein 0:67a55a82ce06 40 #define ffseek 'S' // File Seek
DeMein 0:67a55a82ce06 41 #define fflush 'F' // File Flush
DeMein 0:67a55a82ce06 42 #define fdir 'D' // Directory listing first entry
DeMein 0:67a55a82ce06 43 #define fndir 'N' // Directory listing next entry
DeMein 0:67a55a82ce06 44 #define fftell 'T' // Get value of file pointer
DeMein 0:67a55a82ce06 45 #define ffsize 'Z' // Get size of file
DeMein 0:67a55a82ce06 46
DeMein 0:67a55a82ce06 47 #define f_sdcard 'S' // SD card is the medium
DeMein 0:67a55a82ce06 48 #define f_usb 'U' // USB stick is the storage medium
DeMein 0:67a55a82ce06 49 #define f_local 'L' // local flash is the storage medium
DeMein 0:67a55a82ce06 50
DeMein 0:67a55a82ce06 51 #define f_modew 'w' // file mode is write
DeMein 0:67a55a82ce06 52 #define f_moder 'r' // file mode is read
DeMein 0:67a55a82ce06 53 #define f_modea 'a' // file mode is append
DeMein 0:67a55a82ce06 54
DeMein 0:67a55a82ce06 55 #define fs_local "local" // name for local filesystem
DeMein 0:67a55a82ce06 56 #define fs_sd "sd" // name for SD card filesystem
DeMein 0:67a55a82ce06 57 #define fs_usb "usb" // name for USB filesystem
DeMein 0:67a55a82ce06 58
DeMein 0:67a55a82ce06 59 #define fsp_local "/local/" // path name for local filesystem
DeMein 0:67a55a82ce06 60 #define fsp_sd "/sd/" // path name for SD card filesystem
DeMein 0:67a55a82ce06 61 #define fsp_usb "/usb/" // path name for USB filesystem
DeMein 0:67a55a82ce06 62
DeMein 0:67a55a82ce06 63 #define rt_local "/local" // root path name for local filesystem
DeMein 0:67a55a82ce06 64 #define rt_sd "/sd" // root path name for SD card filesystem
DeMein 0:67a55a82ce06 65 #define rt_usb "/usb" // root path name for USB filesystem
DeMein 0:67a55a82ce06 66
DeMein 0:67a55a82ce06 67 struct fhandle { // used for saving info in file handles
DeMein 0:67a55a82ce06 68 char filename[20]; // filename
DeMein 0:67a55a82ce06 69 char medium; // S, U or F
DeMein 0:67a55a82ce06 70 char fsp[10]; // path name, root only
DeMein 0:67a55a82ce06 71 char direct[20]; // string with current directory
DeMein 0:67a55a82ce06 72 char filemode; // current filemode
DeMein 0:67a55a82ce06 73 char fullpath[50]; // full path
DeMein 0:67a55a82ce06 74 FILE *fp; // file pointer
DeMein 0:67a55a82ce06 75 };
DeMein 0:67a55a82ce06 76
DeMein 0:67a55a82ce06 77 void init_handles();
DeMein 0:67a55a82ce06 78 void parse_F();
DeMein 0:67a55a82ce06 79
DeMein 0:67a55a82ce06 80 void do_fmount();
DeMein 0:67a55a82ce06 81 void do_funmount();
DeMein 0:67a55a82ce06 82 void do_ffopen();
DeMein 0:67a55a82ce06 83 void do_ffread();
DeMein 0:67a55a82ce06 84 void do_ffwrite();
DeMein 0:67a55a82ce06 85 void do_ffclose();
DeMein 0:67a55a82ce06 86 void do_ffseek();
DeMein 0:67a55a82ce06 87 void do_fflush();
DeMein 0:67a55a82ce06 88 void do_fdir();
DeMein 0:67a55a82ce06 89 void do_fndir();
DeMein 0:67a55a82ce06 90 void do_fftell();
DeMein 0:67a55a82ce06 91 void do_ffsize();
DeMein 0:67a55a82ce06 92 void do_fdefault();
DeMein 0:67a55a82ce06 93
DeMein 0:67a55a82ce06 94 #endif