...

Dependents:   2doejemplo Labo_TRSE_Drone

Fork of mbed by mbed official

Committer:
simon.ford@mbed.co.uk
Date:
Thu Jan 22 18:32:40 2009 +0000
Revision:
5:62573be585e9
Parent:
4:5d1359a283bc
Child:
8:00a04e5cd407
* Added initial RPC release
* Added RTC and helper functions
* Added read_u16()/write_u16() to AnalogIn/Out
* Ticker/Timeout timing fixed!
* mbedinfo() helper added
* error() and printf() added to replace DEBUG() and ERROR()
* DigitalIn supports methods on rise/fall
* SPI and Serial support NC
* LED1-4 also map to 1-4
* Timer object reset fixed
* SPI uses single mode
* SPI3 added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon.ford@mbed.co.uk 4:5d1359a283bc 1 /* Copyright 2008 ARM Limited. All rights reserved. */
simon.ford@mbed.co.uk 4:5d1359a283bc 2
simon.ford@mbed.co.uk 4:5d1359a283bc 3 #ifndef MBED_FILESYSTEMLIKE_H
simon.ford@mbed.co.uk 4:5d1359a283bc 4 #define MBED_FILESYSTEMLIKE_H
simon.ford@mbed.co.uk 4:5d1359a283bc 5
simon.ford@mbed.co.uk 4:5d1359a283bc 6 #include "Base.h"
simon.ford@mbed.co.uk 4:5d1359a283bc 7 #include "FileHandle.h"
simon.ford@mbed.co.uk 4:5d1359a283bc 8 #ifdef __ARMCC_VERSION
simon.ford@mbed.co.uk 4:5d1359a283bc 9 # define O_RDONLY 0
simon.ford@mbed.co.uk 4:5d1359a283bc 10 # define O_WRONLY 1
simon.ford@mbed.co.uk 4:5d1359a283bc 11 # define O_RDWR 2
simon.ford@mbed.co.uk 4:5d1359a283bc 12 # define O_CREAT 0x0200
simon.ford@mbed.co.uk 5:62573be585e9 13 # define O_TRUNC 0x0400
simon.ford@mbed.co.uk 4:5d1359a283bc 14 # define O_APPEND 0x0008
simon.ford@mbed.co.uk 4:5d1359a283bc 15 #else
simon.ford@mbed.co.uk 4:5d1359a283bc 16 # include <sys/fcntl.h>
simon.ford@mbed.co.uk 4:5d1359a283bc 17 #endif
simon.ford@mbed.co.uk 4:5d1359a283bc 18
simon.ford@mbed.co.uk 4:5d1359a283bc 19 namespace mbed {
simon.ford@mbed.co.uk 4:5d1359a283bc 20
simon.ford@mbed.co.uk 4:5d1359a283bc 21 /* Class FileSystemLike
simon.ford@mbed.co.uk 4:5d1359a283bc 22 * A filesystem-like object is one that can be used to open files
simon.ford@mbed.co.uk 4:5d1359a283bc 23 * though it by fopen("/name/filename", mode)
simon.ford@mbed.co.uk 4:5d1359a283bc 24 *
simon.ford@mbed.co.uk 4:5d1359a283bc 25 * Implementations must define at least open (the default definitions
simon.ford@mbed.co.uk 4:5d1359a283bc 26 * of the rest of the functions just return error values).
simon.ford@mbed.co.uk 4:5d1359a283bc 27 */
simon.ford@mbed.co.uk 4:5d1359a283bc 28 class FileSystemLike : public Base {
simon.ford@mbed.co.uk 4:5d1359a283bc 29
simon.ford@mbed.co.uk 4:5d1359a283bc 30 public:
simon.ford@mbed.co.uk 4:5d1359a283bc 31
simon.ford@mbed.co.uk 4:5d1359a283bc 32 /* Constructor FileSystemLike
simon.ford@mbed.co.uk 4:5d1359a283bc 33 *
simon.ford@mbed.co.uk 4:5d1359a283bc 34 * Variables
simon.ford@mbed.co.uk 4:5d1359a283bc 35 * name - The name to use for the filesystem.
simon.ford@mbed.co.uk 4:5d1359a283bc 36 */
simon.ford@mbed.co.uk 4:5d1359a283bc 37 FileSystemLike(const char *name) : Base(name) {}
simon.ford@mbed.co.uk 4:5d1359a283bc 38
simon.ford@mbed.co.uk 4:5d1359a283bc 39 /* Function open
simon.ford@mbed.co.uk 4:5d1359a283bc 40 *
simon.ford@mbed.co.uk 4:5d1359a283bc 41 * Variables
simon.ford@mbed.co.uk 4:5d1359a283bc 42 * filename - The name of the file to open.
simon.ford@mbed.co.uk 5:62573be585e9 43 * flags - One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
simon.ford@mbed.co.uk 5:62573be585e9 44 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
simon.ford@mbed.co.uk 4:5d1359a283bc 45 * returns - A pointer to a FileHandle object representing the
simon.ford@mbed.co.uk 4:5d1359a283bc 46 * file on success, or NULL on failure.
simon.ford@mbed.co.uk 4:5d1359a283bc 47 */
simon.ford@mbed.co.uk 4:5d1359a283bc 48 virtual FileHandle *open(const char *filename, int flags) = 0;
simon.ford@mbed.co.uk 4:5d1359a283bc 49
simon.ford@mbed.co.uk 4:5d1359a283bc 50 /* Function remove
simon.ford@mbed.co.uk 4:5d1359a283bc 51 * Remove a file from the filesystem.
simon.ford@mbed.co.uk 4:5d1359a283bc 52 *
simon.ford@mbed.co.uk 4:5d1359a283bc 53 * Variables
simon.ford@mbed.co.uk 4:5d1359a283bc 54 * filename - the name of the file to remove.
simon.ford@mbed.co.uk 4:5d1359a283bc 55 * returns - 0 on success, -1 on failure.
simon.ford@mbed.co.uk 4:5d1359a283bc 56 */
simon.ford@mbed.co.uk 4:5d1359a283bc 57 virtual int remove(const char *filename) { return -1; };
simon.ford@mbed.co.uk 4:5d1359a283bc 58
simon.ford@mbed.co.uk 4:5d1359a283bc 59 /* Function rename
simon.ford@mbed.co.uk 4:5d1359a283bc 60 * Rename a file in the filesystem.
simon.ford@mbed.co.uk 4:5d1359a283bc 61 *
simon.ford@mbed.co.uk 4:5d1359a283bc 62 * Variables
simon.ford@mbed.co.uk 4:5d1359a283bc 63 * oldname - the name of the file to rename.
simon.ford@mbed.co.uk 4:5d1359a283bc 64 * newname - the name to rename it to.
simon.ford@mbed.co.uk 4:5d1359a283bc 65 * returns - 0 on success, -1 on failure.
simon.ford@mbed.co.uk 4:5d1359a283bc 66 */
simon.ford@mbed.co.uk 4:5d1359a283bc 67 virtual int rename(const char *oldname, const char *newname) { return -1; };
simon.ford@mbed.co.uk 4:5d1359a283bc 68
simon.ford@mbed.co.uk 4:5d1359a283bc 69 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
simon.ford@mbed.co.uk 4:5d1359a283bc 70
simon.ford@mbed.co.uk 4:5d1359a283bc 71 };
simon.ford@mbed.co.uk 4:5d1359a283bc 72
simon.ford@mbed.co.uk 4:5d1359a283bc 73 } // namespace mbed
simon.ford@mbed.co.uk 4:5d1359a283bc 74
simon.ford@mbed.co.uk 4:5d1359a283bc 75 #endif