Fork of the official mbed C/C++ SDK provides the software platform and libraries to build your applications. The fork has the documentation converted to Doxygen format

Dependents:   NervousPuppySprintOne NervousPuppySprint2602 Robot WarehouseBot1 ... more

Fork of mbed by mbed official

Files at this revision

API Documentation at this revision

Comitter:
simon.ford@mbed.co.uk
Date:
Wed Apr 15 14:15:04 2009 +0000
Parent:
8:00a04e5cd407
Child:
10:fcb9359f0959
Commit message:
Update library with fixes
* TimerEvent hang bugfix
* FileLike use as file pointer

Changed in this revision

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
LocalFileSystem.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
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
--- a/FileLike.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/FileLike.h	Wed Apr 15 14:15:04 2009 +0000
@@ -22,6 +22,7 @@
      *  name - The name to use to open the file.
      */
     FileLike(const char *name) : Base(name) { }
+    virtual ~FileLike();
 
 };
 
--- a/FileSystemLike.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/FileSystemLike.h	Wed Apr 15 14:15:04 2009 +0000
@@ -84,6 +84,7 @@
      *
      * Variables
      *  name - The name of the directory to create.
+     *  mode - The permissions to create the directory with.
      *  returns - 0 on success, -1 on failure.
      */
     virtual int mkdir(const char *name, mode_t mode) { return -1; }
--- a/FunctionPointer.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/FunctionPointer.h	Wed Apr 15 14:15:04 2009 +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/LocalFileSystem.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/LocalFileSystem.h	Wed Apr 15 14:15:04 2009 +0000
@@ -1,60 +1,60 @@
-/* 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);                               
- * >     remove("/local/out.txt");                 // Removes the file "out.txt" from the local file system
- * >
- * >     DIR *d = opendir("/local");               // Opens the root directory of the local file system
- * >     struct dirent *p;
- * >     while((p = readdir(d)) != NULL) {         // Print the names of the files in the local file system
- * >       printf("%s\n", p->d_name);              // to stdout.
- * >     }
- * >     closedir(d);
- * > }
- *
- * 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);
-    virtual DirHandle *opendir(const char *name);
-};
-
-} // namespace mbed
-
-#endif
+/* 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);                               
+ * >     remove("/local/out.txt");                 // Removes the file "out.txt" from the local file system
+ * >
+ * >     DIR *d = opendir("/local");               // Opens the root directory of the local file system
+ * >     struct dirent *p;
+ * >     while((p = readdir(d)) != NULL) {         // Print the names of the files in the local file system
+ * >       printf("%s\n", p->d_name);              // to stdout.
+ * >     }
+ * >     closedir(d);
+ * > }
+ *
+ * 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);
+    virtual DirHandle *opendir(const char *name);
+};
+
+} // namespace mbed
+
+#endif
--- a/Ticker.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/Ticker.h	Wed Apr 15 14:15:04 2009 +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	Tue Feb 03 18:02:02 2009 +0000
+++ b/Timeout.h	Wed Apr 15 14:15:04 2009 +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/TimerEvent.h	Tue Feb 03 18:02:02 2009 +0000
+++ b/TimerEvent.h	Wed Apr 15 14:15:04 2009 +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	Tue Feb 03 18:02:02 2009 +0000
+++ b/mbed.h	Wed Apr 15 14:15:04 2009 +0000
@@ -5,7 +5,7 @@
 #ifndef MBED_H
 #define MBED_H
 
-#define MBED_LIBRARY_VERSION 9
+#define MBED_LIBRARY_VERSION 10
  
 // Useful C libraries
 #include <stdio.h>