Merge pull request #1795 from 0xc0170/dev_mbedos_additions

Small changes (docs plus assert)
pull/1804/head
Sam Grove 2016-05-28 09:02:04 +08:00
commit 60c862c206
5 changed files with 27 additions and 7 deletions

View File

@ -19,6 +19,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* General C++ Object Thunking class
*
* - allows direct callbacks to non-static C++ class functions
* - keeps track for the corresponding class instance
* - supports an optional context parameter for the called function
* - ideally suited for class object receiving interrupts (NVIC_SetVector)
*/
#ifndef __CTHUNK_H__ #ifndef __CTHUNK_H__
#define __CTHUNK_H__ #define __CTHUNK_H__

View File

@ -82,7 +82,7 @@ public:
* *
* @param location The location to seek to. Must be a value returned by telldir. * @param location The location to seek to. Must be a value returned by telldir.
*/ */
virtual void seekdir(off_t location) { } virtual void seekdir(off_t location) { (void)location;}
virtual ~DirHandle() {} virtual ~DirHandle() {}
}; };

View File

@ -61,7 +61,7 @@ public:
* @param filename the name of the file to remove. * @param filename the name of the file to remove.
* @param returns 0 on success, -1 on failure. * @param returns 0 on success, -1 on failure.
*/ */
virtual int remove(const char *filename) { return -1; }; virtual int remove(const char *filename) { (void) filename; return -1; };
/** Rename a file in the filesystem. /** Rename a file in the filesystem.
* *
@ -72,7 +72,7 @@ public:
* 0 on success, * 0 on success,
* -1 on failure. * -1 on failure.
*/ */
virtual int rename(const char *oldname, const char *newname) { return -1; }; virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; };
/** Opens a directory in the filesystem and returns a DirHandle /** Opens a directory in the filesystem and returns a DirHandle
* representing the directory stream. * representing the directory stream.
@ -83,7 +83,7 @@ public:
* A DirHandle representing the directory stream, or * A DirHandle representing the directory stream, or
* NULL on failure. * NULL on failure.
*/ */
virtual DirHandle *opendir(const char *name) { return NULL; }; virtual DirHandle *opendir(const char *name) { (void) name; return NULL; };
/** Creates a directory in the filesystem. /** Creates a directory in the filesystem.
* *
@ -94,7 +94,7 @@ public:
* 0 on success, * 0 on success,
* -1 on failure. * -1 on failure.
*/ */
virtual int mkdir(const char *name, mode_t mode) { return -1; } virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; }
// TODO other filesystem functions (mkdir, rm, rn, ls etc) // TODO other filesystem functions (mkdir, rm, rn, ls etc)
}; };

View File

@ -28,6 +28,7 @@
// mbed Debug libraries // mbed Debug libraries
#include "mbed_error.h" #include "mbed_error.h"
#include "mbed_interface.h" #include "mbed_interface.h"
#include "mbed_assert.h"
// mbed Peripheral components // mbed Peripheral components
#include "DigitalIn.h" #include "DigitalIn.h"

View File

@ -14,9 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
#include "mbed_assert.h" #include "mbed_assert.h"
#include "mbed_error.h" #include "device.h"
#if DEVICE_STDIO_MESSAGES
#include <stdio.h>
#endif
#include <stdlib.h>
#include "mbed_interface.h"
void mbed_assert_internal(const char *expr, const char *file, int line) void mbed_assert_internal(const char *expr, const char *file, int line)
{ {
error("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); #if DEVICE_STDIO_MESSAGES
fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
#endif
mbed_die();
} }