The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Files at this revision

API Documentation at this revision

Comitter:
simon.ford@mbed.co.uk
Date:
Thu Nov 27 16:23:24 2008 +0000
Parent:
3:aefd12a1f1c5
Child:
5:62573be585e9
Commit message:
New version of framework: vectors, environment, platform, base and file system

Changed in this revision

AnalogIn.h Show annotated file Show diff for this revision Revisions of this file
AnalogOut.h Show annotated file Show diff for this revision Revisions of this file
Base.h Show annotated file Show diff for this revision Revisions of this file
BusIn.h Show annotated file Show diff for this revision Revisions of this file
BusOut.h Show annotated file Show diff for this revision Revisions of this file
Debug.h Show annotated file Show diff for this revision Revisions of this file
DebugTracer.h Show annotated file Show diff for this revision Revisions of this file
DigitalIn.h Show annotated file Show diff for this revision Revisions of this file
DigitalOut.h Show annotated file Show diff for this revision Revisions of this file
FileHandle.h Show annotated file Show diff for this revision Revisions of this file
FileLike.h Show annotated file Show diff for this revision Revisions of this file
FileSystemLike.h Show annotated file Show diff for this revision Revisions of this file
FunctionPointer.h Show annotated file Show diff for this revision Revisions of this file
I2C.h Show annotated file Show diff for this revision Revisions of this file
LPC2300_HAL.h Show annotated file Show diff for this revision Revisions of this file
LPC2300_MAP.h Show annotated file Show diff for this revision Revisions of this file
LocalFileSystem.h Show annotated file Show diff for this revision Revisions of this file
PwmOut.h Show annotated file Show diff for this revision Revisions of this file
Retarget.h Show diff for this revision Revisions of this file
SPI.h Show annotated file Show diff for this revision Revisions of this file
SemihostFileHandle.h Show diff for this revision Revisions of this file
SemihostFileSystem.h Show diff for this revision Revisions of this file
Serial.h Show annotated file Show diff for this revision Revisions of this file
Stream.h Show annotated file Show diff for this revision Revisions of this file
Ticker.h Show annotated file Show diff for this revision Revisions of this file
Timeout.h Show annotated file Show diff for this revision Revisions of this file
Timer.h Show annotated file Show diff for this revision Revisions of this file
TimerEvent.h Show annotated file Show diff for this revision Revisions of this file
mbed.ar Show annotated file Show diff for this revision Revisions of this file
mbed.h Show annotated file Show diff for this revision Revisions of this file
mbed.sct Show annotated file Show diff for this revision Revisions of this file
rpc.h Show annotated file Show diff for this revision Revisions of this file
stackheap.h Show annotated file Show diff for this revision Revisions of this file
--- a/AnalogIn.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/AnalogIn.h	Thu Nov 27 16:23:24 2008 +0000
@@ -24,7 +24,7 @@
 	 * Variables:
 	 *  pin - AnalogIn pin to connect to (15-20)
 	 */
-	AnalogIn(int pin);
+	AnalogIn(int pin, const char *name = NULL);
 	
 	/* Group: Access Methods */
 		
@@ -64,6 +64,8 @@
      *  A shorthand for <read>
      */
 	operator float();
+
+    virtual const struct rpc_method *rpc_methods();
 	
 protected:
 	
--- a/AnalogOut.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/AnalogOut.h	Thu Nov 27 16:23:24 2008 +0000
@@ -24,7 +24,7 @@
 	 * Variables:
 	 *  pin - AnalogOut pin to connect to (18)
 	 */
-	AnalogOut(int pin);
+	AnalogOut(int pin, const char *name = NULL);
 	
 	/* Group: Access Methods */
 		
@@ -86,6 +86,8 @@
 	 *  A shorthand for <read>
 	 */	
 	operator float();
+
+    virtual const struct rpc_method *rpc_methods();
 		
 };
 
--- a/Base.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Base.h	Thu Nov 27 16:23:24 2008 +0000
@@ -1,42 +1,117 @@
 /* mbed Microcontroller Library - Base
- * Copyright (c) 2007-2008, sford
+ * Copyright (c) 2006-2008 ARM Limited. All rights reserved.
+ * sford, jbrawn
  */
-
+ 
 #ifndef MBED_BASE_H
 #define MBED_BASE_H
 
-#define MBED_BASE_NUM_OBJECTS 	128		// max # base objects
-#define MBED_BASE_SIZE_NAME 	16 		// max size of object name, including the null-termination
-
-#include "rt_sys.h"
+#include <cstdlib>
 
 namespace mbed {
 
+/* Class Base
+ *  The base class for most things
+ */
 class Base {
 
 public: 
+    
+    Base(const char *name = NULL);
 
-	Base();
-	virtual ~Base();
+    virtual ~Base();
+
+    /* Function register_object
+     *  Registers this object with the given name, so that it can be
+     *  looked up with lookup. If this object has already been
+     *  registered, then this just changes the name.
+     *
+     * Variables
+     *   name - The name to give the object. If NULL we do nothing.
+     */
+    void register_object(const char *name);
+
+    /* Function name
+     *  Returns the name of the object, or NULL if it has no name.
+     */
+    const char *name();
+
+    /* Function rpc
+     *  Call the given method with the given arguments, and write the
+     *  result into the string pointed to by result. The default
+     *  implementation calls rpc_methods to determine the supported
+     *  methods.
+     *
+     * Variables
+     *  method - The name of the method to call.
+     *  arguments - A list of arguments separated by spaces.
+     *  result - A pointer to a string to write the result into. May
+     *    be NULL, in which case nothing is written.
+     *  returns - true if method corresponds to a valid rpc method, or
+     *    false otherwise.
+     */
+    virtual bool rpc(const char *method, const char *arguments, char *result);	
 
-	void name(const char* name);
-	const char* name();
-	const char* type();
-	
-	static Base* lookup(const char* name);
-	
-	virtual FILEHANDLE sys_open(const char* name, int openmode);
+    /* Function rpc_method
+     *  Returns a pointer to an array describing the rpc methods
+     *  supported by this object, terminated by RPC_METHOD_END.
+     *
+     * Example
+     *
+     * > class Example : public Base {
+     * >   int foo(int a, int b) { return a + b; }
+     * >   virtual const struct rpc_method *rpc_methods() {
+     * >     static const rpc_method rpc_methods[] = {
+     * >       { "foo", generic_caller<int, Example, int, int, &Example::foo> },
+     * >       RPC_METHOD_END
+     * >     };
+     * >     return rpc_methods;
+     * >   }
+     * > };
+     */
+    virtual const struct rpc_method *rpc_methods();
+
+    /* Function rpc
+     *  Use the lookup function to lookup an object and, if
+     *  successful, call its rpc method
+     *
+     * Variables
+     *  returns - false if name does not correspond to an object,
+     *    otherwise the return value of the call to the object's rpc
+     *    method.
+     */
+    static bool rpc(const char *name, const char *method, const char *arguments, char *result);
+
+    /* Function lookup
+     *  Lookup and return the object that has the given name.
+     *
+     * Variables
+     *  name - the name to lookup.
+     *  len - the length of name.
+     */
+    static Base *lookup(const char *name, unsigned int len);
 
 protected: 
 
-	const char* _type;					// The class type
-	char _name[MBED_BASE_SIZE_NAME];	// The class instance name	
-	
-	static int _uid;								// The counter used to generate the uid's 
-	static Base* _objects[MBED_BASE_NUM_OBJECTS]; 	// Pointers to all the objects to enable things like rpc
-	
+    static Base *_head;
+    Base *_next;
+    const char *_name;
+
 };
 
+/* Macro MBED_OBJECT_NAME_MAX
+ *  The maximum size of object name (including terminating null byte)
+ *  that will be recognised when using fopen to open a FileLike
+ *  object, or when using the rpc function.
+ */ 
+#define MBED_OBJECT_NAME_MAX 32
+
+/* Macro MBED_METHOD_NAME_MAX
+ *  The maximum size of rpc method name (including terminating null
+ *  byte) that will be recognised by the rpc function (in rpc.h).
+ */ 
+#define MBED_METHOD_NAME_MAX 32
+
 } // namespace mbed
 
 #endif
--- a/BusIn.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/BusIn.h	Thu Nov 27 16:23:24 2008 +0000
@@ -29,10 +29,11 @@
      *  It is only required to specify as many pin variables as is required
      *  for the bus; the rest will default to NOT_CONNECTED
 	 */ 
-	BusIn(int p0, int p1 = NOT_CONNECTED, int p2 = NOT_CONNECTED, int p3 = NOT_CONNECTED,
-		  int p4 = NOT_CONNECTED, int p5 = NOT_CONNECTED, int p6 = NOT_CONNECTED, int p7 = NOT_CONNECTED,
-		  int p8 = NOT_CONNECTED, int p9 = NOT_CONNECTED, int p10 = NOT_CONNECTED, int p11 = NOT_CONNECTED,
-		  int p12 = NOT_CONNECTED, int p13 = NOT_CONNECTED, int p14 = NOT_CONNECTED, int p15 = NOT_CONNECTED);
+    BusIn(int p0, int p1 = NOT_CONNECTED, int p2 = NOT_CONNECTED, int p3 = NOT_CONNECTED,
+          int p4 = NOT_CONNECTED, int p5 = NOT_CONNECTED, int p6 = NOT_CONNECTED, int p7 = NOT_CONNECTED,
+          int p8 = NOT_CONNECTED, int p9 = NOT_CONNECTED, int p10 = NOT_CONNECTED, int p11 = NOT_CONNECTED,
+          int p12 = NOT_CONNECTED, int p13 = NOT_CONNECTED, int p14 = NOT_CONNECTED, int p15 = NOT_CONNECTED, 
+          const char *name = NULL);
 		
 	virtual ~BusIn();
 	
@@ -52,6 +53,8 @@
 	 *  A shorthand for <read>
 	 */
 	operator int();
+
+    virtual const struct rpc_method *rpc_methods();
 		
 protected:
 	
--- a/BusOut.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/BusOut.h	Thu Nov 27 16:23:24 2008 +0000
@@ -29,10 +29,11 @@
      *  It is only required to specify as many pin variables as is required
      *  for the bus; the rest will default to NOT_CONNECTED
    	 */ 
-	BusOut(int p0, int p1 = NOT_CONNECTED, int p2 = NOT_CONNECTED, int p3 = NOT_CONNECTED,
-		  int p4 = NOT_CONNECTED, int p5 = NOT_CONNECTED, int p6 = NOT_CONNECTED, int p7 = NOT_CONNECTED,
-		  int p8 = NOT_CONNECTED, int p9 = NOT_CONNECTED, int p10 = NOT_CONNECTED, int p11 = NOT_CONNECTED,
-		  int p12 = NOT_CONNECTED, int p13 = NOT_CONNECTED, int p14 = NOT_CONNECTED, int p15 = NOT_CONNECTED);
+    BusOut(int p0, int p1 = NOT_CONNECTED, int p2 = NOT_CONNECTED, int p3 = NOT_CONNECTED,
+           int p4 = NOT_CONNECTED, int p5 = NOT_CONNECTED, int p6 = NOT_CONNECTED, int p7 = NOT_CONNECTED,
+           int p8 = NOT_CONNECTED, int p9 = NOT_CONNECTED, int p10 = NOT_CONNECTED, int p11 = NOT_CONNECTED,
+           int p12 = NOT_CONNECTED, int p13 = NOT_CONNECTED, int p14 = NOT_CONNECTED, int p15 = NOT_CONNECTED, 
+           const char *name = NULL);
 
 	virtual ~BusOut();
 
@@ -68,6 +69,8 @@
 	 */
 	operator int();
 
+    virtual const struct rpc_method *rpc_methods();
+
 protected:
 
 	DigitalOut* _pin[16];
--- a/Debug.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Debug.h	Thu Nov 27 16:23:24 2008 +0000
@@ -5,8 +5,6 @@
 #ifndef MBED_DEBUG_H
 #define MBED_DEBUG_H
 
-#include "DebugTracer.h"
-
 namespace mbed {
 
 /* Section: debug
@@ -25,11 +23,11 @@
 void ERROR(const char* format, ...);
 #endif 
 
-#define ERROR(...) mbed_error(__FILE__, __LINE__, __VA_ARGS__) 
-void mbed_error(const char* file, int line, const char* fmt, ...);
+#define ERROR(FMT, ...) mbed_error(__FILE__, __LINE__, FMT, ##__VA_ARGS__) 
+void mbed_error(const char* file, int line, const char* fmt=0, ...) __attribute__((noreturn));
 
 // Internal use for "official" errors
-void mbed_error(const char* file, int line, int code, const char* fmt, ...);
+void mbed_error(const char* file, int line, int code, const char* fmt=0, ...) __attribute__((noreturn));
 
 // As seen by user, for documentation purposes only
 #if 0
@@ -46,11 +44,7 @@
 void ASSERT(int condition, const char* fmt = 0, ...);
 #endif
 
-#define ASSERT(...) mbed_assert(__FILE__, __LINE__, __VA_ARGS__)
-void mbed_assert(const char* file, int line, int condition, const char* fmt = 0, ...);
-
-// Internal use for "official" errors
-void mbed_assert(const char* file, int line, int condition, int code, const char* fmt = 0, ...);
+#define ASSERT(COND, ...) (COND ? (void)0 : mbed_error(__FILE__, __LINE__, ##__VA_ARGS__))
 
 // As seen by user, for documentation purposes only
 #if 0 
--- a/DebugTracer.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/DebugTracer.h	Thu Nov 27 16:23:24 2008 +0000
@@ -6,7 +6,7 @@
 #define MBED_DEBUGTRACER_H
 
 #include "Base.h"
-#include "stdio.h"
+#include <cstdio>
 
 #define MAX_TRACER_DEPTH 32
 
@@ -17,7 +17,7 @@
 #define METHOD(name) 	DebugTracer _tracer_instance(name, this)
 #define FUNCTION(name)	DebugTracer _tracer_instance(name)
 
-/* Class: DebugTracer
+/* Class DebugTracer
  *  A code instrumentation utility
  * 
  * This object adds a function name or methodname/object instance 
@@ -31,7 +31,7 @@
  *  - trace the runtime call graph (for the whole program run, or programatically on/off) 
  *
  *
- * Example:
+ * Example
  *
  * Function example
  * > void foo(int x) { FUNCTION("foo");
@@ -45,7 +45,7 @@
 
 public:
 
-	/* Constructor: DebugTracer
+	/* Constructor DebugTracer
 	 *  Record the method and object instance it is called on
 	 *  to the call stack
 	 */
@@ -55,7 +55,7 @@
 		_depth++;
 	}
 	
-	/* Destructor: ~DebugTracer
+	/* Destructor ~DebugTracer
 	 *  Pop from the call stack
 	 */
 	~DebugTracer() {
@@ -63,16 +63,16 @@
 	}
 
 	static void stack() {
-		fprintf(stderr, "Trace (depth = %d):\n", _depth);
+		std::fprintf(stderr, "Trace (depth = %d):\n", _depth);
 		for(int i=0; i<_depth; i++) { 
 			// indent
 			for(int j=0; j<i; j++) {
-				fprintf(stderr, "  ");
+				std::fprintf(stderr, "  ");
 			}
 			if(_objects[i]) {
-				fprintf(stderr, "%s::", _objects[i]->type());
+//				std::fprintf(stderr, "%s::", _objects[i]->type());
 			}
-			fprintf(stderr, "%s\n", _functions[i]);
+			std::fprintf(stderr, "%s\n", _functions[i]);
 		}
 	}
 
--- a/DigitalIn.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/DigitalIn.h	Thu Nov 27 16:23:24 2008 +0000
@@ -28,7 +28,7 @@
 	 * Variables:
 	 *  pin - DigitalIn pin to connect to (5-30)
 	 */
-	DigitalIn(int pin);
+	DigitalIn(int pin, const char *name = NULL);
 
 	/* Function: rise
 	 *  Attach a function to call when a rising edge occurs on the input
@@ -66,6 +66,8 @@
 	operator int();
  	
  	static void _irq(); // Called on a GPIO interrupt
+
+    virtual const struct rpc_method *rpc_methods();
  	
 protected:
 
--- a/DigitalOut.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/DigitalOut.h	Thu Nov 27 16:23:24 2008 +0000
@@ -25,7 +25,7 @@
 	 * Variables:
 	 *  pin - DigitalOut pin to connect to (5-30)
 	 */
-	DigitalOut(int pin);
+	DigitalOut(int pin, const char* name = NULL);
 
 	/* Group: Access Methods */
 		
@@ -46,7 +46,9 @@
 	 *      0 for logical 0 (0v) and 1 for logical 1 (3.3v)
 	 */
     int read();
-   
+
+    virtual const struct rpc_method *rpc_methods();
+
    	/* Group: Access Method Shorthand */
    	 
 	/* Function: operator=
--- a/FileHandle.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/FileHandle.h	Thu Nov 27 16:23:24 2008 +0000
@@ -5,9 +5,19 @@
 #ifndef MBED_FILEHANDLE_H
 #define MBED_FILEHANDLE_H
 
+typedef int FILEHANDLE;
+
+#include <stdio.h>
+#ifdef __ARMCC_VERSION
+typedef int ssize_t;
+typedef long off_t;
+#else
+#include <sys/types.h>
+#endif
+
 namespace mbed { 
 
-/* Class: FileHandle
+/* Class FileHandle
  *  An OO equivalent of the internal FILEHANDLE variable
  *  and associated _sys_* functions
  *
@@ -21,73 +31,81 @@
 
 public:
 
-	//virtual ~FileHandle() { }
-	
-	/* Function: sys_write
-	 *  Write the contents of a buffer to the file
+    /* Function write
+     *  Write the contents of a buffer to the file
      *
-     * Parameters:
+     * Parameters
      *  buffer - the buffer to write from
      *  length - the number of characters to write
-     *  mode   - the mode of the file, 0 (normal) or 1 (binary); this may be unused?
      *
-	 * Returns:
-	 *  0 on success, -1 on error, or the number of characters not written on partial success
+     * Returns
+     *  The number of characters written (possibly 0) on success, -1 on error.
      */
-	virtual	int sys_write(const unsigned char* buffer, unsigned int length, int mode) = 0;
+    virtual ssize_t write(const void* buffer, size_t length) = 0;
 
-	virtual	int sys_close() = 0;
-	
-	/* Function: sys_read
-	 *  Reads the contents of the file into a buffer
-	 *
-     * Parameters:
+    /* Function close
+     *  Close the file
+     *
+     * Returns
+     *  Zero on success, -1 on error.
+     */
+    virtual int close() = 0;
+
+    /* Function read
+     *  Reads the contents of the file into a buffer
+     *
+     * Parameters
      *  buffer - the buffer to read in to
      *  length - the number of characters to read
-     *  mode   - the mode of the file, 0 (normal) or 1 (binary); this may be unused?
      *
-     * Returns:
-     *  0 on success, -1 on error, or the number of characters not read on partial success. EOF is 
-     *  signaled by setting the top bit (0x80000000) of the return value. 
-	 */
-	virtual	int sys_read(unsigned char* buffer, unsigned int length, int mode) = 0;
-	
-	/* Function: sys_istty
-	 *  Check if the handle is for a interactive terminal device 
-	 *
-	 * If so, unbuffered behaviour is used by default
-	 *
-	 * Returns:
-	 *  0 - no
-	 *  1 - yes
-	 */
-	virtual	int sys_istty() = 0 ;
+     * Returns
+     *  The number of characters read (zero at end of file) on success, -1 on error.
+     */
+    virtual ssize_t read(void* buffer, size_t length) = 0;
+
+    /* Function isatty
+     *  Check if the handle is for a interactive terminal device 
+     *
+     * If so, line buffered behaviour is used by default
+     *
+     * Returns
+     *  1 if it is a terminal, 0 otherwise
+     */
+    virtual int isatty() = 0 ;
 
-	/* Function: sys_seek
- 	 *  Move the file position to a given offset from the file start
- 	 *
- 	 * Returns:
- 	 *  0 on success, -1 on failure or unsupported
- 	 */
-	virtual	int sys_seek(int position) = 0;
-	
-	/* Function: sys_ensure
-	 *  Flush any OS buffers associated with the FileHandle, ensuring it
-	 *  is up to date on disk
-	 *
-	 * Returns:
-	 *  0 on success or un-needed, -1 on error
- 	 */
-	virtual	int sys_ensure() = 0;
-	
-	/* Function: sys_flen
-	 *  Find the current length of the file
-	 *
-	 * Returns:
-	 *  The current length of the file, or -1 on error
-	 */
-	virtual	int sys_flen() = 0;
-		
+    /* Function lseek
+     *  Move the file position to a given offset from a given location.
+     *
+     * Parameters
+     *  offset - The offset from whence to move to
+     *  whence - SEEK_SET for the start of the file, SEEK_CUR for the
+     *   current file position, or SEEK_END for the end of the file.
+     *
+     * Returns
+     *  New file position on success, -1 on failure or unsupported
+     */
+    virtual off_t lseek(off_t offset, int whence) = 0;
+
+    /* Function fsync
+     *  Flush any buffers associated with the FileHandle, ensuring it
+     *  is up to date on disk
+     *
+     * Returns
+     *  0 on success or un-needed, -1 on error
+     */
+    virtual int fsync() = 0;
+
+    virtual off_t flen() {
+        /* remember our current position */
+        off_t pos = lseek(0, SEEK_CUR);
+        if(pos == -1) return -1;
+        /* seek to the end to get the file length */
+        off_t res = lseek(0, SEEK_END);
+        /* return to our old position */
+        lseek(pos, SEEK_SET);
+        return res;
+    }
+
 };
 
 } // namespace mbed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FileLike.h	Thu Nov 27 16:23:24 2008 +0000
@@ -0,0 +1,30 @@
+/* Copyright 2008 ARM Limited. All rights reserved. */
+
+#ifndef MBED_FILELIKE_H
+#define MBED_FILELIKE_H
+
+#include "Base.h"
+#include "FileHandle.h"
+
+namespace mbed {
+
+/* Class FileLike
+ *  A file-like object is one that can be opened with fopen by
+ *  fopen("/name", mode). It is intersection of the classes Base and
+ *  FileHandle.
+ */ 
+class FileLike : public Base, public FileHandle {
+    
+ public:
+    /* Constructor FileLike
+     *
+     * Variables
+     *  name - The name to use to open the file.
+     */
+    FileLike(const char *name) : Base(name) { }
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FileSystemLike.h	Thu Nov 27 16:23:24 2008 +0000
@@ -0,0 +1,74 @@
+/* Copyright 2008 ARM Limited. All rights reserved. */
+
+#ifndef MBED_FILESYSTEMLIKE_H
+#define MBED_FILESYSTEMLIKE_H
+
+#include "Base.h"
+#include "FileHandle.h"
+#ifdef __ARMCC_VERSION
+# define O_RDONLY 0
+# define O_WRONLY 1
+# define O_RDWR   2
+# define O_CREAT  0x0200
+# define O_APPEND 0x0008
+#else
+# include <sys/fcntl.h>
+#endif
+
+namespace mbed {
+
+/* Class FileSystemLike
+ *  A filesystem-like object is one that can be used to open files
+ *  though it by fopen("/name/filename", mode)
+ *
+ *  Implementations must define at least open (the default definitions
+ *  of the rest of the functions just return error values).
+ */
+class FileSystemLike : public Base {
+
+ public:
+
+    /* Constructor FileSystemLike
+     *
+     * Variables
+     *  name - The name to use for the filesystem.
+     */
+    FileSystemLike(const char *name) : Base(name) {}
+
+    /* Function open
+     *
+     * Variables
+     *  filename - The name of the file to open.
+     *  flags - One of O_RDONLY, O_WRONLY, or O_RDWR, possibly OR'd
+     *    with O_CREAT or O_APPEND.
+     *  returns - A pointer to a FileHandle object representing the
+     *   file on success, or NULL on failure.
+     */
+    virtual FileHandle *open(const char *filename, int flags) = 0;
+
+    /* Function remove
+     *  Remove a file from the filesystem.
+     *
+     * Variables
+     *  filename - the name of the file to remove.
+     *  returns - 0 on success, -1 on failure.
+     */
+    virtual int remove(const char *filename) { return -1; };
+
+    /* Function rename
+     *  Rename a file in the filesystem.
+     *
+     * Variables
+     *  oldname - the name of the file to rename.
+     *  newname - the name to rename it to.
+     *  returns - 0 on success, -1 on failure.
+     */
+    virtual int rename(const char *oldname, const char *newname) { return -1; };
+
+    // TODO other filesystem functions (mkdir, rm, rn, ls etc)
+    
+};
+
+} // namespace mbed
+
+#endif
--- a/FunctionPointer.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/FunctionPointer.h	Thu Nov 27 16:23:24 2008 +0000
@@ -1,86 +1,86 @@
-/* mbed Microcontroller Library - FunctionPointer
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_FUNCTIONPOINTER_H
-#define MBED_FUNCTIONPOINTER_H
-
-#include "string.h"
-
-namespace mbed { 
-
-/* Class FunctionPointer
- *  A class for storing and calling a pointer to a static or member void function
- */
-class FunctionPointer {
-
-public:
-
-	/* Constructor FunctionPointer
-	 *  Create a FunctionPointer, attaching a static function
-	 * 
-	 * Variables
-	 *  function - The void static function to attach (default is none)
-	 */
-	FunctionPointer(void (*function)(void) = 0);
-
-	/* Constructor FunctionPointer
-	 *  Create a FunctionPointer, attaching a member function
-	 * 
-	 * Variables
-	 *  object - The object pointer to invoke the member function on (i.e. the this pointer)
-	 *  function - The address of the void member function to attach 
-	 */
-	template<typename T>	
-	FunctionPointer(T *object, void (T::*member)(void)) {
-		attach(object, member);
-	}
-
-	/* Function attach
-	 *  Attach a static function
-	 * 
-	 * Variables
-	 *  function - The void static function to attach (default is none)
-	 */
-	void attach(void (*function)(void) = 0);
-	
-	/* Function attach
-	 *  Attach a member function
-	 * 
-	 * Variables
-	 *  object - The object pointer to invoke the member function on (i.e. the this pointer)
-	 *  function - The address of the void member function to attach 
-	 */
-	template<typename T>
-	void attach(T *object, void (T::*member)(void)) {
-		_object = static_cast<void*>(object);
-        memcpy(_member, (char*)&member, sizeof(member));
-		_membercaller = &FunctionPointer::membercaller<T>;
-		_function = 0;
-	}
-
-	/* Function call
-	 *  Call the attached static or member function
-	 */		
-	void call();
-		
-private:
-
-	template<typename T>
-	static void membercaller(void *object, char *member) {	
-		T* o = static_cast<T*>(object);
-		void (T::*m)(void);
-        memcpy((char*)&m, member, sizeof(m));
-		(o->*m)();
-	}
-	
-	void (*_function)(void);				// static function pointer - 0 if none attached
-	void *_object;							// object this pointer - 0 if none attached
-	char _member[16];						// raw member function pointer storage - converted back by registered _membercaller
-	void (*_membercaller)(void*, char*);	// registered membercaller function to convert back and call _member on _object
-	
-};
-
-}
-
-#endif
+/* mbed Microcontroller Library - FunctionPointer
+ * Copyright (c) 2007-2008, sford
+ */
+
+#ifndef MBED_FUNCTIONPOINTER_H
+#define MBED_FUNCTIONPOINTER_H
+
+#include "string.h"
+
+namespace mbed { 
+
+/* Class FunctionPointer
+ *  A class for storing and calling a pointer to a static or member void function
+ */
+class FunctionPointer {
+
+public:
+
+	/* Constructor FunctionPointer
+	 *  Create a FunctionPointer, attaching a static function
+	 * 
+	 * Variables
+	 *  function - The void static function to attach (default is none)
+	 */
+	FunctionPointer(void (*function)(void) = 0);
+
+	/* Constructor FunctionPointer
+	 *  Create a FunctionPointer, attaching a member function
+	 * 
+	 * Variables
+	 *  object - The object pointer to invoke the member function on (i.e. the this pointer)
+	 *  function - The address of the void member function to attach 
+	 */
+	template<typename T>	
+	FunctionPointer(T *object, void (T::*member)(void)) {
+		attach(object, member);
+	}
+
+	/* Function attach
+	 *  Attach a static function
+	 * 
+	 * Variables
+	 *  function - The void static function to attach (default is none)
+	 */
+	void attach(void (*function)(void) = 0);
+	
+	/* Function attach
+	 *  Attach a member function
+	 * 
+	 * Variables
+	 *  object - The object pointer to invoke the member function on (i.e. the this pointer)
+	 *  function - The address of the void member function to attach 
+	 */
+	template<typename T>
+	void attach(T *object, void (T::*member)(void)) {
+		_object = static_cast<void*>(object);
+        memcpy(_member, (char*)&member, sizeof(member));
+		_membercaller = &FunctionPointer::membercaller<T>;
+		_function = 0;
+	}
+
+	/* Function call
+	 *  Call the attached static or member function
+	 */		
+	void call();
+		
+private:
+
+	template<typename T>
+	static void membercaller(void *object, char *member) {	
+		T* o = static_cast<T*>(object);
+		void (T::*m)(void);
+        memcpy((char*)&m, member, sizeof(m));
+		(o->*m)();
+	}
+	
+	void (*_function)(void);				// static function pointer - 0 if none attached
+	void *_object;							// object this pointer - 0 if none attached
+	char _member[16];						// raw member function pointer storage - converted back by registered _membercaller
+	void (*_membercaller)(void*, char*);	// registered membercaller function to convert back and call _member on _object
+	
+};
+
+}
+
+#endif
--- a/I2C.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/I2C.h	Thu Nov 27 16:23:24 2008 +0000
@@ -28,7 +28,7 @@
 	 * Pin Options:
 	 *  (9, 10) or (28, 27)	 
 	 */
-	I2C(int sda, int scl);
+	I2C(int sda, int scl, const char *name = NULL);
 	
 	/* Function: frequency
 	 *  Set the frequency of the I2C interface
--- a/LPC2300_HAL.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/LPC2300_HAL.h	Thu Nov 27 16:23:24 2008 +0000
@@ -11,11 +11,9 @@
 #ifndef MBED_LPC2300_HAL_H
 #define MBED_LPC2300_HAL_H
 
-#include "LPC23xx.h"
-
 namespace LPC2300 {
 
-/* Section: LPC2300 */
+/* Section LPC2300 */
 
 //===================================================================
 // General
@@ -29,22 +27,22 @@
 // Pin Connect Block
 //===================================================================
 
-/* Function: pin_function
+/* Function pin_function
  *  Set the port function (0-3)
  */
 void pin_function(int port, int function);
 
-/* Function: pin_pullup
+/* Function pin_pullup
  *  Set the port resistor to pullup
  */
 void pin_pullup(int port);
 
-/* Function: pin_pulldown
+/* Function pin_pulldown
  *  Set the port resistor to pulldown
  */
 void pin_pulldown(int port);
 
-/* Function: pin_pullnone
+/* Function pin_pullnone
  *  Set the port resistor to none
  */
 void pin_pullnone(int port);
@@ -64,22 +62,22 @@
 	volatile unsigned int clr;	// 0x1C
 };	
 
-/* Function: gpio_input
+/* Function gpio_input
  *  Set the port GPIO as an input
  */
 void gpio_input(int port);
 
-/* Function: gpio_output
+/* Function gpio_output
  *  Set the port GPIO as an output
  */
 void gpio_output(int port);
 
-/* Function: gpio_write
+/* Function gpio_write
  *  Write a value to the GPIO port (v & 1)
  */
 void gpio_write(int port, int v);
 
-/* Function: gpio_read
+/* Function gpio_read
  *  Read a value from the GPIO port (0 or 1)
  */
 int gpio_read(int port);
@@ -96,27 +94,27 @@
 	reg32 EnF;		// 0x10
 };	
 
-/* Function: gpio_irq_enable_rising
+/* Function gpio_irq_enable_rising
  *  Enable the rising edge interrupt
  */
 void gpio_irq_enable_rising(int port);		
 
-/* Function: gpio_irq_enable_falling
+/* Function gpio_irq_enable_falling
  *  Enable the falling edge interrupt
  */
 void gpio_irq_enable_falling(int port);
 
-/* Function: gpio_irq_disable_rising
+/* Function gpio_irq_disable_rising
  *  Disable the rising edge interrupt
  */
 void gpio_irq_disable_rising(int port);
 
-/* Function: gpio_irq_disable_falling
+/* Function gpio_irq_disable_falling
  *  Disable the falling edge interrupt
  */
 void gpio_irq_disable_falling(int port);
 
-/* Function: gpio_irq_clear
+/* Function gpio_irq_clear
  *  Clear rising and falling interrupt for the port
  */
 void gpio_irq_clear(int port);
@@ -129,22 +127,22 @@
 // Analog-to-Digital Converter
 //===================================================================
 
-/* Function: adc_poweron
+/* Function adc_poweron
  *  Turn on the ADC
  */
 void adc_poweron();
 
-/* Function: adc_poweroff
+/* Function adc_poweroff
  *  Turn off the ADC
  */
 void adc_poweroff();
 
-/* Function: adc_init
+/* Function adc_init
  *  Setup the ADC ready for reading
  */
 void adc_init();
 
-/* Function: adc_read
+/* Function adc_read
  *  Read the value of the ADC (10-bit, id 0-5)
  */
 int adc_read(int id);
@@ -153,27 +151,27 @@
 // Digital-to-Analog Converter
 //===================================================================
 
-/* Function: dac_poweron
+/* Function dac_poweron
  *  Turn on the DAC
  */
 void dac_poweron();
 
-/* Function: dac_poweroff
+/* Function dac_poweroff
  *  Turn off the DAC
  */
 void dac_poweroff();
 
-/* Function: dac_init
+/* Function dac_init
  *  Setup the DAC ready for writinbg
  */
 void dac_init();
 
-/* Function: dac_write
+/* Function dac_write
  *  Write a value to the DAC (10-bit)
  */
 void dac_write(int value);
 
-/* Function: dac_read
+/* Function dac_read
  *  Read the value currently set as the DAC output (10-bit)
  */
 int dac_read();
@@ -208,7 +206,7 @@
 	reg32 CTCR; // 0x70 - Count Control Register
 };
 
-#define LPC2368_PWM  ((LPC2368_PWM_RF*)0xE0018000)
+#define LPC2368_PWM  ((LPC2368_PWM_RF*)PWM1_BASE_ADDR)
 
 #define TCR_CNT_EN	(1 << 0)
 #define TCR_RESET	(1 << 1)
@@ -289,12 +287,12 @@
 	Forced0
 };
 	
-/* Function: uart_poweron
+/* Function uart_poweron
  *  Turn on the Uart power
  */	
 void uart_poweron(int id);
 
-/* Function: uart_poweroff
+/* Function uart_poweroff
  *  Turn off the Uart power
  */	
 void uart_poweroff(int id);
@@ -362,12 +360,12 @@
 	reg32 ctcr;	// 0x70
 };	
 
-/* Function: timer_poweron
+/* Function timer_poweron
  *  Turn on the Timer power
  */	
 void timer_poweron(int id);
 
-/* Function: timer_poweroff
+/* Function timer_poweroff
  *  Turn off the Timer power
  */	
 void timer_poweroff(int id);
--- a/LPC2300_MAP.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/LPC2300_MAP.h	Thu Nov 27 16:23:24 2008 +0000
@@ -28,6 +28,11 @@
 	USBRX = 70
 };
 
+#define LED1_PORT  	(4*32 + 28)
+#define LED2_PORT	(3*32 + 25)
+#define LED3_PORT	(4*32 + 29)
+#define LED4_PORT	(3*32 + 26)
+
 #elif TARGET_PHAT40
 
 enum {
@@ -39,6 +44,11 @@
 	USBRX = 37
 };
 
+#define LED1_PORT  	(1*32 + 18)
+#define LED2_PORT	(1*32 + 20)
+#define LED3_PORT	(1*32 + 21)
+#define LED4_PORT	(1*32 + 23)
+
 #else
 #error "UNRECOGNISED TARGET"
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LocalFileSystem.h	Thu Nov 27 16:23:24 2008 +0000
@@ -0,0 +1,52 @@
+/* mbed Microcontroller Library - SemihostFileSystem
+ * Copyright (c) 2007-2008, sford
+ */
+
+#ifndef MBED_LOCALFILESYSTEM_H
+#define MBED_LOCALFILESYSTEM_H
+
+#include "FileSystemLike.h"
+
+namespace mbed {
+
+/* Class: LocalFileSystem
+ *  A filesystem for accessing the local mbed Microcontroller USB disk drive. 
+ *
+ *  This allows programs to read and write files on the same disk drive that is used to program the 
+ *  mbed Microcontroller. Once created, the standard C file access functions are used to open, 
+ *  read and write files.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > LocalFileSystem local("local");             // Create the local filesystem under the name "local"
+ * >
+ * > int main() {
+ * >     FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
+ * >     fprintf(fp, "Hello World!");              
+ * >     fclose(fp);                               
+ * > }
+ *
+ * Implementation Notes:
+ *  If the microcontroller program makes an access to the local drive, it will be marked as "removed"
+ *  on the Host computer. This means it is no longer accessible from the Host Computer.
+ *
+ *  The drive will only re-appear when the microcontroller program exists. Note that if the program does
+ *  not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
+ */
+class LocalFileSystem : public FileSystemLike {
+
+public:
+
+    LocalFileSystem(const char* n) : FileSystemLike(n) {
+
+    }
+	
+    virtual FileHandle *open(const char* name, int flags);
+    virtual int remove(const char *filename);
+
+};
+
+} // namespace mbed
+
+#endif
--- a/PwmOut.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/PwmOut.h	Thu Nov 27 16:23:24 2008 +0000
@@ -24,7 +24,7 @@
 	 * Variables:
 	 *  pin - PwmOut pin to connect to (21-26)
 	 */	
-	PwmOut(int pin);
+	PwmOut(int pin, const char *name = NULL);
 
 	/* Group: Access Methods (Analog-like) */
 		
@@ -127,6 +127,8 @@
 	 *  A shorthand for <read>
 	 */
 	operator float();
+
+    virtual const struct rpc_method *rpc_methods();
 	
 protected:
 
--- a/Retarget.h	Fri Nov 14 15:25:20 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/* mbed Microcontroller Library - Retarget
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_RETARGET_H
-#define MBED_RETARGET_H
-
-#include "stdio.h"
-#include "rt_sys.h"
-
-//===================================================================
-// System
-//===================================================================
-
-extern "C" void mbed_startup();
-extern "C" int $Sub$$main();
-extern "C" void $Sub$$_sys_exit(int return_code);
-
-//===================================================================
-// Pre-stdio
-//===================================================================
-
-extern "C" int $Sub$$fputc(int c, FILE* f);
-extern "C" int $Sub$$fgetc(FILE* f);
-extern "C" int $Sub$$__backspace(FILE* f);
-extern "C" void $Sub$$_ttywrch(int c);
-
-//===================================================================
-// Post-stdio
-//===================================================================
-
-extern "C" FILEHANDLE $Sub$$_sys_open(const char* name, int openmode);
-extern "C" int $Sub$$_sys_close(FILEHANDLE fh);
-extern "C" int $Sub$$_sys_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
-extern "C" int $Sub$$_sys_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
-extern "C" int $Sub$$_sys_istty(FILEHANDLE fh);
-extern "C" int $Sub$$_sys_seek(FILEHANDLE fh, int position);
-extern "C" int $Sub$$_sys_ensure(FILEHANDLE fh);
-extern "C" int $Sub$$_sys_flen(FILEHANDLE fh);
-
-
-#endif
-
--- a/SPI.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/SPI.h	Thu Nov 27 16:23:24 2008 +0000
@@ -30,7 +30,7 @@
 	 * Pin Options:
 	 *  (5, 6, 7) or (11, 12, 13)
 	 */
-	SPI(int mosi, int miso, int sclk);
+	SPI(int mosi, int miso, int sclk, const char *name = NULL);
 	
 	/* Function: format
 	 *  Set the transmission format
--- a/SemihostFileHandle.h	Fri Nov 14 15:25:20 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/* mbed Microcontroller Library - SemihostFileHandle
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_SEMIHOSTFILEHANDLE_H
-#define MBED_SEMIHOSTFILEHANDLE_H
-
-#include "rt_sys.h"
-#include "FileHandle.h"
-
-extern "C" int $Super$$_sys_close(FILEHANDLE fh);
-extern "C" int $Super$$_sys_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
-extern "C" int $Super$$_sys_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
-extern "C" int $Super$$_sys_istty(FILEHANDLE fh);
-extern "C" int $Super$$_sys_seek(FILEHANDLE fh, int position);
-extern "C" int $Super$$_sys_ensure(FILEHANDLE fh);
-extern "C" long $Super$$_sys_flen(FILEHANDLE fh);
-
-namespace mbed { 
-
-/* Class SemihostFileHandle
- *  Implements a FileHandle for talking to the standard Semihosting implementation
- */
-class SemihostFileHandle : public FileHandle {
-
-public:
-
-	/* Constructor SemihostFileHandle
-	 *  Create a SemihostFileHandle using a standard FILEHANDLE
-	 */
-	SemihostFileHandle(FILEHANDLE fh) { 
-		_fh = fh; 
-	}
-	
-	virtual int sys_close() { 
-		return $Super$$_sys_close(_fh);
-	}
-	//	virtual ~SemihostFileHandle() { 
-	//	$Super$$_sys_close(_fh);
-	//}
-
-	virtual	int sys_write(const unsigned char* buffer, unsigned int length, int mode) {
-		return $Super$$_sys_write(_fh, buffer, length, mode);
-	}
-	
-	virtual	int sys_read(unsigned char* buffer, unsigned int length, int mode) {
-		return $Super$$_sys_read(_fh, buffer, length, mode);
-	}
-	
-	virtual	int sys_istty() {
-		return $Super$$_sys_istty(_fh);
-	}
-	
-	virtual	int sys_seek(int position) {
-		return $Super$$_sys_seek(_fh, position);
-	}
-	
-	virtual	int sys_ensure() {
-		return $Super$$_sys_ensure(_fh);
-	}
-	
-	virtual	int sys_flen() {
-		return $Super$$_sys_flen(_fh);
-	}	
-
-protected:
-
-	FILEHANDLE _fh;
-
-};
-
-} // namespace mbed
-
-#endif
-
--- a/SemihostFileSystem.h	Fri Nov 14 15:25:20 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/* mbed Microcontroller Library - SemihostFileSystem
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_SEMIHOSTFILESYSTEM_H
-#define MBED_SEMIHOSTFILESYSTEM_H
-
-#include "rt_sys.h"
-
-#include "SemihostFileHandle.h"
-
-extern "C" FILEHANDLE $Super$$_sys_open(const char *name, int openmode);
-
-namespace mbed {
-
-/* Class SemihostFileSystem
- *  A file system invoking the standard semihosting implementation
- */
-class SemihostFileSystem : public Base {
-
-public:
-
-	SemihostFileSystem(char* n) {
-		name(n);
-		_type = "SemihostFileSystem";
-	}
-	
-	virtual FILEHANDLE sys_open(const char* name, int openmode) {
-		FILEHANDLE fh = $Super$$_sys_open(name, openmode);
-		FileHandle* fhc = new SemihostFileHandle(fh);
-		return (FILEHANDLE)fhc;
-	}
-	
-};
-
-} // namespace mbed
-
-#endif
-
--- a/Serial.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Serial.h	Thu Nov 27 16:23:24 2008 +0000
@@ -28,7 +28,7 @@
 	 * Pin Options:
 	 *  (9, 10) or (13, 14) or (28, 27)
      */
-	Serial(int tx, int rx);
+	Serial(int tx, int rx, const char *name = NULL);
 
 
 	/* Function: baud
--- a/Stream.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Stream.h	Thu Nov 27 16:23:24 2008 +0000
@@ -5,31 +5,53 @@
 #ifndef MBED_STREAM_H
 #define MBED_STREAM_H
 
-#include "Base.h"
+#include "FileLike.h"
+#include <cstdio>
 
 namespace mbed {
 
-class Stream : public Base {
+class Stream : protected FileLike {
 
 public:
-
-	Stream();
+    
+    Stream(const char *name = NULL);
+    virtual ~Stream();
 
-	int putc(int c);
-	int getc();
+    int putc(int c) {
+        fflush(_file);
+        return std::fputc(c, _file); 
+    }
+    int puts(const char *s) {
+        fflush(_file);
+        return std::fputs(s, _file); 
+    }
+    int getc() {
+        fflush(_file);
+        return std::fgetc(_file);
+    }
+    char *gets(char *s, int size) {
+        fflush(_file);
+        return std::fgets(s,size,_file);;
+    }
     int printf(const char* format, ...);
     int scanf(const char* format, ...);
-
-	int _backspace();
-	
+    
+    operator std::FILE*() { return _file; }
+    
 protected:
 
-	virtual int _putc(int c) = 0;
-	virtual int _getc() = 0;
+    virtual int close();
+    virtual ssize_t write(const void* buffer, size_t length);
+    virtual ssize_t read(void* buffer, size_t length);
+    virtual off_t lseek(off_t offset, int whence);
+    virtual int isatty();
+    virtual int fsync();
 
-	int _back;
-	int _last;
-	
+    virtual int _putc(int c) = 0;
+    virtual int _getc() = 0;
+    
+    std::FILE *_file;
+    
 };
 
 } // namespace mbed
--- a/Ticker.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Ticker.h	Thu Nov 27 16:23:24 2008 +0000
@@ -1,89 +1,89 @@
-/* mbed Microcontroller Library - Ticker
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_TICKER_H
-#define MBED_TICKER_H
-
-#include "TimerEvent.h"
-#include "FunctionPointer.h"	
-
-namespace mbed {
-
-/* Class: Ticker
- *  A Ticker is used to call a function at a recurring interval
- *
- * You can use as many seperate Ticker objects as you require. 
- */
-class Ticker : public TimerEvent {
-
-public:
-
-    /* Function: attach
-     *  Attach a function to be called by the Ticker, specifiying the interval in seconds
-     *     
-     * Variables:
-     *  fptr - pointer to the function to be called
-     *  t - the time between calls in seconds
-     */
-    void attach(void (*fptr)(void), float t) {
-        attach_us(fptr, t * 1000000.0f);
-    }
-    
-    /* Function: attach
-     *  Attach a member function to be called by the Ticker, specifiying the interval in seconds
-     *     
-     * Variables:
-     *  tptr - pointer to the object to call the member function on
-     *  mptr - pointer to the member function to be called
-     *  t - the time between calls in seconds
-     */
-    template<typename T>
-    void attach(T* tptr, void (T::*mptr)(void), float t) {
-        attach_us(tptr, mptr, t * 1000000.0f);
-    }
-    
-    /* Function: attach_us
-     *  Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
-     *     
-     * Variables:
-     *  fptr - pointer to the function to be called
-     *  t - the time between calls in micro-seconds
-     */
-    void attach_us(void (*fptr)(void), unsigned int t) {
-        _function.attach(fptr);
-        setup(t);
-    }
-
-    /* Function: attach_us
-     *  Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
-     *     
-     * Variables:
-     *  tptr - pointer to the object to call the member function on
-     *  mptr - pointer to the member function to be called
-     *  t - the time between calls in micro-seconds
-     */    
-    template<typename T>
-    void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
-        _function.attach(tptr, mptr);
-        setup(t);
-    }
-    
-    /* Function: detach
-     *  Detach the function
-     */        
-    void detach();
-	
-protected:
-
-    void setup(unsigned int t);
-    virtual void handler();
-	
-    unsigned int _delay;	
-    FunctionPointer _function;	
-
-};	
-
-}
-
-#endif
+/* mbed Microcontroller Library - Ticker
+ * Copyright (c) 2007-2008, sford
+ */
+
+#ifndef MBED_TICKER_H
+#define MBED_TICKER_H
+
+#include "TimerEvent.h"
+#include "FunctionPointer.h"	
+
+namespace mbed {
+
+/* Class: Ticker
+ *  A Ticker is used to call a function at a recurring interval
+ *
+ * You can use as many seperate Ticker objects as you require. 
+ */
+class Ticker : public TimerEvent {
+
+public:
+
+    /* Function: attach
+     *  Attach a function to be called by the Ticker, specifiying the interval in seconds
+     *     
+     * Variables:
+     *  fptr - pointer to the function to be called
+     *  t - the time between calls in seconds
+     */
+    void attach(void (*fptr)(void), float t) {
+        attach_us(fptr, t * 1000000.0f);
+    }
+    
+    /* Function: attach
+     *  Attach a member function to be called by the Ticker, specifiying the interval in seconds
+     *     
+     * Variables:
+     *  tptr - pointer to the object to call the member function on
+     *  mptr - pointer to the member function to be called
+     *  t - the time between calls in seconds
+     */
+    template<typename T>
+    void attach(T* tptr, void (T::*mptr)(void), float t) {
+        attach_us(tptr, mptr, t * 1000000.0f);
+    }
+    
+    /* Function: attach_us
+     *  Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
+     *     
+     * Variables:
+     *  fptr - pointer to the function to be called
+     *  t - the time between calls in micro-seconds
+     */
+    void attach_us(void (*fptr)(void), unsigned int t) {
+        _function.attach(fptr);
+        setup(t);
+    }
+
+    /* Function: attach_us
+     *  Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
+     *     
+     * Variables:
+     *  tptr - pointer to the object to call the member function on
+     *  mptr - pointer to the member function to be called
+     *  t - the time between calls in micro-seconds
+     */    
+    template<typename T>
+    void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
+        _function.attach(tptr, mptr);
+        setup(t);
+    }
+    
+    /* Function: detach
+     *  Detach the function
+     */        
+    void detach();
+	
+protected:
+
+    void setup(unsigned int t);
+    virtual void handler();
+	
+    unsigned int _delay;	
+    FunctionPointer _function;	
+
+};	
+
+}
+
+#endif
--- a/Timeout.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Timeout.h	Thu Nov 27 16:23:24 2008 +0000
@@ -1,86 +1,86 @@
-/* mbed Microcontroller Library - Timeout
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_TIMEOUT_H
-#define MBED_TIMEOUT_H
-
-#include "Ticker.h"
-
-namespace mbed {
-
-/* Class: Timeout
- *  A Timeout is used to call a function at a point in the future
- *
- * You can use as many seperate Timeout objects as you require. 
- */
-class Timeout : public Ticker {
-
-#if 0 // For documentation
-
-    /* Function: attach
-     *  Attach a function to be called by the Timeout, specifiying the delay in seconds
-     *     
-     * Variables:
-     *  fptr - pointer to the function to be called
-     *  t - the time before the call in seconds
-     */
-    void attach(void (*fptr)(void), float t) {
-        attach_us(fptr, t * 1000000.0f);
-    }
-    
-    /* Function: attach
-     *  Attach a member function to be called by the Timeout, specifiying the delay in seconds
-     *     
-     * Variables:
-     *  tptr - pointer to the object to call the member function on
-     *  mptr - pointer to the member function to be called
-     *  t - the time before the calls in seconds
-     */
-    template<typename T>
-    void attach(T* tptr, void (T::*mptr)(void), float t) {
-        attach_us(tptr, mptr, t * 1000000.0f);
-    }
-    
-    /* Function: attach_us
-     *  Attach a function to be called by the Timeout, specifiying the delay in micro-seconds
-     *     
-     * Variables:
-     *  fptr - pointer to the function to be called
-     *  t - the time before the call in micro-seconds
-     */
-    void attach_us(void (*fptr)(void), unsigned int t) {
-        _function.attach(fptr);
-        setup(t);
-    }
-
-    /* Function: attach_us
-     *  Attach a member function to be called by the Timeout, specifiying the delay in micro-seconds
-     *     
-     * Variables:
-     *  tptr - pointer to the object to call the member function on
-     *  mptr - pointer to the member function to be called
-     *  t - the time before the call in micro-seconds
-     */    
-    template<typename T>
-    void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
-        _function.attach(tptr, mptr);
-        setup(t);
-    }
-    
-    /* Function: detach
-     *  Detach the function
-     */        
-    void detach();
-
-#endif
-    
-protected:
-
-	virtual void handler();
-	
-};	
-
-}
-
-#endif
+/* mbed Microcontroller Library - Timeout
+ * Copyright (c) 2007-2008, sford
+ */
+
+#ifndef MBED_TIMEOUT_H
+#define MBED_TIMEOUT_H
+
+#include "Ticker.h"
+
+namespace mbed {
+
+/* Class: Timeout
+ *  A Timeout is used to call a function at a point in the future
+ *
+ * You can use as many seperate Timeout objects as you require. 
+ */
+class Timeout : public Ticker {
+
+#if 0 // For documentation
+
+    /* Function: attach
+     *  Attach a function to be called by the Timeout, specifiying the delay in seconds
+     *     
+     * Variables:
+     *  fptr - pointer to the function to be called
+     *  t - the time before the call in seconds
+     */
+    void attach(void (*fptr)(void), float t) {
+        attach_us(fptr, t * 1000000.0f);
+    }
+    
+    /* Function: attach
+     *  Attach a member function to be called by the Timeout, specifiying the delay in seconds
+     *     
+     * Variables:
+     *  tptr - pointer to the object to call the member function on
+     *  mptr - pointer to the member function to be called
+     *  t - the time before the calls in seconds
+     */
+    template<typename T>
+    void attach(T* tptr, void (T::*mptr)(void), float t) {
+        attach_us(tptr, mptr, t * 1000000.0f);
+    }
+    
+    /* Function: attach_us
+     *  Attach a function to be called by the Timeout, specifiying the delay in micro-seconds
+     *     
+     * Variables:
+     *  fptr - pointer to the function to be called
+     *  t - the time before the call in micro-seconds
+     */
+    void attach_us(void (*fptr)(void), unsigned int t) {
+        _function.attach(fptr);
+        setup(t);
+    }
+
+    /* Function: attach_us
+     *  Attach a member function to be called by the Timeout, specifiying the delay in micro-seconds
+     *     
+     * Variables:
+     *  tptr - pointer to the object to call the member function on
+     *  mptr - pointer to the member function to be called
+     *  t - the time before the call in micro-seconds
+     */    
+    template<typename T>
+    void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
+        _function.attach(tptr, mptr);
+        setup(t);
+    }
+    
+    /* Function: detach
+     *  Detach the function
+     */        
+    void detach();
+
+#endif
+    
+protected:
+
+	virtual void handler();
+	
+};	
+
+}
+
+#endif
--- a/Timer.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/Timer.h	Thu Nov 27 16:23:24 2008 +0000
@@ -16,7 +16,7 @@
 
 public:
 
-	Timer();
+	Timer(const char *name = NULL);
 	
 	/* Group: Access Methods */
 		
--- a/TimerEvent.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/TimerEvent.h	Thu Nov 27 16:23:24 2008 +0000
@@ -1,43 +1,43 @@
-/* mbed Microcontroller Library - TimerEvent
- * Copyright (c) 2007-2008, sford
- */
-
-#ifndef MBED_TIMEREVENT_H
-#define MBED_TIMEREVENT_H
-
-namespace mbed {
-
-// Base abstraction for timer interrupts
-class TimerEvent {
-
-public:
-
-	// The handler registered with the underlying timer interrupt
-	static void irq();
-
-	// Destruction removes it...	
-	virtual ~TimerEvent();
-
-protected:
-
-	// The handler called to service the timer event of the derived class
-	virtual void handler() = 0;
-	
-	// insert in to linked list
-	void insert(unsigned int timestamp);
-	
-	// remove from linked list, if in it
-	void remove();
-	
-	// Get the current usec timestamp
-	static unsigned int timestamp();
-
-	static TimerEvent *_head;   // The head of the list of the events, NULL if none
-	TimerEvent *_next;          // Pointer to the next in the list, NULL if last
-	unsigned int _timestamp;    // The timestamp at which the even should be triggered
-
-};
-
-}
-
-#endif
+/* mbed Microcontroller Library - TimerEvent
+ * Copyright (c) 2007-2008, sford
+ */
+
+#ifndef MBED_TIMEREVENT_H
+#define MBED_TIMEREVENT_H
+
+namespace mbed {
+
+// Base abstraction for timer interrupts
+class TimerEvent {
+
+public:
+
+	// The handler registered with the underlying timer interrupt
+	static void irq();
+
+	// Destruction removes it...	
+	virtual ~TimerEvent();
+
+protected:
+
+	// The handler called to service the timer event of the derived class
+	virtual void handler() = 0;
+	
+	// insert in to linked list
+	void insert(unsigned int timestamp);
+	
+	// remove from linked list, if in it
+	void remove();
+	
+	// Get the current usec timestamp
+	static unsigned int timestamp();
+
+	static TimerEvent *_head;   // The head of the list of the events, NULL if none
+	TimerEvent *_next;          // Pointer to the next in the list, NULL if last
+	unsigned int _timestamp;    // The timestamp at which the even should be triggered
+
+};
+
+}
+
+#endif
Binary file mbed.ar has changed
--- a/mbed.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/mbed.h	Thu Nov 27 16:23:24 2008 +0000
@@ -6,10 +6,10 @@
 #define MBED_H
  
 // Useful C libraries
-#include "stdio.h"
-#include "stdlib.h"
-#include "string.h"
-#include "math.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
 
 #include "helper.h"
 
@@ -34,6 +34,7 @@
 #include "wait.h"
 #include "Ticker.h"
 #include "Timeout.h"
+#include "LocalFileSystem.h"
 
 using namespace mbed; 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.sct	Thu Nov 27 16:23:24 2008 +0000
@@ -0,0 +1,26 @@
+; Copyright 2008 ARM Limited. All rights reserved.
+
+FLASH_LOAD 0x0 0x00080000
+{
+
+  ER_RESET +0
+  {
+    * (VECTOR_TABLE)
+  }
+
+  ER_RO +0
+  {
+    * (+RO)
+  }
+
+  ER_RW 0x40000120
+  {    
+   * (+RW)
+  }
+
+  ER_ZI +0
+  {    
+   * (+ZI)
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rpc.h	Thu Nov 27 16:23:24 2008 +0000
@@ -0,0 +1,277 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2008 ARM Limited. All rights reserved. 
+ */
+
+#ifndef MBED_RPC_H
+#define MBED_RPC_H
+
+/* Section rpc
+ *  Helpers for rpc handling.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "Base.h"
+
+namespace mbed {
+
+/* Function parse_arg
+ *  Parses and returns a value from a string.
+ *
+ * Variable
+ *  arg - The string to pase
+ *  next - If not NULL a pointer to after the last 
+ *    character parsed is written here
+ */
+template<typename T> T parse_arg(const char *arg, const char **next);
+
+/* signed integer types */
+
+template<> inline char parse_arg<char>(const char *arg, const char **next) {
+    if(next != NULL) *next = arg+1;
+    return *arg;
+}
+
+template<> inline short int parse_arg<short int>(const char *arg, const char **next) {
+    return strtol(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline long int parse_arg<long int>(const char *arg, const char **next) {
+    return strtol(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline int parse_arg<int>(const char *arg, const char **next) {
+    return strtol(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline long long parse_arg<long long>(const char *arg, const char **next) {
+    return strtoll(arg, const_cast<char**>(next), 10);
+}
+
+/* unsigned integer types */
+
+template<> inline unsigned char parse_arg<unsigned char>(const char *arg, const char **next) {
+    if(next != NULL) *next = arg+1;
+    return *arg;
+}
+
+template<> inline unsigned short int parse_arg<unsigned short int>(const char *arg, const char **next) {
+    return strtoul(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline unsigned long int parse_arg<unsigned long int>(const char *arg, const char **next) {
+    return strtoul(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline unsigned int parse_arg<unsigned int>(const char *arg, const char **next) {
+    return strtoul(arg, const_cast<char**>(next), 10);
+}
+
+template<> inline unsigned long long parse_arg<unsigned long long>(const char *arg, const char **next) {
+    return strtoull(arg, const_cast<char**>(next), 10);
+}
+
+/* floating types */
+
+template<> inline float parse_arg<float>(const char *arg, const char **next) {
+#if !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 310000
+    return strtof(arg,const_cast<char**>(next));
+#else
+    return strtod(arg,const_cast<char**>(next));
+#endif
+}
+
+template<> inline double parse_arg<double>(const char *arg, const char **next) {
+    return strtod(arg,const_cast<char**>(next));
+}
+
+template<> inline long double parse_arg<long double>(const char *arg, const char **next) {
+    return strtod(arg,const_cast<char**>(next));
+}
+
+
+/* Function write_result
+ *  Writes a value in to a result string in an appropriate manner
+ *
+ * Variable
+ *  val - The value to write
+ *  result - A pointer to the array to write the value into
+ */
+template<typename T> void write_result(T val, char *result);
+
+/* signed integer types */
+
+template<> inline void write_result<char>(char val, char *result) {
+    result[0] = val;
+    result[1] = '\0';
+}
+
+template<> inline void write_result<short int>(short int val, char *result) {
+    sprintf(result, "%hi", val); 
+}
+
+template<> inline void write_result<int>(int val, char *result) {
+    sprintf(result, "%i", val); 
+}
+
+template<> inline void write_result<long int>(long int val, char *result) {
+    sprintf(result, "%li", val); 
+}
+
+template<> inline void write_result<long long int>(long long int val, char *result) {
+    sprintf(result, "%lli", val); 
+}
+
+/* unsigned integer types */
+
+template<> inline void write_result<unsigned char>(unsigned char val, char *result) {
+    result[0] = val;
+    result[1] = '\0';
+}
+
+template<> inline void write_result<unsigned short int>(unsigned short int val, char *result) {
+    sprintf(result, "%hu", val); 
+}
+
+template<> inline void write_result<unsigned int>(unsigned int val, char *result) {
+    sprintf(result, "%u", val); 
+}
+
+template<> inline void write_result<unsigned long int>(unsigned long int val, char *result) {
+    sprintf(result, "%lu", val); 
+}
+
+template<> inline void write_result<unsigned long long int>(unsigned long long int val, char *result) {
+    sprintf(result, "%llu", val); 
+}
+
+/* floating types */
+
+template<> inline void write_result<float>(float val, char *result) {
+    sprintf(result, "%g", val); 
+}
+
+template<> inline void write_result<double>(double val, char *result) {
+    sprintf(result, "%g", val); 
+}
+
+template<> inline void write_result<long double>(long double val, char *result) {
+    sprintf(result, "%Lg", val); 
+}
+
+
+/* Function generic_caller
+ */
+template<class T, void (T::*member)()> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) { 
+    (static_cast<T*>(this_ptr)->*member)(); 
+    if(result != NULL) {
+    	result[0] = '\0';
+    }
+}
+
+
+/* Function generic_caller
+ */
+template<class T, typename A1, void (T::*member)(A1)> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) {
+    const char *next = arguments;
+
+    if(*next == ',' || *next == ' ') next++;
+    A1 arg1 = parse_arg<A1>(next,NULL);
+
+    (static_cast<T*>(this_ptr)->*member)(arg1); 
+    if(result != NULL) {
+        result[0] = '\0';
+    }
+}
+
+
+/* Function generic_caller
+ */
+template<class T, typename A1, typename A2, void (T::*member)(A1,A2)> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) {
+    const char *next = arguments;
+
+    if(*next == ',' || *next == ' ') next++;
+    A1 arg1 = parse_arg<A1>(next,&next);
+
+    if(*next == ',' || *next == ' ') next++;
+    A2 arg2 = parse_arg<A2>(next,NULL);
+
+    (static_cast<T*>(this_ptr)->*member)(arg1,arg2);
+    if(result != NULL) {
+        result[0] = '\0';
+    }
+}
+
+
+/* Function generic_caller
+ */
+template<typename R, class T, R (T::*member)()> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) { 
+    R res = (static_cast<T*>(this_ptr)->*member)();
+    if(result != NULL) {
+        write_result<R>(res, result);
+    }
+}
+
+
+/* Function generic_caller
+ */
+template<typename R, class T, typename A1, R (T::*member)(A1)> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) {
+    const char *next = arguments;
+
+    if(*next == ',' || *next == ' ') next++;
+    A1 arg1 = parse_arg<A1>(next,NULL);
+
+    R res = (static_cast<T*>(this_ptr)->*member)(arg1);
+    if(result != NULL) {
+        write_result<R>(res, result);
+    }
+}
+
+
+/* Function generic_caller
+ */
+template<typename R, class T, typename A1, typename A2, R (T::*member)(A1,A2)> 
+void generic_caller(Base *this_ptr, const char *arguments, char *result) {
+    const char *next = arguments;
+
+    if(*next == ',' || *next == ' ') next++;
+    A1 arg1 = parse_arg<A1>(next,&next);
+
+    if(*next == ',' || *next == ' ') next++;
+    A2 arg2 = parse_arg<A2>(next,NULL);
+
+    R res = (static_cast<T*>(this_ptr)->*member)(arg1,arg2);
+    if(result != NULL) {
+        write_result<R>(res, result);
+    }
+}
+
+struct rpc_method { 
+    const char *name;
+    void (*caller)(Base*, const char*, char*);
+};
+    
+#define RPC_METHOD_END { NULL, NULL }
+
+
+/* Function rpc
+ *  Parse a string describing a call and then do it
+ *
+ * Variables
+ *  call - A pointer to a string describing the call, which has
+ *    the form /object/method arg ... argn. Arguments are
+ *    delimited by space characters, and the string is terminated
+ *    by a null character.
+ *  result - A pointer to an array to write the result into.
+ */
+bool rpc(const char *buf, char *result = 0);
+
+} /* namespace mbed */
+
+#endif
--- a/stackheap.h	Fri Nov 14 15:25:20 2008 +0000
+++ b/stackheap.h	Thu Nov 27 16:23:24 2008 +0000
@@ -73,7 +73,11 @@
 
 
 inline int stack_limit() {
+#ifdef __GNUC__
+	return (unsigned)__builtin_frame_address(0);
+#else
 	return __current_sp();
+#endif
 }
 
 inline int stack_size() {