reef monitor
Dependencies: mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed
Fork of HTTPServerHelloWorld by
Revision 3:5dc0023e6284, committed 2014-01-31
- Comitter:
- wyunreal
- Date:
- Fri Jan 31 23:19:28 2014 +0000
- Parent:
- 2:bd69e4df7955
- Child:
- 4:a19825caaf41
- Commit message:
- First approach of EthernetService class
Changed in this revision
--- a/EthernetNetIf.lib Fri Jul 09 14:46:34 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- a/HTTPServerHelloWorld.cpp Fri Jul 09 14:46:34 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#include "mbed.h"
-#include "EthernetNetIf.h"
-#include "HTTPServer.h"
-
-EthernetNetIf eth;
-HTTPServer svr;
-
-DigitalOut led1(LED1);
-
-int main() {
- printf("Setting up...\n");
- EthernetErr ethErr = eth.setup();
- if(ethErr)
- {
- printf("Error %d in setup.\n", ethErr);
- return -1;
- }
- printf("Setup OK\n");
-
- svr.addHandler<SimpleHandler>("/"); //Default handler
- svr.bind(80);
-
- printf("Listening...\n");
-
- Timer tm;
- tm.start();
- //Listen indefinitely
- while(true)
- {
- Net::poll();
- if(tm.read()>.5)
- {
- led1=!led1; //Show that we are alive
- tm.start();
- }
- }
-
- return 0;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HardwareDrivers/EthernetNetIf.lib Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/EthernetNetIf/#fdadb6a6223c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/donatien/code/NTPClient_NetServices/#7c3f1199256a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Services/EthernetService.cpp Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,25 @@
+#include "EthernetService.h"
+
+EthernetService::EthernetService() {
+ ethernetInterface = new EthernetNetIf();
+ ntpClient = new NTPClient();
+}
+
+EthernetService::~EthernetService() {
+ delete ntpClient;
+ delete ethernetInterface;
+}
+
+int EthernetService::setup() {
+ EthernetErr ethErr = ethernetInterface->setup();
+ if(ethErr) {
+ return 0;
+ }
+ return 1;
+}
+
+int EthernetService::setRtcTime() {
+ Host server(IpAddr(), 123, "0.es.pool.ntp.org");
+ ntpClient->setTime(server);
+ return 1;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Services/EthernetService.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,20 @@
+#ifndef ETHERNET_SERVICE_H
+#define ETHERNET_SERVICE_H
+
+#include "EthernetNetIf.h"
+#include "NTPClient.h"
+
+class EthernetService {
+ private:
+ EthernetNetIf* ethernetInterface;
+ NTPClient* ntpClient;
+
+ public:
+ EthernetService();
+ ~EthernetService();
+
+ int setup();
+ int setRtcTime();
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "HTTPServer.h"
+#include "EthernetService.h"
+#include "NTPClient.h"
+
+EthernetService ethernetService;
+
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+
+int main() {
+ printf("Setting up Ethernet ...\n");
+ if(!ethernetService.setup()) {
+ printf("Error starting ethernet service\n");
+ } else {
+ ethernetService.setRtcTime();
+ }
+
+
+
+Ethernet ethf;
+HTTPServer svr;
+
+ svr.addHandler<SimpleHandler>("/"); //Default handler
+ svr.bind(80);
+
+ printf("Listening on port 80 ...\n");
+
+ Timer tm;
+ tm.start();
+ //Listen indefinitely
+ while(true)
+ {
+ if(ethf.link()) {
+ led4 = 1;
+ } else {
+ led4 = 0;
+ }
+
+ Net::poll();
+ if(tm.read()>.5)
+ {
+ led1=!led1; //Show that we are alive
+ tm.start();
+ }
+ }
+}
--- a/mbed.bld Fri Jul 09 14:46:34 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/AnalogIn.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,94 @@
+/* mbed Microcontroller Library - AnalogIn
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_ANALOGIN_H
+#define MBED_ANALOGIN_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: AnalogIn
+ * An analog input, used for reading the voltage on a pin
+ *
+ * Example:
+ * > // Print messages when the AnalogIn is greater than 50%
+ * >
+ * > #include "mbed.h"
+ * >
+ * > AnalogIn temperature(p20);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > if(temperature > 0.5) {
+ * > printf("Too hot! (%f)", temperature.read());
+ * > }
+ * > }
+ * > }
+ */
+class AnalogIn : public Base {
+
+public:
+
+ /* Constructor: AnalogIn
+ * Create an AnalogIn, connected to the specified pin
+ *
+ * Variables:
+ * pin - AnalogIn pin to connect to
+ * name - (optional) A string to identify the object
+ */
+ AnalogIn(PinName pin, const char *name = NULL);
+
+ /* Function: read
+ * Read the input voltage, represented as a float in the range [0.0, 1.0]
+ *
+ * Variables:
+ * returns - A floating-point value representing the current input voltage,
+ * measured as a percentage
+ */
+ float read();
+
+ /* Function: read_u16
+ * Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
+ *
+ * Variables:
+ * returns - 16-bit unsigned short representing the current input voltage,
+ * normalised to a 16-bit value
+ */
+ unsigned short read_u16();
+
+#ifdef MBED_OPERATORS
+ /* Function: operator float
+ * An operator shorthand for <read()>
+ *
+ * The float() operator can be used as a shorthand for <read()> to simplify common code sequences
+ *
+ * Example:
+ * > float x = volume.read();
+ * > float x = volume;
+ * >
+ * > if(volume.read() > 0.25) { ... }
+ * > if(volume > 0.25) { ... }
+ */
+ operator float();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ ADCName _adc;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/AnalogOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,108 @@
+/* mbed Microcontroller Library - AnalogOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_ANALOGOUT_H
+#define MBED_ANALOGOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: AnalogOut
+ * An analog output, used for setting the voltage on a pin
+ *
+ * Example:
+ * > // Make a sawtooth output
+ * >
+ * > #include "mbed.h"
+ * >
+ * > AnalogOut tri(p18);
+ * > int main() {
+ * > while(1) {
+ * > tri = tri + 0.01;
+ * > wait_us(1);
+ * > if(tri == 1) {
+ * > tri = 0;
+ * > }
+ * > }
+ * > }
+ */
+class AnalogOut : public Base {
+
+public:
+
+ /* Constructor: AnalogOut
+ * Create an AnalogOut connected to the specified pin
+ *
+ * Variables:
+ * pin - AnalogOut pin to connect to (18)
+ */
+ AnalogOut(PinName pin, const char *name = NULL);
+
+ /* Function: write
+ * Set the output voltage, specified as a percentage (float)
+ *
+ * Variables:
+ * percent - A floating-point value representing the output voltage,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
+ * Values outside this range will be saturated to 0.0f or 1.0f.
+ */
+ void write(float value);
+
+ /* Function: write_u16
+ * Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
+ *
+ * Variables:
+ * value - 16-bit unsigned short representing the output voltage,
+ * normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
+ */
+ void write_u16(unsigned short value);
+
+ /* Function: read
+ * Return the current output voltage setting, measured as a percentage (float)
+ *
+ * Variables:
+ * returns - A floating-point value representing the current voltage being output on the pin,
+ * measured as a percentage. The returned value will lie between
+ * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
+ *
+ * Note:
+ * This value may not match exactly the value set by a previous <write>.
+ */
+ float read();
+
+
+#ifdef MBED_OPERATORS
+ /* Function: operator=
+ * An operator shorthand for <write()>
+ */
+ AnalogOut& operator= (float percent);
+ AnalogOut& operator= (AnalogOut& rhs);
+
+ /* Function: operator float()
+ * An operator shorthand for <read()>
+ */
+ operator float();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ DACName _dac;
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Base.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,226 @@
+/* mbed Microcontroller Library - Base
+ * Copyright (c) 2006-2008 ARM Limited. All rights reserved.
+ * sford, jbrawn
+ */
+
+#ifndef MBED_BASE_H
+#define MBED_BASE_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include <cstdlib>
+#include "DirHandle.h"
+
+namespace mbed {
+
+#ifdef MBED_RPC
+struct rpc_function {
+ const char *name;
+ void (*caller)(const char*, char*);
+};
+
+struct rpc_class {
+ const char *name;
+ const rpc_function *static_functions;
+ struct rpc_class *next;
+};
+#endif
+
+/* Class Base
+ * The base class for most things
+ */
+class Base {
+
+public:
+
+ Base(const char *name = NULL);
+
+ 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();
+
+#ifdef MBED_RPC
+
+ /* 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);
+
+ /* Function get_rpc_methods
+ * Returns a pointer to an array describing the rpc methods
+ * supported by this object, terminated by either
+ * RPC_METHOD_END or RPC_METHOD_SUPER(Superclass).
+ *
+ * Example
+ * > class Example : public Base {
+ * > int foo(int a, int b) { return a + b; }
+ * > virtual const struct rpc_method *get_rpc_methods() {
+ * > static const rpc_method rpc_methods[] = {
+ * > { "foo", generic_caller<int, Example, int, int, &Example::foo> },
+ * > RPC_METHOD_SUPER(Base)
+ * > };
+ * > return rpc_methods;
+ * > }
+ * > };
+ */
+ virtual const struct rpc_method *get_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);
+
+#endif
+
+ /* 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);
+
+ static DirHandle *opendir();
+ friend class BaseDirHandle;
+
+protected:
+
+ static Base *_head;
+ Base *_next;
+ const char *_name;
+ bool _from_construct;
+
+private:
+
+#ifdef MBED_RPC
+ static rpc_class *_classes;
+
+ static const rpc_function _base_funcs[];
+ static rpc_class _base_class;
+#endif
+
+ void delete_self();
+ static void list_objs(const char *arguments, char *result);
+ static void clear(const char*,char*);
+
+ static char *new_name(Base *p);
+
+public:
+
+#ifdef MBED_RPC
+ /* Function add_rpc_class
+ * Add the class to the list of classes which can have static
+ * methods called via rpc (the static methods which can be called
+ * are defined by that class' get_rpc_class() static method).
+ */
+ template<class C>
+ static void add_rpc_class() {
+ rpc_class *c = C::get_rpc_class();
+ c->next = _classes;
+ _classes = c;
+ }
+
+ template<class C>
+ static const char *construct() {
+ Base *p = new C();
+ p->_from_construct = true;
+ if(p->_name==NULL) {
+ p->register_object(new_name(p));
+ }
+ return p->_name;
+ }
+
+ template<class C, typename A1>
+ static const char *construct(A1 arg1) {
+ Base *p = new C(arg1);
+ p->_from_construct = true;
+ if(p->_name==NULL) {
+ p->register_object(new_name(p));
+ }
+ return p->_name;
+ }
+
+ template<class C, typename A1, typename A2>
+ static const char *construct(A1 arg1, A2 arg2) {
+ Base *p = new C(arg1,arg2);
+ p->_from_construct = true;
+ if(p->_name==NULL) {
+ p->register_object(new_name(p));
+ }
+ return p->_name;
+ }
+
+ template<class C, typename A1, typename A2, typename A3>
+ static const char *construct(A1 arg1, A2 arg2, A3 arg3) {
+ Base *p = new C(arg1,arg2,arg3);
+ p->_from_construct = true;
+ if(p->_name==NULL) {
+ p->register_object(new_name(p));
+ }
+ return p->_name;
+ }
+
+ template<class C, typename A1, typename A2, typename A3, typename A4>
+ static const char *construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4) {
+ Base *p = new C(arg1,arg2,arg3,arg4);
+ p->_from_construct = true;
+ if(p->_name==NULL) {
+ p->register_object(new_name(p));
+ }
+ return p->_name;
+ }
+#endif
+
+};
+
+/* 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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/BusIn.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,83 @@
+/* mbed Microcontroller Library - DigitalIn
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford, rmeyer
+ */
+
+#ifndef MBED_BUSIN_H
+#define MBED_BUSIN_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+#include "DigitalIn.h"
+
+namespace mbed {
+
+/* Class: BusIn
+ * A digital input bus, used for reading the state of a collection of pins
+ */
+class BusIn : public Base {
+
+public:
+
+ /* Group: Configuration Methods */
+
+ /* Constructor: BusIn
+ * Create an BusIn, connected to the specified pins
+ *
+ * Variables:
+ * p<n> - DigitalIn pin to connect to bus bit <n> (p5-p30, NC)
+ *
+ * Note:
+ * It is only required to specify as many pin variables as is required
+ * for the bus; the rest will default to NC (not connected)
+ */
+ BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
+ PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
+ PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
+ PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC,
+ const char *name = NULL);
+
+ BusIn(PinName pins[16], const char *name = NULL);
+
+ virtual ~BusIn();
+
+ /* Group: Access Methods */
+
+ /* Function: read
+ * Read the value of the input bus
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to the value read from the associated DigitalIn pin
+ */
+ int read();
+
+#ifdef MBED_OPERATORS
+ /* Group: Access Method Shorthand */
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ DigitalIn* _pin[16];
+
+#ifdef MBED_RPC
+ static void construct(const char *arguments, char *res);
+#endif
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/BusInOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,116 @@
+/* mbed Microcontroller Library - BusInOut
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * sford, rmeyer
+ */
+
+#ifndef MBED_BUSINOUT_H
+#define MBED_BUSINOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+#include "DigitalInOut.h"
+
+namespace mbed {
+
+/* Class: BusInOut
+ * A digital input output bus, used for setting the state of a collection of pins
+ */
+class BusInOut : public Base {
+
+public:
+
+ /* Group: Configuration Methods */
+
+ /* Constructor: BusInOut
+ * Create an BusInOut, connected to the specified pins
+ *
+ * Variables:
+ * p<n> - DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
+ *
+ * Note:
+ * It is only required to specify as many pin variables as is required
+ * for the bus; the rest will default to NC (not connected)
+ */
+ BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
+ PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
+ PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
+ PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC,
+ const char *name = NULL);
+
+ BusInOut(PinName pins[16], const char *name = NULL);
+
+ virtual ~BusInOut();
+
+ /* Group: Access Methods */
+
+ /* Function: write
+ * Write the value to the output bus
+ *
+ * Variables:
+ * value - An integer specifying a bit to write for every corresponding DigitalInOut pin
+ */
+ void write(int value);
+
+
+ /* Function: read
+ * Read the value currently output on the bus
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to associated DigitalInOut pin setting
+ */
+ int read();
+
+ /* Function: output
+ * Set as an output
+ */
+ void output();
+
+ /* Function: input
+ * Set as an input
+ */
+ void input();
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone
+ */
+ void mode(PinMode pull);
+
+#ifdef MBED_OPERATORS
+ /* Group: Access Method Shorthand */
+
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ BusInOut& operator= (int v);
+ BusInOut& operator= (BusInOut& rhs);
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ DigitalInOut* _pin[16];
+
+#ifdef MBED_RPC
+ static void construct(const char *arguments, char *res);
+#endif
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/BusOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,98 @@
+/* mbed Microcontroller Library - BusOut
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford, rmeyer
+ */
+
+#ifndef MBED_BUSOUT_H
+#define MBED_BUSOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+#include "DigitalOut.h"
+
+namespace mbed {
+
+/* Class: BusOut
+ * A digital output bus, used for setting the state of a collection of pins
+ */
+class BusOut : public Base {
+
+public:
+
+ /* Group: Configuration Methods */
+
+ /* Constructor: BusOut
+ * Create an BusOut, connected to the specified pins
+ *
+ * Variables:
+ * p<n> - DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
+ *
+ * Note:
+ * It is only required to specify as many pin variables as is required
+ * for the bus; the rest will default to NC (not connected)
+ */
+ BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
+ PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
+ PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
+ PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC,
+ const char *name = NULL);
+
+ BusOut(PinName pins[16], const char *name = NULL);
+
+ virtual ~BusOut();
+
+ /* Group: Access Methods */
+
+ /* Function: write
+ * Write the value to the output bus
+ *
+ * Variables:
+ * value - An integer specifying a bit to write for every corresponding DigitalOut pin
+ */
+ void write(int value);
+
+
+ /* Function: read
+ * Read the value currently output on the bus
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to associated DigitalOut pin setting
+ */
+ int read();
+
+#ifdef MBED_OPERATORS
+ /* Group: Access Method Shorthand */
+
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ BusOut& operator= (int v);
+ BusOut& operator= (BusOut& rhs);
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ DigitalOut* _pin[16];
+
+#ifdef MBED_RPC
+ static void construct(const char *arguments, char *res);
+#endif
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/CAN.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,240 @@
+/* mbed Microcontroller Library - can
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * rmeyer
+ */
+
+#ifndef MBED_CAN_H
+#define MBED_CAN_H
+
+#include "Base.h"
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+
+#include "can_helper.h"
+#include "FunctionPointer.h"
+
+#include <string.h>
+
+namespace mbed {
+
+/* Class: CANMessage
+ *
+ */
+class CANMessage : public CAN_Message {
+
+public:
+
+ /* Constructor: CANMessage
+ * Creates empty CAN message.
+ */
+ CANMessage() {
+ len = 8;
+ type = CANData;
+ format = CANStandard;
+ id = 0;
+ memset(data, 0, 8);
+ }
+
+ /* Constructor: CANMessage
+ * Creates CAN message with specific content.
+ */
+ CANMessage(int _id, const char *_data, char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) {
+ len = _len & 0xF;
+ type = _type;
+ format = _format;
+ id = _id;
+ memcpy(data, _data, _len);
+ }
+
+ /* Constructor: CANMessage
+ * Creates CAN remote message.
+ */
+ CANMessage(int _id, CANFormat _format = CANStandard) {
+ len = 0;
+ type = CANRemote;
+ format = _format;
+ id = _id;
+ memset(data, 0, 8);
+ }
+#if 0 // Inhereted from CAN_Message, for documentation only
+
+ /* Variable: id
+ * The message id.
+ *
+ * If format is CANStandard it must be an 11 bit long id
+ * If format is CANExtended it must be an 29 bit long id
+ */
+ unsigned int id;
+
+ /* Variable: data
+ * Space for 8 byte payload.
+ *
+ * If type is CANData data can store up to 8 byte data.
+ */
+ unsigned char data[8];
+
+ /* Variable: len
+ * Length of data in bytes.
+ *
+ * If type is CANData data can store up to 8 byte data.
+ */
+ unsigned char len;
+
+ /* Variable: format
+ * Defines if the message has standard or extended format.
+ *
+ * Defines the type of message id:
+ * Default is CANStandard which implies 11 bit id.
+ * CANExtended means 29 bit message id.
+ */
+ CANFormat format;
+
+ /* Variable: type
+ * Defines the type of a message.
+ *
+ * The message type can rather be CANData for a message with data (default).
+ * Or CANRemote for a request of a specific CAN message.
+ */
+ CANType type; // 0 - DATA FRAME, 1 - REMOTE FRAME
+#endif
+};
+
+/* Class: CAN
+ * A can bus client, used for communicating with can devices
+ */
+class CAN : public Base {
+
+public:
+
+ /* Constructor: CAN
+ * Creates an CAN interface connected to specific pins.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > Ticker ticker;
+ * > DigitalOut led1(LED1);
+ * > DigitalOut led2(LED2);
+ * > CAN can1(p9, p10);
+ * > CAN can2(p30, p29);
+ * >
+ * > char counter = 0;
+ * >
+ * > void send() {
+ * > if(can1.write(CANMessage(1337, &counter, 1))) {
+ * > printf("Message sent: %d\n", counter);
+ * > counter++;
+ * > }
+ * > led1 = !led1;
+ * > }
+ * >
+ * > int main() {
+ * > ticker.attach(&send, 1);
+ * > CANMessage msg;
+ * > while(1) {
+ * > if(can2.read(msg)) {
+ * > printf("Message received: %d\n\n", msg.data[0]);
+ * > led2 = !led2;
+ * > }
+ * > wait(0.2);
+ * > }
+ * > }
+ *
+ * Variables:
+ * rd - read from transmitter
+ * td - transmit to transmitter
+ */
+ CAN(PinName rd, PinName td);
+ virtual ~CAN();
+
+ /* Function: frequency
+ * Set the frequency of the CAN interface
+ *
+ * Variables:
+ * hz - The bus frequency in hertz
+ * returns - 1 if successful, 0 otherwise
+ */
+ int frequency(int hz);
+
+ /* Function: write
+ * Write a CANMessage to the bus.
+ *
+ * Variables:
+ * msg - The CANMessage to write.
+ *
+ * Returns:
+ * 0 - If write failed.
+ * 1 - If write was successful.
+ */
+ int write(CANMessage msg);
+
+ /* Function: read
+ * Read a CANMessage from the bus.
+ *
+ * Variables:
+ * msg - A CANMessage to read to.
+ *
+ * Returns:
+ * 0 - If no message arrived.
+ * 1 - If message arrived.
+ */
+ int read(CANMessage &msg);
+
+ /* Function: reset
+ * Reset CAN interface.
+ *
+ * To use after error overflow.
+ */
+ void reset();
+
+ /* Function: monitor
+ * Puts or removes the CAN interface into silent monitoring mode
+ *
+ * Variables:
+ * silent - boolean indicating whether to go into silent mode or not
+ */
+ void monitor(bool silent);
+
+ /* Function: rderror
+ * Returns number of read errors to detect read overflow errors.
+ */
+ unsigned char rderror();
+
+ /* Function: tderror
+ * Returns number of write errors to detect write overflow errors.
+ */
+ unsigned char tderror();
+
+ /* Function: attach
+ * Attach a function to call whenever a CAN frame received interrupt is
+ * generated.
+ *
+ * Variables:
+ * fptr - A pointer to a void function, or 0 to set as none
+ */
+ void attach(void (*fptr)(void));
+
+ /* Function attach
+ * Attach a member function to call whenever a CAN frame received interrupt
+ * is generated.
+ *
+ * Variables:
+ * tptr - pointer to the object to call the member function on
+ * mptr - pointer to the member function to be called
+ */
+ template<typename T>
+ void attach(T* tptr, void (T::*mptr)(void));
+
+private:
+
+ CANName _id;
+ FunctionPointer _rxirq;
+
+ void setup_interrupt(void);
+ void remove_interrupt(void);
+};
+
+} // namespace mbed
+
+#endif // MBED_CAN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/DigitalIn.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,95 @@
+/* mbed Microcontroller Library - DigitalIn
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_DIGITALIN_H
+#define MBED_DIGITALIN_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: DigitalIn
+ * A digital input, used for reading the state of a pin
+ *
+ * Example:
+ * > // Flash an LED while a DigitalIn is true
+ * >
+ * > #include "mbed.h"
+ * >
+ * > DigitalIn enable(p5);
+ * > DigitalOut led(LED1);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > if(enable) {
+ * > led = !led;
+ * > }
+ * > wait(0.25);
+ * > }
+ * > }
+ */
+class DigitalIn : public Base {
+
+public:
+
+ /* Constructor: DigitalIn
+ * Create a DigitalIn connected to the specified pin
+ *
+ * Variables:
+ * pin - DigitalIn pin to connect to
+ * name - (optional) A string to identify the object
+ */
+ DigitalIn(PinName pin, const char *name = NULL);
+
+ /* Function: read
+ * Read the input, represented as 0 or 1 (int)
+ *
+ * Variables:
+ * returns - An integer representing the state of the input pin,
+ * 0 for logical 0 and 1 for logical 1
+ */
+ int read() {
+ return ((_gpio->FIOPIN & _mask) ? 1 : 0);
+ }
+
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone, OpenDrain
+ */
+ void mode(PinMode pull);
+
+#ifdef MBED_OPERATORS
+ /* Function: operator int()
+ * An operator shorthand for <read()>
+ */
+ operator int() {
+ return read();
+ }
+
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ PinName _pin;
+ LPC_GPIO_TypeDef *_gpio;
+ uint32_t _mask;
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/DigitalInOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,113 @@
+/* mbed Microcontroller Library - DigitalInOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_DIGITALINOUT_H
+#define MBED_DIGITALINOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: DigitalInOut
+ * A digital input/output, used for setting or reading a bi-directional pin
+ */
+class DigitalInOut : public Base {
+
+public:
+
+ /* Constructor: DigitalInOut
+ * Create a DigitalInOut connected to the specified pin
+ *
+ * Variables:
+ * pin - DigitalInOut pin to connect to
+ */
+ DigitalInOut(PinName pin, const char* name = NULL);
+
+ /* Function: write
+ * Set the output, specified as 0 or 1 (int)
+ *
+ * Variables:
+ * value - An integer specifying the pin output value,
+ * 0 for logical 0 and 1 (or any other non-zero value) for logical 1
+ */
+ void write(int value) {
+ if(value) {
+ _gpio->FIOSET = _mask;
+ } else {
+ _gpio->FIOCLR = _mask;
+ }
+ }
+
+ /* Function: read
+ * Return the output setting, represented as 0 or 1 (int)
+ *
+ * Variables:
+ * returns - An integer representing the output setting of the pin if it is an output,
+ * or read the input if set as an input
+ */
+ int read() {
+ return ((_gpio->FIOPIN & _mask) ? 1 : 0);
+ }
+
+
+ /* Function: output
+ * Set as an output
+ */
+ void output();
+
+ /* Function: input
+ * Set as an input
+ */
+ void input();
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone, OpenDrain
+ */
+ void mode(PinMode pull);
+
+#ifdef MBED_OPERATORS
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ DigitalInOut& operator= (int value) {
+ write(value);
+ return *this;
+ }
+
+ DigitalInOut& operator= (DigitalInOut& rhs) {
+ write(rhs.read());
+ return *this;
+ }
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int() {
+ return read();
+ }
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ PinName _pin;
+ LPC_GPIO_TypeDef *_gpio;
+ uint32_t _mask;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/DigitalOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,111 @@
+/* mbed Microcontroller Library - DigitalOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_DIGITALOUT_H
+#define MBED_DIGITALOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: DigitalOut
+ * A digital output, used for setting the state of a pin
+ *
+ * Example:
+ * > // Toggle a LED
+ * > #include "mbed.h"
+ * >
+ * > DigitalOut led(LED1);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > led = !led;
+ * > wait(0.2);
+ * > }
+ * > }
+ */
+class DigitalOut : public Base {
+
+public:
+
+ /* Constructor: DigitalOut
+ * Create a DigitalOut connected to the specified pin
+ *
+ * Variables:
+ * pin - DigitalOut pin to connect to
+ */
+ DigitalOut(PinName pin, const char* name = NULL);
+
+ /* Function: write
+ * Set the output, specified as 0 or 1 (int)
+ *
+ * Variables:
+ * value - An integer specifying the pin output value,
+ * 0 for logical 0 and 1 (or any other non-zero value) for logical 1
+ */
+ void write(int value) {
+ if(value) {
+ _gpio->FIOSET = _mask;
+ } else {
+ _gpio->FIOCLR = _mask;
+ }
+ }
+
+ /* Function: read
+ * Return the output setting, represented as 0 or 1 (int)
+ *
+ * Variables:
+ * returns - An integer representing the output setting of the pin,
+ * 0 for logical 0 and 1 for logical 1
+ */
+ int read() {
+ return ((_gpio->FIOPIN & _mask) ? 1 : 0);
+ }
+
+
+#ifdef MBED_OPERATORS
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ DigitalOut& operator= (int value) {
+ write(value);
+ return *this;
+ }
+
+ DigitalOut& operator= (DigitalOut& rhs) {
+ write(rhs.read());
+ return *this;
+ }
+
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int() {
+ return read();
+ }
+
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ PinName _pin;
+ LPC_GPIO_TypeDef *_gpio;
+ uint32_t _mask;
+
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/DirHandle.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,97 @@
+/* mbed Microcontroller Library - DirHandler
+ * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_DIRHANDLE_H
+#define MBED_DIRHANDLE_H
+
+#ifdef __ARMCC_VERSION
+# define NAME_MAX 255
+typedef int mode_t;
+#else
+# include <sys/syslimits.h>
+#endif
+#include "FileHandle.h"
+
+struct dirent {
+ char d_name[NAME_MAX+1];
+};
+
+namespace mbed {
+
+/* Class DirHandle
+ * Represents a directory stream. Objects of this type are returned
+ * by a FileSystemLike's opendir method. Implementations must define
+ * at least closedir, readdir and rewinddir.
+ *
+ * If a FileSystemLike class defines the opendir method, then the
+ * directories of an object of that type can be accessed by
+ * DIR *d = opendir("/example/directory") (or opendir("/example")
+ * to open the root of the filesystem), and then using readdir(d) etc.
+ *
+ * The root directory is considered to contain all FileLike and
+ * FileSystemLike objects, so the DIR* returned by opendir("/") will
+ * reflect this.
+ */
+class DirHandle {
+
+ public:
+ /* Function closedir
+ * Closes the directory.
+ *
+ * Variables
+ * returns - 0 on success, or -1 on error.
+ */
+ virtual int closedir()=0;
+
+ /* Function readdir
+ * Return the directory entry at the current position, and
+ * advances the position to the next entry.
+ *
+ * Returns
+ * A pointer to a dirent structure representing the
+ * directory entry at the current position, or NULL on reaching
+ * end of directory or error.
+ */
+ virtual struct dirent *readdir()=0;
+
+ /* Function rewinddir
+ * Resets the position to the beginning of the directory.
+ */
+ virtual void rewinddir()=0;
+
+ /* Function telldir
+ * Returns the current position of the DirHandle.
+ *
+ * Returns
+ * The current position, or -1 on error.
+ */
+ virtual off_t telldir() { return -1; }
+
+ /* Function seekdir
+ * Sets the position of the DirHandle.
+ *
+ * Variables
+ * location - The location to seek to. Must be a value returned
+ * by telldir.
+ */
+ virtual void seekdir(off_t location) { }
+
+};
+
+} // namespace mbed
+
+typedef mbed::DirHandle DIR;
+
+extern "C" {
+ DIR *opendir(const char*);
+ struct dirent *readdir(DIR *);
+ int closedir(DIR*);
+ void rewinddir(DIR*);
+ long telldir(DIR*);
+ void seekdir(DIR*, long);
+ int mkdir(const char *name, mode_t n);
+};
+
+#endif /* MBED_DIRHANDLE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Ethernet.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,168 @@
+/* mbed Microcontroller Library - Ethernet
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * sford, rmeyer
+ */
+
+#ifndef MBED_ETHERNET_H
+#define MBED_ETHERNET_H
+
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: Ethernet
+ * An ethernet interface, to use with the ethernet pins.
+ *
+ * Example:
+ * > // Read destination and source from every ethernet packet
+ * >
+ * > #include "mbed.h"
+ * >
+ * > Ethernet eth;
+ * >
+ * > int main() {
+ * > char buf[0x600];
+ * >
+ * > while(1) {
+ * > int size = eth.receive();
+ * > if(size > 0) {
+ * > eth.read(buf, size);
+ * > printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ * > buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+ * > printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ * > buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
+ * > }
+ * >
+ * > wait(1);
+ * > }
+ * > }
+ *
+ */
+class Ethernet : public Base {
+
+public:
+
+ /* Constructor: Ethernet
+ * Initialise the ethernet interface.
+ */
+ Ethernet();
+
+ /* Destructor: Ethernet
+ * Powers the hardware down.
+ */
+ virtual ~Ethernet();
+
+ enum Mode {
+ AutoNegotiate
+ , HalfDuplex10
+ , FullDuplex10
+ , HalfDuplex100
+ , FullDuplex100
+ };
+
+ /* Function: write
+ * Writes into an outgoing ethernet packet.
+ *
+ * It will append size bytes of data to the previously written bytes.
+ *
+ * Variables:
+ * data - An array to write.
+ * size - The size of data.
+ *
+ * Returns:
+ * The number of written bytes.
+ */
+ int write(const char *data, int size);
+
+ /* Function: send
+ * Send an outgoing ethernet packet.
+ *
+ * After filling in the data in an ethernet packet it must be send.
+ * Send will provide a new packet to write to.
+ *
+ * Returns:
+ * 0 - If the sending was failed.
+ * 1 - If the package is successfully sent.
+ */
+ int send();
+
+ /* Function: receive
+ * Recevies an arrived ethernet packet.
+ *
+ * Receiving an ethernet packet will drop the last received ethernet packet
+ * and make a new ethernet packet ready to read.
+ * If no ethernet packet is arrived it will return 0.
+ *
+ * Returns:
+ * 0 - If no ethernet packet is arrived.
+ * The size of the arrived packet.
+ */
+ int receive();
+
+ /* Function: read
+ * Read from an recevied ethernet packet.
+ *
+ * After receive returnd a number bigger than 0it is
+ * possible to read bytes from this packet.
+ * Read will write up to size bytes into data.
+ *
+ * It is possible to use read multible times.
+ * Each time read will start reading after the last read byte before.
+ *
+ * Returns:
+ * The number of byte read.
+ */
+ int read(char *data, int size);
+
+ /* Function: address
+ * Gives the ethernet address of the mbed.
+ *
+ * Variables:
+ * mac - Must be a pointer to a 6 byte char array to copy the ethernet address in.
+ */
+ void address(char *mac);
+
+ /* Function: link
+ * Returns if an ethernet link is pressent or not. It takes a wile after Ethernet initializion to show up.
+ *
+ * Returns:
+ * 0 - If no ethernet link is pressent.
+ * 1 - If an ethernet link is pressent.
+ *
+ * Example:
+ * > // Using the Ethernet link function
+ * > #include "mbed.h"
+ * >
+ * > Ethernet eth;
+ * >
+ * > int main() {
+ * > wait(1); // Needed after startup.
+ * > if(eth.link()) {
+ * > printf("online\n");
+ * > } else {
+ * > printf("offline\n");
+ * > }
+ * > }
+ *
+ */
+ int link();
+
+ /* Function: set_link
+ * Sets the speed and duplex parameters of an ethernet link
+ *
+ * Variables:
+ * mode - the speed and duplex mode to set the link to:
+ *
+ * > AutoNegotiate Auto negotiate speed and duplex
+ * > HalfDuplex10 10 Mbit, half duplex
+ * > FullDuplex10 10 Mbit, full duplex
+ * > HalfDuplex100 100 Mbit, half duplex
+ * > FullDuplex100 100 Mbit, full duplex
+ */
+ void set_link(Mode mode);
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/FileHandle.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,115 @@
+/* mbed Microcontroller Library - FileHandler
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#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
+ * An OO equivalent of the internal FILEHANDLE variable
+ * and associated _sys_* functions
+ *
+ * FileHandle is an abstract class, needing at least sys_write and
+ * sys_read to be implmented for a simple interactive device
+ *
+ * No one ever directly tals to/instanciates a FileHandle - it gets
+ * created by FileSystem, and wrapped up by stdio
+ */
+class FileHandle {
+
+public:
+
+ /* Function write
+ * Write the contents of a buffer to the file
+ *
+ * Parameters
+ * buffer - the buffer to write from
+ * length - the number of characters to write
+ *
+ * Returns
+ * The number of characters written (possibly 0) on success, -1 on error.
+ */
+ virtual ssize_t write(const void* buffer, size_t length) = 0;
+
+ /* 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
+ *
+ * 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 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
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/FileLike.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,34 @@
+/* mbed Microcontroller Library - FileLike
+ * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#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) { }
+ virtual ~FileLike();
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/FileSystemLike.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,101 @@
+/* mbed Microcontroller Library - FileSystemLike
+ * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_FILESYSTEMLIKE_H
+#define MBED_FILESYSTEMLIKE_H
+
+#ifdef __ARMCC_VERSION
+# define O_RDONLY 0
+# define O_WRONLY 1
+# define O_RDWR 2
+# define O_CREAT 0x0200
+# define O_TRUNC 0x0400
+# define O_APPEND 0x0008
+typedef int mode_t;
+#else
+# include <sys/fcntl.h>
+#endif
+#include "Base.h"
+#include "FileHandle.h"
+#include "DirHandle.h"
+
+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, OR'd with
+ * zero or more of O_CREAT, O_TRUNC, 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; };
+
+ /* Function opendir
+ * Opens a directory in the filesystem and returns a DirHandle
+ * representing the directory stream.
+ *
+ * Variables
+ * name - The name of the directory to open.
+ * returns - A DirHandle representing the directory stream, or
+ * NULL on failure.
+ */
+ virtual DirHandle *opendir(const char *name) { return NULL; };
+
+ /* Function mkdir
+ * Creates a directory in the filesystem.
+ *
+ * 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; }
+
+ // TODO other filesystem functions (mkdir, rm, rn, ls etc)
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/FunctionPointer.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,87 @@
+/* mbed Microcontroller Library - FunctionPointer
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * 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
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/I2C.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,136 @@
+/* mbed Microcontroller Library - I2C
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_I2C_H
+#define MBED_I2C_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: I2C
+ * An I2C Master, used for communicating with I2C slave devices
+ *
+ * Example:
+ * > // Read from I2C slave at address 0x62
+ * >
+ * > #include "mbed.h"
+ * >
+ * > I2C i2c(p28, p27);
+ * >
+ * > int main() {
+ * > int address = 0x62;
+ * > char data[2];
+ * > i2c.read(address, data, 2);
+ * > }
+ */
+class I2C : public Base {
+
+public:
+
+ enum RxStatus {
+ NoData
+ , MasterGeneralCall
+ , MasterWrite
+ , MasterRead
+ };
+
+ enum Acknowledge {
+ NoACK = 0
+ , ACK = 1
+ };
+
+ /* Constructor: I2C
+ * Create an I2C Master interface, connected to the specified pins
+ *
+ * Variables:
+ * sda - I2C data line pin
+ * scl - I2C clock line pin
+ */
+ I2C(PinName sda, PinName scl, const char *name = NULL);
+
+ /* Function: frequency
+ * Set the frequency of the I2C interface
+ *
+ * Variables:
+ * hz - The bus frequency in hertz
+ */
+ void frequency(int hz);
+
+ /* Function: read
+ * Read from an I2C slave
+ *
+ * Performs a complete read transaction. The bottom bit of
+ * the address is forced to 1 to indicate a read.
+ *
+ * Variables:
+ * address - 8-bit I2C slave address [ addr | 1 ]
+ * data - Pointer to the byte-array to read data in to
+ * length - Number of bytes to read
+ * repeated - Repeated start, true - don't send stop at end
+ * returns - 0 on success (ack), or non-0 on failure (nack)
+ */
+ int read(int address, char *data, int length, bool repeated = false);
+
+ /* Function: read
+ * Read a single byte from the I2C bus
+ *
+ * Variables:
+ * ack - indicates if the byte is to be acknowledged (1 = acknowledge)
+ * returns - the byte read
+ */
+ int read(int ack);
+
+ /* Function: write
+ * Write to an I2C slave
+ *
+ * Performs a complete write transaction. The bottom bit of
+ * the address is forced to 0 to indicate a write.
+ *
+ * Variables:
+ * address - 8-bit I2C slave address [ addr | 0 ]
+ * data - Pointer to the byte-array data to send
+ * length - Number of bytes to send
+ * repeated - Repeated start, true - do not send stop at end
+ * returns - 0 on success (ack), or non-0 on failure (nack)
+ */
+ int write(int address, const char *data, int length, bool repeated = false);
+
+ /* Function: write
+ * Write single byte out on the I2C bus
+ *
+ * Variables:
+ * data - data to write out on bus
+ * returns - a '1' if an ACK was received, a '0' otherwise
+ */
+ int write(int data);
+
+ /* Function: start
+ * Creates a start condition on the I2C bus
+ */
+
+ void start(void);
+
+ /* Function: stop
+ * Creates a stop condition on the I2C bus
+ */
+ void stop(void);
+
+protected:
+
+ void aquire();
+
+ I2CName _i2c;
+ static I2C *_owner;
+ int _hz;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/I2CSlave.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,149 @@
+/* mbed Microcontroller Library - I2CSlave
+ * Copyright (c) 2007-2010 ARM Limited. All rights reserved.
+ * jward
+ */
+
+#ifndef MBED_I2C_SLAVE_H
+#define MBED_I2C_SLAVE_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: I2CSlave
+ * An I2C Slave, used for communicating with an I2C Master device
+ *
+ * Example:
+ * > // Simple I2C responder
+ * > #include <mbed.h>
+ * >
+ * > I2CSlave slave(p9, p10);
+ * >
+ * > int main() {
+ * > char buf[10];
+ * > char msg[] = "Slave!";
+ * >
+ * > slave.address(0xA0);
+ * > while (1) {
+ * > int i = slave.receive();
+ * > switch (i) {
+ * > case I2CSlave::ReadAddressed:
+ * > slave.write(msg, strlen(msg) + 1); // Includes null char
+ * > break;
+ * > case I2CSlave::WriteGeneral:
+ * > slave.read(buf, 10);
+ * > printf("Read G: %s\n", buf);
+ * > break;
+ * > case I2CSlave::WriteAddressed:
+ * > slave.read(buf, 10);
+ * > printf("Read A: %s\n", buf);
+ * > break;
+ * > }
+ * > for(int i = 0; i < 10; i++) buf[i] = 0; // Clear buffer
+ * > }
+ * > }
+ * >
+ */
+class I2CSlave : public Base {
+
+public:
+
+ enum RxStatus {
+ NoData = 0
+ , ReadAddressed = 1
+ , WriteGeneral = 2
+ , WriteAddressed = 3
+ };
+
+ /* Constructor: I2CSlave
+ * Create an I2C Slave interface, connected to the specified pins.
+ *
+ * Variables:
+ * sda - I2C data line pin
+ * scl - I2C clock line pin
+ */
+ I2CSlave(PinName sda, PinName scl, const char *name = NULL);
+
+ /* Function: frequency
+ * Set the frequency of the I2C interface
+ *
+ * Variables:
+ * hz - The bus frequency in hertz
+ */
+ void frequency(int hz);
+
+ /* Function: receive
+ * Checks to see if this I2C Slave has been addressed.
+ *
+ * Variables:
+ * returns - a status indicating if the device has been addressed, and how
+ * > NoData - the slave has not been addressed
+ * > ReadAddressed - the master has requested a read from this slave
+ * > WriteAddressed - the master is writing to this slave
+ * > WriteGeneral - the master is writing to all slave
+ */
+ int receive(void);
+
+ /* Function: read
+ * Read from an I2C master.
+ *
+ * Variables:
+ * data - pointer to the byte array to read data in to
+ * length - maximum number of bytes to read
+ * returns - 0 on success, non-0 otherwise
+ */
+ int read(char *data, int length);
+
+ /* Function: read
+ * Read a single byte from an I2C master.
+ *
+ * Variables:
+ * returns - the byte read
+ */
+ int read(void);
+
+ /* Function: write
+ * Write to an I2C master.
+ *
+ * Variables:
+ * data - pointer to the byte array to be transmitted
+ * length - the number of bytes to transmite
+ * returns - a 0 on success, non-0 otherwise
+ */
+ int write(const char *data, int length);
+
+ /* Function: write
+ * Write a single byte to an I2C master.
+ *
+ * Variables
+ * data - the byte to write
+ * returns - a '1' if an ACK was received, a '0' otherwise
+ */
+ int write(int data);
+
+ /* Function: address
+ * Sets the I2C slave address.
+ *
+ * Variables
+ * address - the address to set for the slave (ignoring the least
+ * signifcant bit). If set to 0, the slave will only respond to the
+ * general call address.
+ */
+ void address(int address);
+
+ /* Function: stop
+ * Reset the I2C slave back into the known ready receiving state.
+ */
+ void stop(void);
+
+protected:
+
+ I2CName _i2c;
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/InterruptIn.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,125 @@
+/* mbed Microcontroller Library - InterruptIn
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_INTERRUPTIN_H
+#define MBED_INTERRUPTIN_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+#include "FunctionPointer.h"
+
+namespace mbed {
+
+/* Class: InterruptIn
+ * A digital interrupt input, used to call a function on a rising or falling edge
+ *
+ * Example:
+ * > // Flash an LED while waiting for events
+ * >
+ * > #include "mbed.h"
+ * >
+ * > InterruptIn event(p16);
+ * > DigitalOut led(LED1);
+ * >
+ * > void trigger() {
+ * > printf("triggered!\n");
+ * > }
+ * >
+ * > int main() {
+ * > event.rise(&trigger);
+ * > while(1) {
+ * > led = !led;
+ * > wait(0.25);
+ * > }
+ * > }
+ */
+class InterruptIn : public Base {
+
+public:
+
+ /* Constructor: InterruptIn
+ * Create an InterruptIn connected to the specified pin
+ *
+ * Variables:
+ * pin - InterruptIn pin to connect to
+ * name - (optional) A string to identify the object
+ */
+ InterruptIn(PinName pin, const char *name = NULL);
+
+ int read();
+#ifdef MBED_OPERATORS
+ operator int();
+
+#endif
+
+ /* Function: rise
+ * Attach a function to call when a rising edge occurs on the input
+ *
+ * Variables:
+ * fptr - A pointer to a void function, or 0 to set as none
+ */
+ void rise(void (*fptr)(void));
+
+ /* Function: rise
+ * Attach a member function to call when a rising edge occurs on the input
+ *
+ * Variables:
+ * tptr - pointer to the object to call the member function on
+ * mptr - pointer to the member function to be called
+ */
+ template<typename T>
+ void rise(T* tptr, void (T::*mptr)(void)) {
+ _rise.attach(tptr, mptr);
+ setup_interrupt(1, 1);
+ }
+
+ /* Function: fall
+ * Attach a function to call when a falling edge occurs on the input
+ *
+ * Variables:
+ * fptr - A pointer to a void function, or 0 to set as none
+ */
+ void fall(void (*fptr)(void));
+
+ /* Function: fall
+ * Attach a member function to call when a falling edge occurs on the input
+ *
+ * Variables:
+ * tptr - pointer to the object to call the member function on
+ * mptr - pointer to the member function to be called
+ */
+ template<typename T>
+ void fall(T* tptr, void (T::*mptr)(void)) {
+ _fall.attach(tptr, mptr);
+ setup_interrupt(0, 1);
+ }
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone
+ */
+ void mode(PinMode pull);
+
+
+ static void _irq();
+ static InterruptIn *_irq_objects[48];
+
+protected:
+
+ PinName _pin;
+ FunctionPointer _rise;
+ FunctionPointer _fall;
+
+ void setup_interrupt(int rising, int enable);
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC1768/LPC1768.sct Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,21 @@
+
+LR_IROM1 0x00000000 0x80000 { ; load region size_region
+ ER_IROM1 0x00000000 0x80000 { ; load address = execution address
+ *.o (RESET, +First)
+ *(InRoot$$Sections)
+ .ANY (+RO)
+ }
+ RW_IRAM1 0x10000000 0x8000 { ; RW data, Application data
+ .ANY (+RW +ZI)
+ }
+ RW_IRAM2 0x2007C000 0x4000 { ; RW data, USB RAM
+ .ANY (AHBSRAM0)
+ }
+ RW_IRAM3 0x20080000 0x4000 { ; RW data, ETH RAM
+ .ANY (AHBSRAM1)
+ }
+ RW_IRAM4 0x40038000 0x0800 { ; RW data, CAN RAM
+ .ANY (CANRAM)
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC1768/LPC17xx.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,968 @@
+/******************************************************************************
+ * @file: LPC17xx.h
+ * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Header File for
+ * NXP LPC17xx Device Series
+ * @version: V1.04
+ * @date: 2. July 2009
+ *----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2008 ARM Limited. All rights reserved.
+ *
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M3
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
+
+
+#ifndef __LPC17xx_H__
+#define __LPC17xx_H__
+
+/*
+ * ==========================================================================
+ * ---------- Interrupt Number Definition -----------------------------------
+ * ==========================================================================
+ */
+
+typedef enum IRQn
+{
+/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/
+ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
+ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
+ BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
+ UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
+ SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
+ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */
+ PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
+ SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */
+
+/****** LPC17xx Specific Interrupt Numbers *******************************************************/
+ WDT_IRQn = 0, /*!< Watchdog Timer Interrupt */
+ TIMER0_IRQn = 1, /*!< Timer0 Interrupt */
+ TIMER1_IRQn = 2, /*!< Timer1 Interrupt */
+ TIMER2_IRQn = 3, /*!< Timer2 Interrupt */
+ TIMER3_IRQn = 4, /*!< Timer3 Interrupt */
+ UART0_IRQn = 5, /*!< UART0 Interrupt */
+ UART1_IRQn = 6, /*!< UART1 Interrupt */
+ UART2_IRQn = 7, /*!< UART2 Interrupt */
+ UART3_IRQn = 8, /*!< UART3 Interrupt */
+ PWM1_IRQn = 9, /*!< PWM1 Interrupt */
+ I2C0_IRQn = 10, /*!< I2C0 Interrupt */
+ I2C1_IRQn = 11, /*!< I2C1 Interrupt */
+ I2C2_IRQn = 12, /*!< I2C2 Interrupt */
+ SPI_IRQn = 13, /*!< SPI Interrupt */
+ SSP0_IRQn = 14, /*!< SSP0 Interrupt */
+ SSP1_IRQn = 15, /*!< SSP1 Interrupt */
+ PLL0_IRQn = 16, /*!< PLL0 Lock (Main PLL) Interrupt */
+ RTC_IRQn = 17, /*!< Real Time Clock Interrupt */
+ EINT0_IRQn = 18, /*!< External Interrupt 0 Interrupt */
+ EINT1_IRQn = 19, /*!< External Interrupt 1 Interrupt */
+ EINT2_IRQn = 20, /*!< External Interrupt 2 Interrupt */
+ EINT3_IRQn = 21, /*!< External Interrupt 3 Interrupt */
+ ADC_IRQn = 22, /*!< A/D Converter Interrupt */
+ BOD_IRQn = 23, /*!< Brown-Out Detect Interrupt */
+ USB_IRQn = 24, /*!< USB Interrupt */
+ CAN_IRQn = 25, /*!< CAN Interrupt */
+ DMA_IRQn = 26, /*!< General Purpose DMA Interrupt */
+ I2S_IRQn = 27, /*!< I2S Interrupt */
+ ENET_IRQn = 28, /*!< Ethernet Interrupt */
+ RIT_IRQn = 29, /*!< Repetitive Interrupt Timer Interrupt */
+ MCPWM_IRQn = 30, /*!< Motor Control PWM Interrupt */
+ QEI_IRQn = 31, /*!< Quadrature Encoder Interface Interrupt */
+ PLL1_IRQn = 32, /*!< PLL1 Lock (USB PLL) Interrupt */
+} IRQn_Type;
+
+
+/*
+ * ==========================================================================
+ * ----------- Processor and Core Peripheral Section ------------------------
+ * ==========================================================================
+ */
+
+/* Configuration of the Cortex-M3 Processor and Core Peripherals */
+#define __MPU_PRESENT 1 /*!< MPU present or not */
+#define __NVIC_PRIO_BITS 5 /*!< Number of Bits used for Priority Levels */
+#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
+
+
+#include <core_cm3.h> /* Cortex-M3 processor and core peripherals */
+#include "system_LPC17xx.h" /* System Header */
+
+
+/******************************************************************************/
+/* Device Specific Peripheral registers structures */
+/******************************************************************************/
+
+#if defined ( __CC_ARM )
+#pragma anon_unions
+#endif
+
+/*------------- System Control (SC) ------------------------------------------*/
+typedef struct
+{
+ __IO uint32_t FLASHCFG; /* Flash Accelerator Module */
+ uint32_t RESERVED0[31];
+ __IO uint32_t PLL0CON; /* Clocking and Power Control */
+ __IO uint32_t PLL0CFG;
+ __I uint32_t PLL0STAT;
+ __O uint32_t PLL0FEED;
+ uint32_t RESERVED1[4];
+ __IO uint32_t PLL1CON;
+ __IO uint32_t PLL1CFG;
+ __I uint32_t PLL1STAT;
+ __O uint32_t PLL1FEED;
+ uint32_t RESERVED2[4];
+ __IO uint32_t PCON;
+ __IO uint32_t PCONP;
+ uint32_t RESERVED3[15];
+ __IO uint32_t CCLKCFG;
+ __IO uint32_t USBCLKCFG;
+ __IO uint32_t CLKSRCSEL;
+ uint32_t RESERVED4[12];
+ __IO uint32_t EXTINT; /* External Interrupts */
+ uint32_t RESERVED5;
+ __IO uint32_t EXTMODE;
+ __IO uint32_t EXTPOLAR;
+ uint32_t RESERVED6[12];
+ __IO uint32_t RSID; /* Reset */
+ uint32_t RESERVED7[7];
+ __IO uint32_t SCS; /* Syscon Miscellaneous Registers */
+ __IO uint32_t IRCTRIM; /* Clock Dividers */
+ __IO uint32_t PCLKSEL0;
+ __IO uint32_t PCLKSEL1;
+ uint32_t RESERVED8[4];
+ __IO uint32_t USBIntSt; /* USB Device/OTG Interrupt Register */
+ uint32_t RESERVED9;
+ __IO uint32_t CLKOUTCFG; /* Clock Output Configuration */
+ } LPC_SC_TypeDef;
+
+/*------------- Pin Connect Block (PINCON) -----------------------------------*/
+typedef struct
+{
+ __IO uint32_t PINSEL0;
+ __IO uint32_t PINSEL1;
+ __IO uint32_t PINSEL2;
+ __IO uint32_t PINSEL3;
+ __IO uint32_t PINSEL4;
+ __IO uint32_t PINSEL5;
+ __IO uint32_t PINSEL6;
+ __IO uint32_t PINSEL7;
+ __IO uint32_t PINSEL8;
+ __IO uint32_t PINSEL9;
+ __IO uint32_t PINSEL10;
+ uint32_t RESERVED0[5];
+ __IO uint32_t PINMODE0;
+ __IO uint32_t PINMODE1;
+ __IO uint32_t PINMODE2;
+ __IO uint32_t PINMODE3;
+ __IO uint32_t PINMODE4;
+ __IO uint32_t PINMODE5;
+ __IO uint32_t PINMODE6;
+ __IO uint32_t PINMODE7;
+ __IO uint32_t PINMODE8;
+ __IO uint32_t PINMODE9;
+ __IO uint32_t PINMODE_OD0;
+ __IO uint32_t PINMODE_OD1;
+ __IO uint32_t PINMODE_OD2;
+ __IO uint32_t PINMODE_OD3;
+ __IO uint32_t PINMODE_OD4;
+ __IO uint32_t I2CPADCFG;
+} LPC_PINCON_TypeDef;
+
+/*------------- General Purpose Input/Output (GPIO) --------------------------*/
+typedef struct
+{
+ __IO uint32_t FIODIR;
+ uint32_t RESERVED0[3];
+ __IO uint32_t FIOMASK;
+ __IO uint32_t FIOPIN;
+ __IO uint32_t FIOSET;
+ __O uint32_t FIOCLR;
+} LPC_GPIO_TypeDef;
+
+typedef struct
+{
+ __I uint32_t IntStatus;
+ __I uint32_t IO0IntStatR;
+ __I uint32_t IO0IntStatF;
+ __O uint32_t IO0IntClr;
+ __IO uint32_t IO0IntEnR;
+ __IO uint32_t IO0IntEnF;
+ uint32_t RESERVED0[3];
+ __I uint32_t IO2IntStatR;
+ __I uint32_t IO2IntStatF;
+ __O uint32_t IO2IntClr;
+ __IO uint32_t IO2IntEnR;
+ __IO uint32_t IO2IntEnF;
+} LPC_GPIOINT_TypeDef;
+
+/*------------- Timer (TIM) --------------------------------------------------*/
+typedef struct
+{
+ __IO uint32_t IR;
+ __IO uint32_t TCR;
+ __IO uint32_t TC;
+ __IO uint32_t PR;
+ __IO uint32_t PC;
+ __IO uint32_t MCR;
+ __IO uint32_t MR0;
+ __IO uint32_t MR1;
+ __IO uint32_t MR2;
+ __IO uint32_t MR3;
+ __IO uint32_t CCR;
+ __I uint32_t CR0;
+ __I uint32_t CR1;
+ uint32_t RESERVED0[2];
+ __IO uint32_t EMR;
+ uint32_t RESERVED1[12];
+ __IO uint32_t CTCR;
+} LPC_TIM_TypeDef;
+
+/*------------- Pulse-Width Modulation (PWM) ---------------------------------*/
+typedef struct
+{
+ __IO uint32_t IR;
+ __IO uint32_t TCR;
+ __IO uint32_t TC;
+ __IO uint32_t PR;
+ __IO uint32_t PC;
+ __IO uint32_t MCR;
+ __IO uint32_t MR0;
+ __IO uint32_t MR1;
+ __IO uint32_t MR2;
+ __IO uint32_t MR3;
+ __IO uint32_t CCR;
+ __I uint32_t CR0;
+ __I uint32_t CR1;
+ __I uint32_t CR2;
+ __I uint32_t CR3;
+ uint32_t RESERVED0;
+ __IO uint32_t MR4;
+ __IO uint32_t MR5;
+ __IO uint32_t MR6;
+ __IO uint32_t PCR;
+ __IO uint32_t LER;
+ uint32_t RESERVED1[7];
+ __IO uint32_t CTCR;
+} LPC_PWM_TypeDef;
+
+/*------------- Universal Asynchronous Receiver Transmitter (UART) -----------*/
+typedef struct
+{
+ union {
+ __I uint8_t RBR;
+ __O uint8_t THR;
+ __IO uint8_t DLL;
+ uint32_t RESERVED0;
+ };
+ union {
+ __IO uint8_t DLM;
+ __IO uint32_t IER;
+ };
+ union {
+ __I uint32_t IIR;
+ __O uint8_t FCR;
+ };
+ __IO uint8_t LCR;
+ uint8_t RESERVED1[7];
+ __I uint8_t LSR;
+ uint8_t RESERVED2[7];
+ __IO uint8_t SCR;
+ uint8_t RESERVED3[3];
+ __IO uint32_t ACR;
+ __IO uint8_t ICR;
+ uint8_t RESERVED4[3];
+ __IO uint8_t FDR;
+ uint8_t RESERVED5[7];
+ __IO uint8_t TER;
+ uint8_t RESERVED6[39];
+ __I uint8_t FIFOLVL;
+} LPC_UART_TypeDef;
+
+typedef struct
+{
+ union {
+ __I uint8_t RBR;
+ __O uint8_t THR;
+ __IO uint8_t DLL;
+ uint32_t RESERVED0;
+ };
+ union {
+ __IO uint8_t DLM;
+ __IO uint32_t IER;
+ };
+ union {
+ __I uint32_t IIR;
+ __O uint8_t FCR;
+ };
+ __IO uint8_t LCR;
+ uint8_t RESERVED1[7];
+ __I uint8_t LSR;
+ uint8_t RESERVED2[7];
+ __IO uint8_t SCR;
+ uint8_t RESERVED3[3];
+ __IO uint32_t ACR;
+ __IO uint8_t ICR;
+ uint8_t RESERVED4[3];
+ __IO uint8_t FDR;
+ uint8_t RESERVED5[7];
+ __IO uint8_t TER;
+ uint8_t RESERVED6[39];
+ __I uint8_t FIFOLVL;
+ uint8_t RESERVED7[363];
+ __IO uint32_t DMAREQSEL;
+} LPC_UART0_TypeDef;
+
+typedef struct
+{
+ union {
+ __I uint8_t RBR;
+ __O uint8_t THR;
+ __IO uint8_t DLL;
+ uint32_t RESERVED0;
+ };
+ union {
+ __IO uint8_t DLM;
+ __IO uint32_t IER;
+ };
+ union {
+ __I uint32_t IIR;
+ __O uint8_t FCR;
+ };
+ __IO uint8_t LCR;
+ uint8_t RESERVED1[3];
+ __IO uint8_t MCR;
+ uint8_t RESERVED2[3];
+ __I uint8_t LSR;
+ uint8_t RESERVED3[3];
+ __I uint8_t MSR;
+ uint8_t RESERVED4[3];
+ __IO uint8_t SCR;
+ uint8_t RESERVED5[3];
+ __IO uint32_t ACR;
+ uint32_t RESERVED6;
+ __IO uint32_t FDR;
+ uint32_t RESERVED7;
+ __IO uint8_t TER;
+ uint8_t RESERVED8[27];
+ __IO uint8_t RS485CTRL;
+ uint8_t RESERVED9[3];
+ __IO uint8_t ADRMATCH;
+ uint8_t RESERVED10[3];
+ __IO uint8_t RS485DLY;
+ uint8_t RESERVED11[3];
+ __I uint8_t FIFOLVL;
+} LPC_UART1_TypeDef;
+
+/*------------- Serial Peripheral Interface (SPI) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t SPCR;
+ __I uint32_t SPSR;
+ __IO uint32_t SPDR;
+ __IO uint32_t SPCCR;
+ uint32_t RESERVED0[3];
+ __IO uint32_t SPINT;
+} LPC_SPI_TypeDef;
+
+/*------------- Synchronous Serial Communication (SSP) -----------------------*/
+typedef struct
+{
+ __IO uint32_t CR0;
+ __IO uint32_t CR1;
+ __IO uint32_t DR;
+ __I uint32_t SR;
+ __IO uint32_t CPSR;
+ __IO uint32_t IMSC;
+ __IO uint32_t RIS;
+ __IO uint32_t MIS;
+ __IO uint32_t ICR;
+ __IO uint32_t DMACR;
+} LPC_SSP_TypeDef;
+
+/*------------- Inter-Integrated Circuit (I2C) -------------------------------*/
+typedef struct
+{
+ __IO uint32_t I2CONSET;
+ __I uint32_t I2STAT;
+ __IO uint32_t I2DAT;
+ __IO uint32_t I2ADR0;
+ __IO uint32_t I2SCLH;
+ __IO uint32_t I2SCLL;
+ __O uint32_t I2CONCLR;
+ __IO uint32_t MMCTRL;
+ __IO uint32_t I2ADR1;
+ __IO uint32_t I2ADR2;
+ __IO uint32_t I2ADR3;
+ __I uint32_t I2DATA_BUFFER;
+ __IO uint32_t I2MASK0;
+ __IO uint32_t I2MASK1;
+ __IO uint32_t I2MASK2;
+ __IO uint32_t I2MASK3;
+} LPC_I2C_TypeDef;
+
+/*------------- Inter IC Sound (I2S) -----------------------------------------*/
+typedef struct
+{
+ __IO uint32_t I2SDAO;
+ __IO uint32_t I2SDAI;
+ __O uint32_t I2STXFIFO;
+ __I uint32_t I2SRXFIFO;
+ __I uint32_t I2SSTATE;
+ __IO uint32_t I2SDMA1;
+ __IO uint32_t I2SDMA2;
+ __IO uint32_t I2SIRQ;
+ __IO uint32_t I2STXRATE;
+ __IO uint32_t I2SRXRATE;
+ __IO uint32_t I2STXBITRATE;
+ __IO uint32_t I2SRXBITRATE;
+ __IO uint32_t I2STXMODE;
+ __IO uint32_t I2SRXMODE;
+} LPC_I2S_TypeDef;
+
+/*------------- Repetitive Interrupt Timer (RIT) -----------------------------*/
+typedef struct
+{
+ __IO uint32_t RICOMPVAL;
+ __IO uint32_t RIMASK;
+ __IO uint8_t RICTRL;
+ uint8_t RESERVED0[3];
+ __IO uint32_t RICOUNTER;
+} LPC_RIT_TypeDef;
+
+/*------------- Real-Time Clock (RTC) ----------------------------------------*/
+typedef struct
+{
+ __IO uint8_t ILR;
+ uint8_t RESERVED0[7];
+ __IO uint8_t CCR;
+ uint8_t RESERVED1[3];
+ __IO uint8_t CIIR;
+ uint8_t RESERVED2[3];
+ __IO uint8_t AMR;
+ uint8_t RESERVED3[3];
+ __I uint32_t CTIME0;
+ __I uint32_t CTIME1;
+ __I uint32_t CTIME2;
+ __IO uint8_t SEC;
+ uint8_t RESERVED4[3];
+ __IO uint8_t MIN;
+ uint8_t RESERVED5[3];
+ __IO uint8_t HOUR;
+ uint8_t RESERVED6[3];
+ __IO uint8_t DOM;
+ uint8_t RESERVED7[3];
+ __IO uint8_t DOW;
+ uint8_t RESERVED8[3];
+ __IO uint16_t DOY;
+ uint16_t RESERVED9;
+ __IO uint8_t MONTH;
+ uint8_t RESERVED10[3];
+ __IO uint16_t YEAR;
+ uint16_t RESERVED11;
+ __IO uint32_t CALIBRATION;
+ __IO uint32_t GPREG0;
+ __IO uint32_t GPREG1;
+ __IO uint32_t GPREG2;
+ __IO uint32_t GPREG3;
+ __IO uint32_t GPREG4;
+ __IO uint8_t RTC_AUXEN;
+ uint8_t RESERVED12[3];
+ __IO uint8_t RTC_AUX;
+ uint8_t RESERVED13[3];
+ __IO uint8_t ALSEC;
+ uint8_t RESERVED14[3];
+ __IO uint8_t ALMIN;
+ uint8_t RESERVED15[3];
+ __IO uint8_t ALHOUR;
+ uint8_t RESERVED16[3];
+ __IO uint8_t ALDOM;
+ uint8_t RESERVED17[3];
+ __IO uint8_t ALDOW;
+ uint8_t RESERVED18[3];
+ __IO uint16_t ALDOY;
+ uint16_t RESERVED19;
+ __IO uint8_t ALMON;
+ uint8_t RESERVED20[3];
+ __IO uint16_t ALYEAR;
+ uint16_t RESERVED21;
+} LPC_RTC_TypeDef;
+
+/*------------- Watchdog Timer (WDT) -----------------------------------------*/
+typedef struct
+{
+ __IO uint8_t WDMOD;
+ uint8_t RESERVED0[3];
+ __IO uint32_t WDTC;
+ __O uint8_t WDFEED;
+ uint8_t RESERVED1[3];
+ __I uint32_t WDTV;
+ __IO uint32_t WDCLKSEL;
+} LPC_WDT_TypeDef;
+
+/*------------- Analog-to-Digital Converter (ADC) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t ADCR;
+ __IO uint32_t ADGDR;
+ uint32_t RESERVED0;
+ __IO uint32_t ADINTEN;
+ __I uint32_t ADDR0;
+ __I uint32_t ADDR1;
+ __I uint32_t ADDR2;
+ __I uint32_t ADDR3;
+ __I uint32_t ADDR4;
+ __I uint32_t ADDR5;
+ __I uint32_t ADDR6;
+ __I uint32_t ADDR7;
+ __I uint32_t ADSTAT;
+ __IO uint32_t ADTRM;
+} LPC_ADC_TypeDef;
+
+/*------------- Digital-to-Analog Converter (DAC) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t DACR;
+ __IO uint32_t DACCTRL;
+ __IO uint16_t DACCNTVAL;
+} LPC_DAC_TypeDef;
+
+/*------------- Motor Control Pulse-Width Modulation (MCPWM) -----------------*/
+typedef struct
+{
+ __I uint32_t MCCON;
+ __O uint32_t MCCON_SET;
+ __O uint32_t MCCON_CLR;
+ __I uint32_t MCCAPCON;
+ __O uint32_t MCCAPCON_SET;
+ __O uint32_t MCCAPCON_CLR;
+ __IO uint32_t MCTIM0;
+ __IO uint32_t MCTIM1;
+ __IO uint32_t MCTIM2;
+ __IO uint32_t MCPER0;
+ __IO uint32_t MCPER1;
+ __IO uint32_t MCPER2;
+ __IO uint32_t MCPW0;
+ __IO uint32_t MCPW1;
+ __IO uint32_t MCPW2;
+ __IO uint32_t MCDEADTIME;
+ __IO uint32_t MCCCP;
+ __IO uint32_t MCCR0;
+ __IO uint32_t MCCR1;
+ __IO uint32_t MCCR2;
+ __I uint32_t MCINTEN;
+ __O uint32_t MCINTEN_SET;
+ __O uint32_t MCINTEN_CLR;
+ __I uint32_t MCCNTCON;
+ __O uint32_t MCCNTCON_SET;
+ __O uint32_t MCCNTCON_CLR;
+ __I uint32_t MCINTFLAG;
+ __O uint32_t MCINTFLAG_SET;
+ __O uint32_t MCINTFLAG_CLR;
+ __O uint32_t MCCAP_CLR;
+} LPC_MCPWM_TypeDef;
+
+/*------------- Quadrature Encoder Interface (QEI) ---------------------------*/
+typedef struct
+{
+ __O uint32_t QEICON;
+ __I uint32_t QEISTAT;
+ __IO uint32_t QEICONF;
+ __I uint32_t QEIPOS;
+ __IO uint32_t QEIMAXPOS;
+ __IO uint32_t CMPOS0;
+ __IO uint32_t CMPOS1;
+ __IO uint32_t CMPOS2;
+ __I uint32_t INXCNT;
+ __IO uint32_t INXCMP;
+ __IO uint32_t QEILOAD;
+ __I uint32_t QEITIME;
+ __I uint32_t QEIVEL;
+ __I uint32_t QEICAP;
+ __IO uint32_t VELCOMP;
+ __IO uint32_t FILTER;
+ uint32_t RESERVED0[998];
+ __O uint32_t QEIIEC;
+ __O uint32_t QEIIES;
+ __I uint32_t QEIINTSTAT;
+ __I uint32_t QEIIE;
+ __O uint32_t QEICLR;
+ __O uint32_t QEISET;
+} LPC_QEI_TypeDef;
+
+/*------------- Controller Area Network (CAN) --------------------------------*/
+typedef struct
+{
+ __IO uint32_t mask[512]; /* ID Masks */
+} LPC_CANAF_RAM_TypeDef;
+
+typedef struct /* Acceptance Filter Registers */
+{
+ __IO uint32_t AFMR;
+ __IO uint32_t SFF_sa;
+ __IO uint32_t SFF_GRP_sa;
+ __IO uint32_t EFF_sa;
+ __IO uint32_t EFF_GRP_sa;
+ __IO uint32_t ENDofTable;
+ __I uint32_t LUTerrAd;
+ __I uint32_t LUTerr;
+ __IO uint32_t FCANIE;
+ __IO uint32_t FCANIC0;
+ __IO uint32_t FCANIC1;
+} LPC_CANAF_TypeDef;
+
+typedef struct /* Central Registers */
+{
+ __I uint32_t CANTxSR;
+ __I uint32_t CANRxSR;
+ __I uint32_t CANMSR;
+} LPC_CANCR_TypeDef;
+
+typedef struct /* Controller Registers */
+{
+ __IO uint32_t MOD;
+ __O uint32_t CMR;
+ __IO uint32_t GSR;
+ __I uint32_t ICR;
+ __IO uint32_t IER;
+ __IO uint32_t BTR;
+ __IO uint32_t EWL;
+ __I uint32_t SR;
+ __IO uint32_t RFS;
+ __IO uint32_t RID;
+ __IO uint32_t RDA;
+ __IO uint32_t RDB;
+ __IO uint32_t TFI1;
+ __IO uint32_t TID1;
+ __IO uint32_t TDA1;
+ __IO uint32_t TDB1;
+ __IO uint32_t TFI2;
+ __IO uint32_t TID2;
+ __IO uint32_t TDA2;
+ __IO uint32_t TDB2;
+ __IO uint32_t TFI3;
+ __IO uint32_t TID3;
+ __IO uint32_t TDA3;
+ __IO uint32_t TDB3;
+} LPC_CAN_TypeDef;
+
+/*------------- General Purpose Direct Memory Access (GPDMA) -----------------*/
+typedef struct /* Common Registers */
+{
+ __I uint32_t DMACIntStat;
+ __I uint32_t DMACIntTCStat;
+ __O uint32_t DMACIntTCClear;
+ __I uint32_t DMACIntErrStat;
+ __O uint32_t DMACIntErrClr;
+ __I uint32_t DMACRawIntTCStat;
+ __I uint32_t DMACRawIntErrStat;
+ __I uint32_t DMACEnbldChns;
+ __IO uint32_t DMACSoftBReq;
+ __IO uint32_t DMACSoftSReq;
+ __IO uint32_t DMACSoftLBReq;
+ __IO uint32_t DMACSoftLSReq;
+ __IO uint32_t DMACConfig;
+ __IO uint32_t DMACSync;
+} LPC_GPDMA_TypeDef;
+
+typedef struct /* Channel Registers */
+{
+ __IO uint32_t DMACCSrcAddr;
+ __IO uint32_t DMACCDestAddr;
+ __IO uint32_t DMACCLLI;
+ __IO uint32_t DMACCControl;
+ __IO uint32_t DMACCConfig;
+} LPC_GPDMACH_TypeDef;
+
+/*------------- Universal Serial Bus (USB) -----------------------------------*/
+typedef struct
+{
+ __I uint32_t HcRevision; /* USB Host Registers */
+ __IO uint32_t HcControl;
+ __IO uint32_t HcCommandStatus;
+ __IO uint32_t HcInterruptStatus;
+ __IO uint32_t HcInterruptEnable;
+ __IO uint32_t HcInterruptDisable;
+ __IO uint32_t HcHCCA;
+ __I uint32_t HcPeriodCurrentED;
+ __IO uint32_t HcControlHeadED;
+ __IO uint32_t HcControlCurrentED;
+ __IO uint32_t HcBulkHeadED;
+ __IO uint32_t HcBulkCurrentED;
+ __I uint32_t HcDoneHead;
+ __IO uint32_t HcFmInterval;
+ __I uint32_t HcFmRemaining;
+ __I uint32_t HcFmNumber;
+ __IO uint32_t HcPeriodicStart;
+ __IO uint32_t HcLSTreshold;
+ __IO uint32_t HcRhDescriptorA;
+ __IO uint32_t HcRhDescriptorB;
+ __IO uint32_t HcRhStatus;
+ __IO uint32_t HcRhPortStatus1;
+ __IO uint32_t HcRhPortStatus2;
+ uint32_t RESERVED0[40];
+ __I uint32_t Module_ID;
+
+ __I uint32_t OTGIntSt; /* USB On-The-Go Registers */
+ __IO uint32_t OTGIntEn;
+ __O uint32_t OTGIntSet;
+ __O uint32_t OTGIntClr;
+ __IO uint32_t OTGStCtrl;
+ __IO uint32_t OTGTmr;
+ uint32_t RESERVED1[58];
+
+ __I uint32_t USBDevIntSt; /* USB Device Interrupt Registers */
+ __IO uint32_t USBDevIntEn;
+ __O uint32_t USBDevIntClr;
+ __O uint32_t USBDevIntSet;
+
+ __O uint32_t USBCmdCode; /* USB Device SIE Command Registers */
+ __I uint32_t USBCmdData;
+
+ __I uint32_t USBRxData; /* USB Device Transfer Registers */
+ __O uint32_t USBTxData;
+ __I uint32_t USBRxPLen;
+ __O uint32_t USBTxPLen;
+ __IO uint32_t USBCtrl;
+ __O uint32_t USBDevIntPri;
+
+ __I uint32_t USBEpIntSt; /* USB Device Endpoint Interrupt Regs */
+ __IO uint32_t USBEpIntEn;
+ __O uint32_t USBEpIntClr;
+ __O uint32_t USBEpIntSet;
+ __O uint32_t USBEpIntPri;
+
+ __IO uint32_t USBReEp; /* USB Device Endpoint Realization Reg*/
+ __O uint32_t USBEpInd;
+ __IO uint32_t USBMaxPSize;
+
+ __I uint32_t USBDMARSt; /* USB Device DMA Registers */
+ __O uint32_t USBDMARClr;
+ __O uint32_t USBDMARSet;
+ uint32_t RESERVED2[9];
+ __IO uint32_t USBUDCAH;
+ __I uint32_t USBEpDMASt;
+ __O uint32_t USBEpDMAEn;
+ __O uint32_t USBEpDMADis;
+ __I uint32_t USBDMAIntSt;
+ __IO uint32_t USBDMAIntEn;
+ uint32_t RESERVED3[2];
+ __I uint32_t USBEoTIntSt;
+ __O uint32_t USBEoTIntClr;
+ __O uint32_t USBEoTIntSet;
+ __I uint32_t USBNDDRIntSt;
+ __O uint32_t USBNDDRIntClr;
+ __O uint32_t USBNDDRIntSet;
+ __I uint32_t USBSysErrIntSt;
+ __O uint32_t USBSysErrIntClr;
+ __O uint32_t USBSysErrIntSet;
+ uint32_t RESERVED4[15];
+
+ __I uint32_t I2C_RX; /* USB OTG I2C Registers */
+ __O uint32_t I2C_WO;
+ __I uint32_t I2C_STS;
+ __IO uint32_t I2C_CTL;
+ __IO uint32_t I2C_CLKHI;
+ __O uint32_t I2C_CLKLO;
+ uint32_t RESERVED5[823];
+
+ union {
+ __IO uint32_t USBClkCtrl; /* USB Clock Control Registers */
+ __IO uint32_t OTGClkCtrl;
+ };
+ union {
+ __I uint32_t USBClkSt;
+ __I uint32_t OTGClkSt;
+ };
+} LPC_USB_TypeDef;
+
+/*------------- Ethernet Media Access Controller (EMAC) ----------------------*/
+typedef struct
+{
+ __IO uint32_t MAC1; /* MAC Registers */
+ __IO uint32_t MAC2;
+ __IO uint32_t IPGT;
+ __IO uint32_t IPGR;
+ __IO uint32_t CLRT;
+ __IO uint32_t MAXF;
+ __IO uint32_t SUPP;
+ __IO uint32_t TEST;
+ __IO uint32_t MCFG;
+ __IO uint32_t MCMD;
+ __IO uint32_t MADR;
+ __O uint32_t MWTD;
+ __I uint32_t MRDD;
+ __I uint32_t MIND;
+ uint32_t RESERVED0[2];
+ __IO uint32_t SA0;
+ __IO uint32_t SA1;
+ __IO uint32_t SA2;
+ uint32_t RESERVED1[45];
+ __IO uint32_t Command; /* Control Registers */
+ __I uint32_t Status;
+ __IO uint32_t RxDescriptor;
+ __IO uint32_t RxStatus;
+ __IO uint32_t RxDescriptorNumber;
+ __I uint32_t RxProduceIndex;
+ __IO uint32_t RxConsumeIndex;
+ __IO uint32_t TxDescriptor;
+ __IO uint32_t TxStatus;
+ __IO uint32_t TxDescriptorNumber;
+ __IO uint32_t TxProduceIndex;
+ __I uint32_t TxConsumeIndex;
+ uint32_t RESERVED2[10];
+ __I uint32_t TSV0;
+ __I uint32_t TSV1;
+ __I uint32_t RSV;
+ uint32_t RESERVED3[3];
+ __IO uint32_t FlowControlCounter;
+ __I uint32_t FlowControlStatus;
+ uint32_t RESERVED4[34];
+ __IO uint32_t RxFilterCtrl; /* Rx Filter Registers */
+ __IO uint32_t RxFilterWoLStatus;
+ __IO uint32_t RxFilterWoLClear;
+ uint32_t RESERVED5;
+ __IO uint32_t HashFilterL;
+ __IO uint32_t HashFilterH;
+ uint32_t RESERVED6[882];
+ __I uint32_t IntStatus; /* Module Control Registers */
+ __IO uint32_t IntEnable;
+ __O uint32_t IntClear;
+ __O uint32_t IntSet;
+ uint32_t RESERVED7;
+ __IO uint32_t PowerDown;
+ uint32_t RESERVED8;
+ __IO uint32_t Module_ID;
+} LPC_EMAC_TypeDef;
+
+#if defined ( __CC_ARM )
+#pragma anon_unions
+#endif
+
+
+/******************************************************************************/
+/* Peripheral memory map */
+/******************************************************************************/
+/* Base addresses */
+#define LPC_FLASH_BASE (0x00000000UL)
+#define LPC_RAM_BASE (0x10000000UL)
+#define LPC_GPIO_BASE (0x2009C000UL)
+#define LPC_APB0_BASE (0x40000000UL)
+#define LPC_APB1_BASE (0x40080000UL)
+#define LPC_AHB_BASE (0x50000000UL)
+#define LPC_CM3_BASE (0xE0000000UL)
+
+/* APB0 peripherals */
+#define LPC_WDT_BASE (LPC_APB0_BASE + 0x00000)
+#define LPC_TIM0_BASE (LPC_APB0_BASE + 0x04000)
+#define LPC_TIM1_BASE (LPC_APB0_BASE + 0x08000)
+#define LPC_UART0_BASE (LPC_APB0_BASE + 0x0C000)
+#define LPC_UART1_BASE (LPC_APB0_BASE + 0x10000)
+#define LPC_PWM1_BASE (LPC_APB0_BASE + 0x18000)
+#define LPC_I2C0_BASE (LPC_APB0_BASE + 0x1C000)
+#define LPC_SPI_BASE (LPC_APB0_BASE + 0x20000)
+#define LPC_RTC_BASE (LPC_APB0_BASE + 0x24000)
+#define LPC_GPIOINT_BASE (LPC_APB0_BASE + 0x28080)
+#define LPC_PINCON_BASE (LPC_APB0_BASE + 0x2C000)
+#define LPC_SSP1_BASE (LPC_APB0_BASE + 0x30000)
+#define LPC_ADC_BASE (LPC_APB0_BASE + 0x34000)
+#define LPC_CANAF_RAM_BASE (LPC_APB0_BASE + 0x38000)
+#define LPC_CANAF_BASE (LPC_APB0_BASE + 0x3C000)
+#define LPC_CANCR_BASE (LPC_APB0_BASE + 0x40000)
+#define LPC_CAN1_BASE (LPC_APB0_BASE + 0x44000)
+#define LPC_CAN2_BASE (LPC_APB0_BASE + 0x48000)
+#define LPC_I2C1_BASE (LPC_APB0_BASE + 0x5C000)
+
+/* APB1 peripherals */
+#define LPC_SSP0_BASE (LPC_APB1_BASE + 0x08000)
+#define LPC_DAC_BASE (LPC_APB1_BASE + 0x0C000)
+#define LPC_TIM2_BASE (LPC_APB1_BASE + 0x10000)
+#define LPC_TIM3_BASE (LPC_APB1_BASE + 0x14000)
+#define LPC_UART2_BASE (LPC_APB1_BASE + 0x18000)
+#define LPC_UART3_BASE (LPC_APB1_BASE + 0x1C000)
+#define LPC_I2C2_BASE (LPC_APB1_BASE + 0x20000)
+#define LPC_I2S_BASE (LPC_APB1_BASE + 0x28000)
+#define LPC_RIT_BASE (LPC_APB1_BASE + 0x30000)
+#define LPC_MCPWM_BASE (LPC_APB1_BASE + 0x38000)
+#define LPC_QEI_BASE (LPC_APB1_BASE + 0x3C000)
+#define LPC_SC_BASE (LPC_APB1_BASE + 0x7C000)
+
+/* AHB peripherals */
+#define LPC_EMAC_BASE (LPC_AHB_BASE + 0x00000)
+#define LPC_GPDMA_BASE (LPC_AHB_BASE + 0x04000)
+#define LPC_GPDMACH0_BASE (LPC_AHB_BASE + 0x04100)
+#define LPC_GPDMACH1_BASE (LPC_AHB_BASE + 0x04120)
+#define LPC_GPDMACH2_BASE (LPC_AHB_BASE + 0x04140)
+#define LPC_GPDMACH3_BASE (LPC_AHB_BASE + 0x04160)
+#define LPC_GPDMACH4_BASE (LPC_AHB_BASE + 0x04180)
+#define LPC_GPDMACH5_BASE (LPC_AHB_BASE + 0x041A0)
+#define LPC_GPDMACH6_BASE (LPC_AHB_BASE + 0x041C0)
+#define LPC_GPDMACH7_BASE (LPC_AHB_BASE + 0x041E0)
+#define LPC_USB_BASE (LPC_AHB_BASE + 0x0C000)
+
+/* GPIOs */
+#define LPC_GPIO0_BASE (LPC_GPIO_BASE + 0x00000)
+#define LPC_GPIO1_BASE (LPC_GPIO_BASE + 0x00020)
+#define LPC_GPIO2_BASE (LPC_GPIO_BASE + 0x00040)
+#define LPC_GPIO3_BASE (LPC_GPIO_BASE + 0x00060)
+#define LPC_GPIO4_BASE (LPC_GPIO_BASE + 0x00080)
+
+
+/******************************************************************************/
+/* Peripheral declaration */
+/******************************************************************************/
+#define LPC_SC ((LPC_SC_TypeDef *) LPC_SC_BASE )
+#define LPC_GPIO0 ((LPC_GPIO_TypeDef *) LPC_GPIO0_BASE )
+#define LPC_GPIO1 ((LPC_GPIO_TypeDef *) LPC_GPIO1_BASE )
+#define LPC_GPIO2 ((LPC_GPIO_TypeDef *) LPC_GPIO2_BASE )
+#define LPC_GPIO3 ((LPC_GPIO_TypeDef *) LPC_GPIO3_BASE )
+#define LPC_GPIO4 ((LPC_GPIO_TypeDef *) LPC_GPIO4_BASE )
+#define LPC_WDT ((LPC_WDT_TypeDef *) LPC_WDT_BASE )
+#define LPC_TIM0 ((LPC_TIM_TypeDef *) LPC_TIM0_BASE )
+#define LPC_TIM1 ((LPC_TIM_TypeDef *) LPC_TIM1_BASE )
+#define LPC_TIM2 ((LPC_TIM_TypeDef *) LPC_TIM2_BASE )
+#define LPC_TIM3 ((LPC_TIM_TypeDef *) LPC_TIM3_BASE )
+#define LPC_RIT ((LPC_RIT_TypeDef *) LPC_RIT_BASE )
+#define LPC_UART0 ((LPC_UART0_TypeDef *) LPC_UART0_BASE )
+#define LPC_UART1 ((LPC_UART1_TypeDef *) LPC_UART1_BASE )
+#define LPC_UART2 ((LPC_UART_TypeDef *) LPC_UART2_BASE )
+#define LPC_UART3 ((LPC_UART_TypeDef *) LPC_UART3_BASE )
+#define LPC_PWM1 ((LPC_PWM_TypeDef *) LPC_PWM1_BASE )
+#define LPC_I2C0 ((LPC_I2C_TypeDef *) LPC_I2C0_BASE )
+#define LPC_I2C1 ((LPC_I2C_TypeDef *) LPC_I2C1_BASE )
+#define LPC_I2C2 ((LPC_I2C_TypeDef *) LPC_I2C2_BASE )
+#define LPC_I2S ((LPC_I2S_TypeDef *) LPC_I2S_BASE )
+#define LPC_SPI ((LPC_SPI_TypeDef *) LPC_SPI_BASE )
+#define LPC_RTC ((LPC_RTC_TypeDef *) LPC_RTC_BASE )
+#define LPC_GPIOINT ((LPC_GPIOINT_TypeDef *) LPC_GPIOINT_BASE )
+#define LPC_PINCON ((LPC_PINCON_TypeDef *) LPC_PINCON_BASE )
+#define LPC_SSP0 ((LPC_SSP_TypeDef *) LPC_SSP0_BASE )
+#define LPC_SSP1 ((LPC_SSP_TypeDef *) LPC_SSP1_BASE )
+#define LPC_ADC ((LPC_ADC_TypeDef *) LPC_ADC_BASE )
+#define LPC_DAC ((LPC_DAC_TypeDef *) LPC_DAC_BASE )
+#define LPC_CANAF_RAM ((LPC_CANAF_RAM_TypeDef *) LPC_CANAF_RAM_BASE)
+#define LPC_CANAF ((LPC_CANAF_TypeDef *) LPC_CANAF_BASE )
+#define LPC_CANCR ((LPC_CANCR_TypeDef *) LPC_CANCR_BASE )
+#define LPC_CAN1 ((LPC_CAN_TypeDef *) LPC_CAN1_BASE )
+#define LPC_CAN2 ((LPC_CAN_TypeDef *) LPC_CAN2_BASE )
+#define LPC_MCPWM ((LPC_MCPWM_TypeDef *) LPC_MCPWM_BASE )
+#define LPC_QEI ((LPC_QEI_TypeDef *) LPC_QEI_BASE )
+#define LPC_EMAC ((LPC_EMAC_TypeDef *) LPC_EMAC_BASE )
+#define LPC_GPDMA ((LPC_GPDMA_TypeDef *) LPC_GPDMA_BASE )
+#define LPC_GPDMACH0 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH0_BASE )
+#define LPC_GPDMACH1 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH1_BASE )
+#define LPC_GPDMACH2 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH2_BASE )
+#define LPC_GPDMACH3 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH3_BASE )
+#define LPC_GPDMACH4 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH4_BASE )
+#define LPC_GPDMACH5 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH5_BASE )
+#define LPC_GPDMACH6 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH6_BASE )
+#define LPC_GPDMACH7 ((LPC_GPDMACH_TypeDef *) LPC_GPDMACH7_BASE )
+#define LPC_USB ((LPC_USB_TypeDef *) LPC_USB_BASE )
+
+#endif // __LPC17xx_H__
Binary file mbed/LPC1768/capi.ar has changed
Binary file mbed/LPC1768/cmsis_nvic.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC1768/core_cm3.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,1410 @@
+/******************************************************************************
+ * @file: core_cm3.h
+ * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Header File
+ * @version: V1.30 PRE-RELEASE
+ * @date: 30. July 2009
+ *----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2009 ARM Limited. All rights reserved.
+ *
+ * ARM Limited (ARM) is supplying this software for use with Cortex-Mx
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
+
+#ifndef __CM3_CORE_H__
+#define __CM3_CORE_H__
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */
+#define __CM3_CMSIS_VERSION_SUB (0x30) /*!< [15:0] CMSIS HAL sub version */
+#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
+
+#define __CORTEX_M (0x03) /*!< Cortex core */
+
+/**
+ * Lint configuration \n
+ * ----------------------- \n
+ *
+ * The following Lint messages will be suppressed and not shown: \n
+ * \n
+ * --- Error 10: --- \n
+ * register uint32_t __regBasePri __asm("basepri"); \n
+ * Error 10: Expecting ';' \n
+ * \n
+ * --- Error 530: --- \n
+ * return(__regBasePri); \n
+ * Warning 530: Symbol '__regBasePri' (line 264) not initialized \n
+ * \n
+ * --- Error 550: --- \n
+ * __regBasePri = (basePri & 0x1ff); \n
+ * } \n
+ * Warning 550: Symbol '__regBasePri' (line 271) not accessed \n
+ * \n
+ * --- Error 754: --- \n
+ * uint32_t RESERVED0[24]; \n
+ * Info 754: local structure member '<some, not used in the HAL>' (line 109, file ./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 750: --- \n
+ * #define __CM3_CORE_H__ \n
+ * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 528: --- \n
+ * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n
+ * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 751: --- \n
+ * } InterruptType_Type; \n
+ * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced \n
+ * \n
+ * \n
+ * Note: To re-enable a Message, insert a space before 'lint' * \n
+ *
+ */
+
+/*lint -save */
+/*lint -e10 */
+/*lint -e530 */
+/*lint -e550 */
+/*lint -e754 */
+/*lint -e750 */
+/*lint -e528 */
+/*lint -e751 */
+
+
+#include <stdint.h> /* Include standard types */
+
+#if defined (__ICCARM__)
+ #include <intrinsics.h> /* IAR Intrinsics */
+#endif
+
+
+#ifndef __NVIC_PRIO_BITS
+ #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */
+#endif
+
+
+
+
+/**
+ * IO definitions
+ *
+ * define access restrictions to peripheral registers
+ */
+
+#ifdef __cplusplus
+#define __I volatile /*!< defines 'read only' permissions */
+#else
+#define __I volatile const /*!< defines 'read only' permissions */
+#endif
+#define __O volatile /*!< defines 'write only' permissions */
+#define __IO volatile /*!< defines 'read / write' permissions */
+
+
+
+/*******************************************************************************
+ * Register Abstraction
+ ******************************************************************************/
+
+
+/* System Reset */
+#define NVIC_VECTRESET 0 /*!< Vector Reset Bit */
+#define NVIC_SYSRESETREQ 2 /*!< System Reset Request */
+#define NVIC_AIRCR_VECTKEY (0x5FA << 16) /*!< AIRCR Key for write access */
+#define NVIC_AIRCR_ENDIANESS 15 /*!< Endianess */
+
+/* Core Debug */
+#define CoreDebug_DEMCR_TRCENA (1 << 24) /*!< DEMCR TRCENA enable */
+#define ITM_TCR_ITMENA 1 /*!< ITM enable */
+
+
+
+
+/* memory mapping struct for Nested Vectored Interrupt Controller (NVIC) */
+typedef struct
+{
+ __IO uint32_t ISER[8]; /*!< Interrupt Set Enable Register */
+ uint32_t RESERVED0[24];
+ __IO uint32_t ICER[8]; /*!< Interrupt Clear Enable Register */
+ uint32_t RSERVED1[24];
+ __IO uint32_t ISPR[8]; /*!< Interrupt Set Pending Register */
+ uint32_t RESERVED2[24];
+ __IO uint32_t ICPR[8]; /*!< Interrupt Clear Pending Register */
+ uint32_t RESERVED3[24];
+ __IO uint32_t IABR[8]; /*!< Interrupt Active bit Register */
+ uint32_t RESERVED4[56];
+ __IO uint8_t IP[240]; /*!< Interrupt Priority Register, 8Bit wide */
+ uint32_t RESERVED5[644];
+ __O uint32_t STIR; /*!< Software Trigger Interrupt Register */
+} NVIC_Type;
+
+
+/* memory mapping struct for System Control Block */
+typedef struct
+{
+ __I uint32_t CPUID; /*!< CPU ID Base Register */
+ __IO uint32_t ICSR; /*!< Interrupt Control State Register */
+ __IO uint32_t VTOR; /*!< Vector Table Offset Register */
+ __IO uint32_t AIRCR; /*!< Application Interrupt / Reset Control Register */
+ __IO uint32_t SCR; /*!< System Control Register */
+ __IO uint32_t CCR; /*!< Configuration Control Register */
+ __IO uint8_t SHP[12]; /*!< System Handlers Priority Registers (4-7, 8-11, 12-15) */
+ __IO uint32_t SHCSR; /*!< System Handler Control and State Register */
+ __IO uint32_t CFSR; /*!< Configurable Fault Status Register */
+ __IO uint32_t HFSR; /*!< Hard Fault Status Register */
+ __IO uint32_t DFSR; /*!< Debug Fault Status Register */
+ __IO uint32_t MMFAR; /*!< Mem Manage Address Register */
+ __IO uint32_t BFAR; /*!< Bus Fault Address Register */
+ __IO uint32_t AFSR; /*!< Auxiliary Fault Status Register */
+ __I uint32_t PFR[2]; /*!< Processor Feature Register */
+ __I uint32_t DFR; /*!< Debug Feature Register */
+ __I uint32_t ADR; /*!< Auxiliary Feature Register */
+ __I uint32_t MMFR[4]; /*!< Memory Model Feature Register */
+ __I uint32_t ISAR[5]; /*!< ISA Feature Register */
+} SCB_Type;
+
+
+/* memory mapping struct for SysTick */
+typedef struct
+{
+ __IO uint32_t CTRL; /*!< SysTick Control and Status Register */
+ __IO uint32_t LOAD; /*!< SysTick Reload Value Register */
+ __IO uint32_t VAL; /*!< SysTick Current Value Register */
+ __I uint32_t CALIB; /*!< SysTick Calibration Register */
+} SysTick_Type;
+
+
+/* memory mapping structur for ITM */
+typedef struct
+{
+ __O union
+ {
+ __O uint8_t u8; /*!< ITM Stimulus Port 8-bit */
+ __O uint16_t u16; /*!< ITM Stimulus Port 16-bit */
+ __O uint32_t u32; /*!< ITM Stimulus Port 32-bit */
+ } PORT [32]; /*!< ITM Stimulus Port Registers */
+ uint32_t RESERVED0[864];
+ __IO uint32_t TER; /*!< ITM Trace Enable Register */
+ uint32_t RESERVED1[15];
+ __IO uint32_t TPR; /*!< ITM Trace Privilege Register */
+ uint32_t RESERVED2[15];
+ __IO uint32_t TCR; /*!< ITM Trace Control Register */
+ uint32_t RESERVED3[29];
+ __IO uint32_t IWR; /*!< ITM Integration Write Register */
+ __IO uint32_t IRR; /*!< ITM Integration Read Register */
+ __IO uint32_t IMCR; /*!< ITM Integration Mode Control Register */
+ uint32_t RESERVED4[43];
+ __IO uint32_t LAR; /*!< ITM Lock Access Register */
+ __IO uint32_t LSR; /*!< ITM Lock Status Register */
+ uint32_t RESERVED5[6];
+ __I uint32_t PID4; /*!< ITM Product ID Registers */
+ __I uint32_t PID5;
+ __I uint32_t PID6;
+ __I uint32_t PID7;
+ __I uint32_t PID0;
+ __I uint32_t PID1;
+ __I uint32_t PID2;
+ __I uint32_t PID3;
+ __I uint32_t CID0;
+ __I uint32_t CID1;
+ __I uint32_t CID2;
+ __I uint32_t CID3;
+} ITM_Type;
+
+
+/* memory mapped struct for Interrupt Type */
+typedef struct
+{
+ uint32_t RESERVED0;
+ __I uint32_t ICTR; /*!< Interrupt Control Type Register */
+#if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
+ __IO uint32_t ACTLR; /*!< Auxiliary Control Register */
+#else
+ uint32_t RESERVED1;
+#endif
+} InterruptType_Type;
+
+
+/* Memory Protection Unit */
+#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
+typedef struct
+{
+ __I uint32_t TYPE; /*!< MPU Type Register */
+ __IO uint32_t CTRL; /*!< MPU Control Register */
+ __IO uint32_t RNR; /*!< MPU Region RNRber Register */
+ __IO uint32_t RBAR; /*!< MPU Region Base Address Register */
+ __IO uint32_t RASR; /*!< MPU Region Attribute and Size Register */
+ __IO uint32_t RBAR_A1; /*!< MPU Alias 1 Region Base Address Register */
+ __IO uint32_t RASR_A1; /*!< MPU Alias 1 Region Attribute and Size Register */
+ __IO uint32_t RBAR_A2; /*!< MPU Alias 2 Region Base Address Register */
+ __IO uint32_t RASR_A2; /*!< MPU Alias 2 Region Attribute and Size Register */
+ __IO uint32_t RBAR_A3; /*!< MPU Alias 3 Region Base Address Register */
+ __IO uint32_t RASR_A3; /*!< MPU Alias 3 Region Attribute and Size Register */
+} MPU_Type;
+#endif
+
+
+/* Core Debug Register */
+typedef struct
+{
+ __IO uint32_t DHCSR; /*!< Debug Halting Control and Status Register */
+ __O uint32_t DCRSR; /*!< Debug Core Register Selector Register */
+ __IO uint32_t DCRDR; /*!< Debug Core Register Data Register */
+ __IO uint32_t DEMCR; /*!< Debug Exception and Monitor Control Register */
+} CoreDebug_Type;
+
+
+/* Memory mapping of Cortex-M3 Hardware */
+#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */
+#define ITM_BASE (0xE0000000) /*!< ITM Base Address */
+#define CoreDebug_BASE (0xE000EDF0) /*!< Core Debug Base Address */
+#define SysTick_BASE (SCS_BASE + 0x0010) /*!< SysTick Base Address */
+#define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */
+#define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */
+
+#define InterruptType ((InterruptType_Type *) SCS_BASE) /*!< Interrupt Type Register */
+#define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */
+#define SysTick ((SysTick_Type *) SysTick_BASE) /*!< SysTick configuration struct */
+#define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */
+#define ITM ((ITM_Type *) ITM_BASE) /*!< ITM configuration struct */
+#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */
+
+#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
+ #define MPU_BASE (SCS_BASE + 0x0D90) /*!< Memory Protection Unit */
+ #define MPU ((MPU_Type*) MPU_BASE) /*!< Memory Protection Unit */
+#endif
+
+
+/*******************************************************************************
+ * Hardware Abstraction Layer
+ ******************************************************************************/
+
+
+#if defined ( __CC_ARM )
+ #define __ASM __asm /*!< asm keyword for ARM Compiler */
+ #define __INLINE __inline /*!< inline keyword for ARM Compiler */
+
+#elif defined ( __ICCARM__ )
+ #define __ASM __asm /*!< asm keyword for IAR Compiler */
+ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
+
+#elif defined ( __GNUC__ )
+ #define __ASM __asm /*!< asm keyword for GNU Compiler */
+ #define __INLINE inline /*!< inline keyword for GNU Compiler */
+
+#elif defined ( __TASKING__ )
+ #define __ASM __asm /*!< asm keyword for TASKING Compiler */
+ #define __INLINE inline /*!< inline keyword for TASKING Compiler */
+
+#endif
+
+
+/* ################### Compiler specific Intrinsics ########################### */
+
+#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
+/* ARM armcc specific functions */
+
+#define __enable_fault_irq __enable_fiq
+#define __disable_fault_irq __disable_fiq
+
+#define __NOP __nop
+#define __WFI __wfi
+#define __WFE __wfe
+#define __SEV __sev
+#define __ISB() __isb(0)
+#define __DSB() __dsb(0)
+#define __DMB() __dmb(0)
+#define __REV __rev
+#define __RBIT __rbit
+#define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
+#define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
+#define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
+#define __STREXB(value, ptr) __strex(value, ptr)
+#define __STREXH(value, ptr) __strex(value, ptr)
+#define __STREXW(value, ptr) __strex(value, ptr)
+
+
+/* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
+/* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
+/* intrinsic void __enable_irq(); */
+/* intrinsic void __disable_irq(); */
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @param none
+ * @return uint32_t ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param uint32_t Process Stack Pointer
+ * @return none
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @param none
+ * @return uint32_t Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param uint32_t Main Stack Pointer
+ * @return none
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param uint16_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/*
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param int16_t value to reverse
+ * @return int32_t reversed value
+ *
+ * Reverse byte order in signed short value with sign extension to integer
+ */
+extern int32_t __REVSH(int16_t value);
+
+
+#if (__ARMCC_VERSION < 400000)
+
+/**
+ * @brief Remove the exclusive lock created by ldrex
+ *
+ * @param none
+ * @return none
+ *
+ * Removes the exclusive lock which is created by ldrex.
+ */
+extern void __CLREX(void);
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @param none
+ * @return uint32_t BasePriority
+ *
+ * Return the content of the base priority register
+ */
+extern uint32_t __get_BASEPRI(void);
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param uint32_t BasePriority
+ * @return none
+ *
+ * Set the base priority register
+ */
+extern void __set_BASEPRI(uint32_t basePri);
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @param none
+ * @return uint32_t PriMask
+ *
+ * Return the state of the priority mask bit from the priority mask
+ * register
+ */
+extern uint32_t __get_PRIMASK(void);
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param uint32_t PriMask
+ * @return none
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+extern void __set_PRIMASK(uint32_t priMask);
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @param none
+ * @return uint32_t FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+extern uint32_t __get_FAULTMASK(void);
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param uint32_t faultMask value
+ * @return none
+ *
+ * Set the fault mask register
+ */
+extern void __set_FAULTMASK(uint32_t faultMask);
+
+/**
+ * @brief Return the Control Register value
+ *
+ * @param none
+ * @return uint32_t Control value
+ *
+ * Return the content of the control register
+ */
+extern uint32_t __get_CONTROL(void);
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param uint32_t Control value
+ * @return none
+ *
+ * Set the control register
+ */
+extern void __set_CONTROL(uint32_t control);
+
+#else /* (__ARMCC_VERSION >= 400000) */
+
+
+/**
+ * @brief Remove the exclusive lock created by ldrex
+ *
+ * @param none
+ * @return none
+ *
+ * Removes the exclusive lock which is created by ldrex.
+ */
+#define __CLREX __clrex
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @param none
+ * @return uint32_t BasePriority
+ *
+ * Return the content of the base priority register
+ */
+static __INLINE uint32_t __get_BASEPRI(void)
+{
+ register uint32_t __regBasePri __ASM("basepri");
+ return(__regBasePri);
+}
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param uint32_t BasePriority
+ * @return none
+ *
+ * Set the base priority register
+ */
+static __INLINE void __set_BASEPRI(uint32_t basePri)
+{
+ register uint32_t __regBasePri __ASM("basepri");
+ __regBasePri = (basePri & 0xff);
+}
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @param none
+ * @return uint32_t PriMask
+ *
+ * Return the state of the priority mask bit from the priority mask
+ * register
+ */
+static __INLINE uint32_t __get_PRIMASK(void)
+{
+ register uint32_t __regPriMask __ASM("primask");
+ return(__regPriMask);
+}
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param uint32_t PriMask
+ * @return none
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+static __INLINE void __set_PRIMASK(uint32_t priMask)
+{
+ register uint32_t __regPriMask __ASM("primask");
+ __regPriMask = (priMask);
+}
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @param none
+ * @return uint32_t FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+static __INLINE uint32_t __get_FAULTMASK(void)
+{
+ register uint32_t __regFaultMask __ASM("faultmask");
+ return(__regFaultMask);
+}
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param uint32_t faultMask value
+ * @return none
+ *
+ * Set the fault mask register
+ */
+static __INLINE void __set_FAULTMASK(uint32_t faultMask)
+{
+ register uint32_t __regFaultMask __ASM("faultmask");
+ __regFaultMask = (faultMask & 1);
+}
+
+/**
+ * @brief Return the Control Register value
+ *
+ * @param none
+ * @return uint32_t Control value
+ *
+ * Return the content of the control register
+ */
+static __INLINE uint32_t __get_CONTROL(void)
+{
+ register uint32_t __regControl __ASM("control");
+ return(__regControl);
+}
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param uint32_t Control value
+ * @return none
+ *
+ * Set the control register
+ */
+static __INLINE void __set_CONTROL(uint32_t control)
+{
+ register uint32_t __regControl __ASM("control");
+ __regControl = control;
+}
+
+#endif /* __ARMCC_VERSION */
+
+
+
+#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
+/* IAR iccarm specific functions */
+
+#define __enable_irq __enable_interrupt /*!< global Interrupt enable */
+#define __disable_irq __disable_interrupt /*!< global Interrupt disable */
+
+static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); }
+static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); }
+
+#define __NOP __no_operation() /*!< no operation intrinsic in IAR Compiler */
+static __INLINE void __WFI() { __ASM ("wfi"); }
+static __INLINE void __WFE() { __ASM ("wfe"); }
+static __INLINE void __SEV() { __ASM ("sev"); }
+static __INLINE void __CLREX() { __ASM ("clrex"); }
+
+/* intrinsic void __ISB(void) */
+/* intrinsic void __DSB(void) */
+/* intrinsic void __DMB(void) */
+/* intrinsic void __set_PRIMASK(); */
+/* intrinsic void __get_PRIMASK(); */
+/* intrinsic void __set_FAULTMASK(); */
+/* intrinsic void __get_FAULTMASK(); */
+/* intrinsic uint32_t __REV(uint32_t value); */
+/* intrinsic uint32_t __REVSH(uint32_t value); */
+/* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
+/* intrinsic unsigned long __LDREX(unsigned long *); */
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @param none
+ * @return uint32_t ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param uint32_t Process Stack Pointer
+ * @return none
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @param none
+ * @return uint32_t Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param uint32_t Main Stack Pointer
+ * @return none
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param uint16_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param uint32_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse bit order of value
+ */
+extern uint32_t __RBIT(uint32_t value);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint8_t* address
+ * @return uint8_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint8_t __LDREXB(uint8_t *addr);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint16_t* address
+ * @return uint16_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint16_t __LDREXH(uint16_t *addr);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint32_t* address
+ * @return uint32_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint32_t __LDREXW(uint32_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint8_t *address
+ * @param uint8_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint16_t *address
+ * @param uint16_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint32_t *address
+ * @param uint32_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
+
+
+
+#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
+/* GNU gcc specific functions */
+
+static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }
+static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); }
+
+static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); }
+static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); }
+
+static __INLINE void __NOP() { __ASM volatile ("nop"); }
+static __INLINE void __WFI() { __ASM volatile ("wfi"); }
+static __INLINE void __WFE() { __ASM volatile ("wfe"); }
+static __INLINE void __SEV() { __ASM volatile ("sev"); }
+static __INLINE void __ISB() { __ASM volatile ("isb"); }
+static __INLINE void __DSB() { __ASM volatile ("dsb"); }
+static __INLINE void __DMB() { __ASM volatile ("dmb"); }
+static __INLINE void __CLREX() { __ASM volatile ("clrex"); }
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @param none
+ * @return uint32_t ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param uint32_t Process Stack Pointer
+ * @return none
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @param none
+ * @return uint32_t Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param uint32_t Main Stack Pointer
+ * @return none
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @param none
+ * @return uint32_t BasePriority
+ *
+ * Return the content of the base priority register
+ */
+extern uint32_t __get_BASEPRI(void);
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param uint32_t BasePriority
+ * @return none
+ *
+ * Set the base priority register
+ */
+extern void __set_BASEPRI(uint32_t basePri);
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @param none
+ * @return uint32_t PriMask
+ *
+ * Return the state of the priority mask bit from the priority mask
+ * register
+ */
+extern uint32_t __get_PRIMASK(void);
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param uint32_t PriMask
+ * @return none
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+extern void __set_PRIMASK(uint32_t priMask);
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @param none
+ * @return uint32_t FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+extern uint32_t __get_FAULTMASK(void);
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param uint32_t faultMask value
+ * @return none
+ *
+ * Set the fault mask register
+ */
+extern void __set_FAULTMASK(uint32_t faultMask);
+
+/**
+ * @brief Return the Control Register value
+*
+* @param none
+* @return uint32_t Control value
+ *
+ * Return the content of the control register
+ */
+extern uint32_t __get_CONTROL(void);
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param uint32_t Control value
+ * @return none
+ *
+ * Set the control register
+ */
+extern void __set_CONTROL(uint32_t control);
+
+/**
+ * @brief Reverse byte order in integer value
+ *
+ * @param uint32_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse byte order in integer value
+ */
+extern uint32_t __REV(uint32_t value);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param uint16_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/*
+ * Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param int16_t value to reverse
+ * @return int32_t reversed value
+ *
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ */
+extern int32_t __REVSH(int16_t value);
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param uint32_t value to reverse
+ * @return uint32_t reversed value
+ *
+ * Reverse bit order of value
+ */
+extern uint32_t __RBIT(uint32_t value);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint8_t* address
+ * @return uint8_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint8_t __LDREXB(uint8_t *addr);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint16_t* address
+ * @return uint16_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint16_t __LDREXH(uint16_t *addr);
+
+/**
+ * @brief LDR Exclusive
+ *
+ * @param uint32_t* address
+ * @return uint32_t value of (*address)
+ *
+ * Exclusive LDR command
+ */
+extern uint32_t __LDREXW(uint32_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint8_t *address
+ * @param uint8_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint16_t *address
+ * @param uint16_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
+
+/**
+ * @brief STR Exclusive
+ *
+ * @param uint32_t *address
+ * @param uint32_t value to store
+ * @return uint32_t successful / failed
+ *
+ * Exclusive STR command
+ */
+extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
+
+
+#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
+/* TASKING carm specific functions */
+
+/*
+ * The CMSIS functions have been implemented as intrinsics in the compiler.
+ * Please use "carm -?i" to get an up to date list of all instrinsics,
+ * Including the CMSIS ones.
+ */
+
+#endif
+
+
+
+/* ########################## NVIC functions #################################### */
+
+
+/**
+ * @brief Set the Priority Grouping in NVIC Interrupt Controller
+ *
+ * @param uint32_t priority_grouping is priority grouping field
+ * @return none
+ *
+ * Set the priority grouping field using the required unlock sequence.
+ * The parameter priority_grouping is assigned to the field
+ * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
+ */
+static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
+{
+ uint32_t reg_value;
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+
+ reg_value = SCB->AIRCR; /* read old register configuration */
+ reg_value &= ~((0xFFFFU << 16) | (0x0F << 8)); /* clear bits to change */
+ reg_value = ((reg_value | NVIC_AIRCR_VECTKEY | (PriorityGroupTmp << 8))); /* Insert write key and priorty group */
+ SCB->AIRCR = reg_value;
+}
+
+/**
+ * @brief Get the Priority Grouping from NVIC Interrupt Controller
+ *
+ * @param none
+ * @return uint32_t priority grouping field
+ *
+ * Get the priority grouping from NVIC Interrupt Controller.
+ * priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
+ */
+static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
+{
+ return ((SCB->AIRCR >> 8) & 0x07); /* read priority grouping field */
+}
+
+/**
+ * @brief Enable Interrupt in NVIC Interrupt Controller
+ *
+ * @param IRQn_Type IRQn specifies the interrupt number
+ * @return none
+ *
+ * Enable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
+{
+ NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
+}
+
+/**
+ * @brief Disable the interrupt line for external interrupt specified
+ *
+ * @param IRQn_Type IRQn is the positive number of the external interrupt
+ * @return none
+ *
+ * Disable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
+{
+ NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
+}
+
+/**
+ * @brief Read the interrupt pending bit for a device specific interrupt source
+ *
+ * @param IRQn_Type IRQn is the number of the device specifc interrupt
+ * @return uint32_t 1 if pending interrupt else 0
+ *
+ * Read the pending register in NVIC and return 1 if its status is pending,
+ * otherwise it returns 0
+ */
+static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
+{
+ return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
+}
+
+/**
+ * @brief Set the pending bit for an external interrupt
+ *
+ * @param IRQn_Type IRQn is the Number of the interrupt
+ * @return none
+ *
+ * Set the pending bit for the specified interrupt.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
+{
+ NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
+}
+
+/**
+ * @brief Clear the pending bit for an external interrupt
+ *
+ * @param IRQn_Type IRQn is the Number of the interrupt
+ * @return none
+ *
+ * Clear the pending bit for the specified interrupt.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
+{
+ NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
+}
+
+/**
+ * @brief Read the active bit for an external interrupt
+ *
+ * @param IRQn_Type IRQn is the Number of the interrupt
+ * @return uint32_t 1 if active else 0
+ *
+ * Read the active register in NVIC and returns 1 if its status is active,
+ * otherwise it returns 0.
+ */
+static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
+{
+ return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
+}
+
+/**
+ * @brief Set the priority for an interrupt
+ *
+ * @param IRQn_Type IRQn is the Number of the interrupt
+ * @param priority is the priority for the interrupt
+ * @return none
+ *
+ * Set the priority for the specified interrupt. The interrupt
+ * number can be positive to specify an external (device specific)
+ * interrupt, or negative to specify an internal (core) interrupt. \n
+ *
+ * Note: The priority cannot be set for every core interrupt.
+ */
+static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
+{
+ if(IRQn < 0) {
+ SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
+ else {
+ NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
+}
+
+/**
+ * @brief Read the priority for an interrupt
+ *
+ * @param IRQn_Type IRQn is the Number of the interrupt
+ * @return uint32_t priority is the priority for the interrupt
+ *
+ * Read the priority for the specified interrupt. The interrupt
+ * number can be positive to specify an external (device specific)
+ * interrupt, or negative to specify an internal (core) interrupt.
+ *
+ * The returned priority value is automatically aligned to the implemented
+ * priority bits of the microcontroller.
+ *
+ * Note: The priority cannot be set for every core interrupt.
+ */
+static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
+{
+
+ if(IRQn < 0) {
+ return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */
+ else {
+ return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
+}
+
+
+/**
+ * @brief Encode the priority for an interrupt
+ *
+ * @param uint32_t PriorityGroup is the used priority group
+ * @param uint32_t PreemptPriority is the preemptive priority value (starting from 0)
+ * @param uint32_t SubPriority is the sub priority value (starting from 0)
+ * @return uint32_t the priority for the interrupt
+ *
+ * Encode the priority for an interrupt with the given priority group,
+ * preemptive priority value and sub priority value.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
+ *
+ * The returned priority value can be used for NVIC_SetPriority(...) function
+ */
+static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
+{
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+ uint32_t PreemptPriorityBits;
+ uint32_t SubPriorityBits;
+
+ PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
+ SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
+
+ return (
+ ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
+ ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
+ );
+}
+
+
+/**
+ * @brief Decode the priority of an interrupt
+ *
+ * @param uint32_t Priority the priority for the interrupt
+ * @param uint32_t PrioGroup is the used priority group
+ * @param uint32_t* pPreemptPrio is the preemptive priority value (starting from 0)
+ * @param uint32_t* pSubPrio is the sub priority value (starting from 0)
+ * @return none
+ *
+ * Decode an interrupt priority value with the given priority group to
+ * preemptive priority value and sub priority value.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
+ *
+ * The priority value can be retrieved with NVIC_GetPriority(...) function
+ */
+static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
+{
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+ uint32_t PreemptPriorityBits;
+ uint32_t SubPriorityBits;
+
+ PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
+ SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
+
+ *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
+ *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
+}
+
+
+
+/* ################################## SysTick function ############################################ */
+
+#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
+
+/* SysTick constants */
+#define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */
+#define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */
+#define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */
+#define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */
+
+/**
+ * @brief Initialize and start the SysTick counter and its interrupt.
+ *
+ * @param uint32_t ticks is the number of ticks between two interrupts
+ * @return none
+ *
+ * Initialise the system tick timer and its interrupt and start the
+ * system tick timer / counter in free running mode to generate
+ * periodical interrupts.
+ */
+static __INLINE uint32_t SysTick_Config(uint32_t ticks)
+{
+ if (ticks > SYSTICK_MAXCOUNT) return (1); /* Reload value impossible */
+
+ SysTick->LOAD = (ticks & SYSTICK_MAXCOUNT) - 1; /* set reload register */
+ NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
+ SysTick->VAL = (0x00); /* Load the SysTick Counter Value */
+ SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<<SYSTICK_ENABLE) | (1<<SYSTICK_TICKINT); /* Enable SysTick IRQ and SysTick Timer */
+ return (0); /* Function successful */
+}
+
+#endif
+
+
+
+
+
+/* ################################## Reset function ############################################ */
+
+/**
+ * @brief Initiate a system reset request.
+ *
+ * @param none
+ * @return none
+ *
+ * Initialize a system reset request to reset the MCU
+ */
+static __INLINE void NVIC_SystemReset(void)
+{
+ SCB->AIRCR = (NVIC_AIRCR_VECTKEY | (SCB->AIRCR & (0x700)) | (1<<NVIC_SYSRESETREQ)); /* Keep priority group unchanged */
+ __DSB(); /* Ensure completion of memory access */
+ while(1); /* wait until reset */
+}
+
+
+/* ##################################### Debug In/Output function ########################################### */
+
+extern volatile int ITM_RxBuffer; /* variable to receive characters */
+#define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /* value identifying ITM_RxBuffer is ready for next character */
+
+
+/**
+ * @brief Outputs a character via the ITM channel 0
+ *
+ * @param uint32_t character to output
+ * @return uint32_t input character
+ *
+ * The function outputs a character via the ITM channel 0.
+ * The function returns when no debugger is connected that has booked the output.
+ * It is blocking when a debugger is connected, but the previous character send is not transmitted.
+ */
+static __INLINE uint32_t ITM_SendChar (uint32_t ch)
+{
+ if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA) &&
+ (ITM->TCR & ITM_TCR_ITMENA) &&
+ (ITM->TER & (1UL << 0)) )
+ {
+ while (ITM->PORT[0].u32 == 0);
+ ITM->PORT[0].u8 = (uint8_t) ch;
+ }
+ return (ch);
+}
+
+
+/**
+ * @brief Inputs a character via variable ITM_RxBuffer
+ *
+ * @param none
+ * @return uint32_t input character
+ *
+ * The function inputs a character via variable ITM_RxBuffer.
+ * The function returns when no debugger is connected that has booked the output.
+ * It is blocking when a debugger is connected, but the previous character send is not transmitted.
+ */
+static __INLINE int ITM_ReceiveChar (void) {
+ int ch = -1; /* no character available */
+
+ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
+ ch = ITM_RxBuffer;
+ ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
+ }
+
+ return (ch);
+}
+
+
+/**
+ * @brief Check if a character via variable ITM_RxBuffer is available
+ *
+ * @param none
+ * @return int 1 = character available, 0 = no character available
+ *
+ * The function checks variable ITM_RxBuffer whether a character is available or not.
+ * The function returns '1' if a character is available and '0' if no character is available.
+ */
+static __INLINE int ITM_CheckChar (void) {
+
+ if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
+ return (0); /* no character available */
+ } else {
+ return (1); /* character available */
+ }
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CM3_CORE_H__ */
+
+/*lint -restore */
Binary file mbed/LPC1768/core_cm3.o has changed
Binary file mbed/LPC1768/mbed.ar has changed
Binary file mbed/LPC1768/stackheap.o has changed
Binary file mbed/LPC1768/startup_LPC17xx.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC1768/system_LPC17xx.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * @file: system_LPC17xx.h
+ * @purpose: CMSIS Cortex-M3 Device Peripheral Access Layer Header File
+ * for the NXP LPC17xx Device Series
+ * @version: V1.02
+ * @date: 27. July 2009
+ *----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2009 ARM Limited. All rights reserved.
+ *
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M3
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
+
+
+#ifndef __SYSTEM_LPC17xx_H
+#define __SYSTEM_LPC17xx_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
+
+
+/**
+ * Initialize the system
+ *
+ * @param none
+ * @return none
+ *
+ * @brief Setup the microcontroller system.
+ * Initialize the System and update the SystemCoreClock variable.
+ */
+extern void SystemInit (void);
+
+/**
+ * Update SystemCoreClock variable
+ *
+ * @param none
+ * @return none
+ *
+ * @brief Updates the SystemCoreClock with current core Clock
+ * retrieved from cpu registers.
+ */
+extern void SystemCoreClockUpdate (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SYSTEM_LPC17xx_H */
Binary file mbed/LPC1768/system_LPC17xx.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC2368/LPC2368.sct Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,24 @@
+
+LR_IROM1 0x00000000 0x80000 { ; load region size_region
+ ER_IROM1 0x00000000 0x80000 { ; load address = execution address
+ *.o (RESET, +First)
+ *(InRoot$$Sections)
+ .ANY (+RO)
+ }
+ RW_IRAM1 0x40000120 0x7EE0 { ; RW data, inc space for realmonitor
+ .ANY (+RW +ZI)
+ }
+ RW_IRAM2 0x7FD00000 0x2000 { ; RW data, USB RAM
+ .ANY (AHBSRAM0)
+ }
+ RW_IRAM3 0x7FE00000 0x4000 { ; RW data, ETH RAM
+ .ANY (AHBSRAM1)
+ }
+ RW_IRAM4 0xE0038000 0x0800 { ; RW data, CAN RAM
+ .ANY (CANRAM)
+ }
+ RW_IRAM5 0xE0084000 0x0800 { ; RW data, RTC RAM
+ .ANY (RTCRAM)
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC2368/LPC23xx.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,862 @@
+/* mbed Microcontroller Library - LPC23xx CMSIS-like structs
+ * Copyright (C) 2009 ARM Limited. All rights reserved.
+ *
+ * An LPC23xx header file, based on the CMSIS LPC17xx.h and old LPC23xx.h
+ */
+
+#ifndef __LPC23xx_H
+#define __LPC23xx_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*
+ * ==========================================================================
+ * ---------- Interrupt Number Definition -----------------------------------
+ * ==========================================================================
+ */
+
+typedef enum IRQn
+{
+/****** LPC23xx Specific Interrupt Numbers *******************************************************/
+ WDT_IRQn = 0, /*!< Watchdog Timer Interrupt */
+
+ TIMER0_IRQn = 4, /*!< Timer0 Interrupt */
+ TIMER1_IRQn = 5, /*!< Timer1 Interrupt */
+ UART0_IRQn = 6, /*!< UART0 Interrupt */
+ UART1_IRQn = 7, /*!< UART1 Interrupt */
+ PWM1_IRQn = 8, /*!< PWM1 Interrupt */
+ I2C0_IRQn = 9, /*!< I2C0 Interrupt */
+ SPI_IRQn = 10, /*!< SPI Interrupt */
+ SSP0_IRQn = 10, /*!< SSP0 Interrupt */
+ SSP1_IRQn = 11, /*!< SSP1 Interrupt */
+ PLL0_IRQn = 12, /*!< PLL0 Lock (Main PLL) Interrupt */
+ RTC_IRQn = 13, /*!< Real Time Clock Interrupt */
+ EINT0_IRQn = 14, /*!< External Interrupt 0 Interrupt */
+ EINT1_IRQn = 15, /*!< External Interrupt 1 Interrupt */
+ EINT2_IRQn = 16, /*!< External Interrupt 2 Interrupt */
+ EINT3_IRQn = 17, /*!< External Interrupt 3 Interrupt */
+ ADC_IRQn = 18, /*!< A/D Converter Interrupt */
+ I2C1_IRQn = 19, /*!< I2C1 Interrupt */
+ BOD_IRQn = 20, /*!< Brown-Out Detect Interrupt */
+ ENET_IRQn = 21, /*!< Ethernet Interrupt */
+ USB_IRQn = 22, /*!< USB Interrupt */
+ CAN_IRQn = 23, /*!< CAN Interrupt */
+ MIC_IRQn = 24, /*!< Multimedia Interface Controler */
+ DMA_IRQn = 25, /*!< General Purpose DMA Interrupt */
+ TIMER2_IRQn = 26, /*!< Timer2 Interrupt */
+ TIMER3_IRQn = 27, /*!< Timer3 Interrupt */
+ UART2_IRQn = 28, /*!< UART2 Interrupt */
+ UART3_IRQn = 29, /*!< UART3 Interrupt */
+ I2C2_IRQn = 30, /*!< I2C2 Interrupt */
+ I2S_IRQn = 31, /*!< I2S Interrupt */
+} IRQn_Type;
+
+/*
+ * ==========================================================================
+ * ----------- Processor and Core Peripheral Section ------------------------
+ * ==========================================================================
+ */
+
+/* Configuration of the ARM7 Processor and Core Peripherals */
+#define __MPU_PRESENT 0 /*!< MPU present or not */
+#define __NVIC_PRIO_BITS 4 /*!< Number of Bits used for Priority Levels */
+#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
+
+
+#include <core_arm7.h>
+#include "system_LPC23xx.h" /* System Header */
+
+
+/******************************************************************************/
+/* Device Specific Peripheral registers structures */
+/******************************************************************************/
+
+#pragma anon_unions
+
+/*------------- Vector Interupt Controler (VIC) ------------------------------*/
+typedef struct
+{
+ __I uint32_t IRQStatus;
+ __I uint32_t FIQStatus;
+ __I uint32_t RawIntr;
+ __IO uint32_t IntSelect;
+ __IO uint32_t IntEnable;
+ __O uint32_t IntEnClr;
+ __IO uint32_t SoftInt;
+ __O uint32_t SoftIntClr;
+ __IO uint32_t Protection;
+ __IO uint32_t SWPriorityMask;
+ __IO uint32_t RESERVED0[54];
+ __IO uint32_t VectAddr[32];
+ __IO uint32_t RESERVED1[32];
+ __IO uint32_t VectPriority[32];
+ __IO uint32_t RESERVED2[800];
+ __IO uint32_t Address;
+} LPC_VIC_TypeDef;
+
+/*------------- System Control (SC) ------------------------------------------*/
+typedef struct
+{
+ __IO uint32_t MAMCR;
+ __IO uint32_t MAMTIM;
+ uint32_t RESERVED0[14];
+ __IO uint32_t MEMMAP;
+ uint32_t RESERVED1[15];
+ __IO uint32_t PLL0CON; /* Clocking and Power Control */
+ __IO uint32_t PLL0CFG;
+ __I uint32_t PLL0STAT;
+ __O uint32_t PLL0FEED;
+ uint32_t RESERVED2[12];
+ __IO uint32_t PCON;
+ __IO uint32_t PCONP;
+ uint32_t RESERVED3[15];
+ __IO uint32_t CCLKCFG;
+ __IO uint32_t USBCLKCFG;
+ __IO uint32_t CLKSRCSEL;
+ uint32_t RESERVED4[12];
+ __IO uint32_t EXTINT; /* External Interrupts */
+ __IO uint32_t INTWAKE;
+ __IO uint32_t EXTMODE;
+ __IO uint32_t EXTPOLAR;
+ uint32_t RESERVED6[12];
+ __IO uint32_t RSID; /* Reset */
+ __IO uint32_t CSPR;
+ __IO uint32_t AHBCFG1;
+ __IO uint32_t AHBCFG2;
+ uint32_t RESERVED7[4];
+ __IO uint32_t SCS; /* Syscon Miscellaneous Registers */
+ __IO uint32_t IRCTRIM; /* Clock Dividers */
+ __IO uint32_t PCLKSEL0;
+ __IO uint32_t PCLKSEL1;
+ uint32_t RESERVED8[4];
+ __IO uint32_t USBIntSt; /* USB Device/OTG Interrupt Register */
+ uint32_t RESERVED9;
+// __IO uint32_t CLKOUTCFG; /* Clock Output Configuration */
+ } LPC_SC_TypeDef;
+
+/*------------- Pin Connect Block (PINCON) -----------------------------------*/
+typedef struct
+{
+ __IO uint32_t PINSEL0;
+ __IO uint32_t PINSEL1;
+ __IO uint32_t PINSEL2;
+ __IO uint32_t PINSEL3;
+ __IO uint32_t PINSEL4;
+ __IO uint32_t PINSEL5;
+ __IO uint32_t PINSEL6;
+ __IO uint32_t PINSEL7;
+ __IO uint32_t PINSEL8;
+ __IO uint32_t PINSEL9;
+ __IO uint32_t PINSEL10;
+ uint32_t RESERVED0[5];
+ __IO uint32_t PINMODE0;
+ __IO uint32_t PINMODE1;
+ __IO uint32_t PINMODE2;
+ __IO uint32_t PINMODE3;
+ __IO uint32_t PINMODE4;
+ __IO uint32_t PINMODE5;
+ __IO uint32_t PINMODE6;
+ __IO uint32_t PINMODE7;
+ __IO uint32_t PINMODE8;
+ __IO uint32_t PINMODE9;
+ __IO uint32_t PINMODE_OD0;
+ __IO uint32_t PINMODE_OD1;
+ __IO uint32_t PINMODE_OD2;
+ __IO uint32_t PINMODE_OD3;
+ __IO uint32_t PINMODE_OD4;
+} LPC_PINCON_TypeDef;
+
+/*------------- General Purpose Input/Output (GPIO) --------------------------*/
+typedef struct
+{
+ __IO uint32_t FIODIR;
+ uint32_t RESERVED0[3];
+ __IO uint32_t FIOMASK;
+ __IO uint32_t FIOPIN;
+ __IO uint32_t FIOSET;
+ __O uint32_t FIOCLR;
+} LPC_GPIO_TypeDef;
+
+typedef struct
+{
+ __I uint32_t IntStatus;
+ __I uint32_t IO0IntStatR;
+ __I uint32_t IO0IntStatF;
+ __O uint32_t IO0IntClr;
+ __IO uint32_t IO0IntEnR;
+ __IO uint32_t IO0IntEnF;
+ uint32_t RESERVED0[3];
+ __I uint32_t IO2IntStatR;
+ __I uint32_t IO2IntStatF;
+ __O uint32_t IO2IntClr;
+ __IO uint32_t IO2IntEnR;
+ __IO uint32_t IO2IntEnF;
+} LPC_GPIOINT_TypeDef;
+
+/*------------- Timer (TIM) --------------------------------------------------*/
+typedef struct
+{
+ __IO uint32_t IR;
+ __IO uint32_t TCR;
+ __IO uint32_t TC;
+ __IO uint32_t PR;
+ __IO uint32_t PC;
+ __IO uint32_t MCR;
+ __IO uint32_t MR0;
+ __IO uint32_t MR1;
+ __IO uint32_t MR2;
+ __IO uint32_t MR3;
+ __IO uint32_t CCR;
+ __I uint32_t CR0;
+ __I uint32_t CR1;
+ uint32_t RESERVED0[2];
+ __IO uint32_t EMR;
+ uint32_t RESERVED1[12];
+ __IO uint32_t CTCR;
+} LPC_TIM_TypeDef;
+
+/*------------- Pulse-Width Modulation (PWM) ---------------------------------*/
+typedef struct
+{
+ __IO uint32_t IR;
+ __IO uint32_t TCR;
+ __IO uint32_t TC;
+ __IO uint32_t PR;
+ __IO uint32_t PC;
+ __IO uint32_t MCR;
+ __IO uint32_t MR0;
+ __IO uint32_t MR1;
+ __IO uint32_t MR2;
+ __IO uint32_t MR3;
+ __IO uint32_t CCR;
+ __I uint32_t CR0;
+ __I uint32_t CR1;
+ __I uint32_t CR2;
+ __I uint32_t CR3;
+ uint32_t RESERVED0;
+ __IO uint32_t MR4;
+ __IO uint32_t MR5;
+ __IO uint32_t MR6;
+ __IO uint32_t PCR;
+ __IO uint32_t LER;
+ uint32_t RESERVED1[7];
+ __IO uint32_t CTCR;
+} LPC_PWM_TypeDef;
+
+/*------------- Universal Asynchronous Receiver Transmitter (UART) -----------*/
+typedef struct
+{
+ union {
+ __I uint8_t RBR;
+ __O uint8_t THR;
+ __IO uint8_t DLL;
+ uint32_t RESERVED0;
+ };
+ union {
+ __IO uint8_t DLM;
+ __IO uint32_t IER;
+ };
+ union {
+ __I uint32_t IIR;
+ __O uint8_t FCR;
+ };
+ __IO uint8_t LCR;
+ uint8_t RESERVED1[7];
+ __IO uint8_t LSR;
+ uint8_t RESERVED2[7];
+ __IO uint8_t SCR;
+ uint8_t RESERVED3[3];
+ __IO uint32_t ACR;
+ __IO uint8_t ICR;
+ uint8_t RESERVED4[3];
+ __IO uint8_t FDR;
+ uint8_t RESERVED5[7];
+ __IO uint8_t TER;
+ uint8_t RESERVED6[27];
+ __IO uint8_t RS485CTRL;
+ uint8_t RESERVED7[3];
+ __IO uint8_t ADRMATCH;
+} LPC_UART_TypeDef;
+
+typedef struct
+{
+ union {
+ __I uint8_t RBR;
+ __O uint8_t THR;
+ __IO uint8_t DLL;
+ uint32_t RESERVED0;
+ };
+ union {
+ __IO uint8_t DLM;
+ __IO uint32_t IER;
+ };
+ union {
+ __I uint32_t IIR;
+ __O uint8_t FCR;
+ };
+ __IO uint8_t LCR;
+ uint8_t RESERVED1[3];
+ __IO uint8_t MCR;
+ uint8_t RESERVED2[3];
+ __IO uint8_t LSR;
+ uint8_t RESERVED3[3];
+ __IO uint8_t MSR;
+ uint8_t RESERVED4[3];
+ __IO uint8_t SCR;
+ uint8_t RESERVED5[3];
+ __IO uint32_t ACR;
+ uint32_t RESERVED6;
+ __IO uint32_t FDR;
+ uint32_t RESERVED7;
+ __IO uint8_t TER;
+ uint8_t RESERVED8[27];
+ __IO uint8_t RS485CTRL;
+ uint8_t RESERVED9[3];
+ __IO uint8_t ADRMATCH;
+ uint8_t RESERVED10[3];
+ __IO uint8_t RS485DLY;
+} LPC_UART1_TypeDef;
+
+/*------------- Serial Peripheral Interface (SPI) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t SPCR;
+ __I uint32_t SPSR;
+ __IO uint32_t SPDR;
+ __IO uint32_t SPCCR;
+ uint32_t RESERVED0[3];
+ __IO uint32_t SPINT;
+} LPC_SPI_TypeDef;
+
+/*------------- Synchronous Serial Communication (SSP) -----------------------*/
+typedef struct
+{
+ __IO uint32_t CR0;
+ __IO uint32_t CR1;
+ __IO uint32_t DR;
+ __I uint32_t SR;
+ __IO uint32_t CPSR;
+ __IO uint32_t IMSC;
+ __IO uint32_t RIS;
+ __IO uint32_t MIS;
+ __IO uint32_t ICR;
+ __IO uint32_t DMACR;
+} LPC_SSP_TypeDef;
+
+/*------------- Inter-Integrated Circuit (I2C) -------------------------------*/
+typedef struct
+{
+ __IO uint32_t I2CONSET;
+ __I uint32_t I2STAT;
+ __IO uint32_t I2DAT;
+ __IO uint32_t I2ADR0;
+ __IO uint32_t I2SCLH;
+ __IO uint32_t I2SCLL;
+ __O uint32_t I2CONCLR;
+ __IO uint32_t MMCTRL;
+ __IO uint32_t I2ADR1;
+ __IO uint32_t I2ADR2;
+ __IO uint32_t I2ADR3;
+ __I uint32_t I2DATA_BUFFER;
+ __IO uint32_t I2MASK0;
+ __IO uint32_t I2MASK1;
+ __IO uint32_t I2MASK2;
+ __IO uint32_t I2MASK3;
+} LPC_I2C_TypeDef;
+
+/*------------- Inter IC Sound (I2S) -----------------------------------------*/
+typedef struct
+{
+ __IO uint32_t I2SDAO;
+ __I uint32_t I2SDAI;
+ __O uint32_t I2STXFIFO;
+ __I uint32_t I2SRXFIFO;
+ __I uint32_t I2SSTATE;
+ __IO uint32_t I2SDMA1;
+ __IO uint32_t I2SDMA2;
+ __IO uint32_t I2SIRQ;
+ __IO uint32_t I2STXRATE;
+ __IO uint32_t I2SRXRATE;
+ __IO uint32_t I2STXBITRATE;
+ __IO uint32_t I2SRXBITRATE;
+ __IO uint32_t I2STXMODE;
+ __IO uint32_t I2SRXMODE;
+} LPC_I2S_TypeDef;
+
+/*------------- Real-Time Clock (RTC) ----------------------------------------*/
+typedef struct
+{
+ __IO uint8_t ILR;
+ uint8_t RESERVED0[3];
+ __IO uint8_t CTC;
+ uint8_t RESERVED1[3];
+ __IO uint8_t CCR;
+ uint8_t RESERVED2[3];
+ __IO uint8_t CIIR;
+ uint8_t RESERVED3[3];
+ __IO uint8_t AMR;
+ uint8_t RESERVED4[3];
+ __I uint32_t CTIME0;
+ __I uint32_t CTIME1;
+ __I uint32_t CTIME2;
+ __IO uint8_t SEC;
+ uint8_t RESERVED5[3];
+ __IO uint8_t MIN;
+ uint8_t RESERVED6[3];
+ __IO uint8_t HOUR;
+ uint8_t RESERVED7[3];
+ __IO uint8_t DOM;
+ uint8_t RESERVED8[3];
+ __IO uint8_t DOW;
+ uint8_t RESERVED9[3];
+ __IO uint16_t DOY;
+ uint16_t RESERVED10;
+ __IO uint8_t MONTH;
+ uint8_t RESERVED11[3];
+ __IO uint16_t YEAR;
+ uint16_t RESERVED12;
+ __IO uint32_t CALIBRATION;
+ __IO uint32_t GPREG0;
+ __IO uint32_t GPREG1;
+ __IO uint32_t GPREG2;
+ __IO uint32_t GPREG3;
+ __IO uint32_t GPREG4;
+ __IO uint8_t WAKEUPDIS;
+ uint8_t RESERVED13[3];
+ __IO uint8_t PWRCTRL;
+ uint8_t RESERVED14[3];
+ __IO uint8_t ALSEC;
+ uint8_t RESERVED15[3];
+ __IO uint8_t ALMIN;
+ uint8_t RESERVED16[3];
+ __IO uint8_t ALHOUR;
+ uint8_t RESERVED17[3];
+ __IO uint8_t ALDOM;
+ uint8_t RESERVED18[3];
+ __IO uint8_t ALDOW;
+ uint8_t RESERVED19[3];
+ __IO uint16_t ALDOY;
+ uint16_t RESERVED20;
+ __IO uint8_t ALMON;
+ uint8_t RESERVED21[3];
+ __IO uint16_t ALYEAR;
+ uint16_t RESERVED22;
+} LPC_RTC_TypeDef;
+
+/*------------- Watchdog Timer (WDT) -----------------------------------------*/
+typedef struct
+{
+ __IO uint8_t WDMOD;
+ uint8_t RESERVED0[3];
+ __IO uint32_t WDTC;
+ __O uint8_t WDFEED;
+ uint8_t RESERVED1[3];
+ __I uint32_t WDTV;
+ __IO uint32_t WDCLKSEL;
+} LPC_WDT_TypeDef;
+
+/*------------- Analog-to-Digital Converter (ADC) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t ADCR;
+ __IO uint32_t ADGDR;
+ uint32_t RESERVED0;
+ __IO uint32_t ADINTEN;
+ __I uint32_t ADDR0;
+ __I uint32_t ADDR1;
+ __I uint32_t ADDR2;
+ __I uint32_t ADDR3;
+ __I uint32_t ADDR4;
+ __I uint32_t ADDR5;
+ __I uint32_t ADDR6;
+ __I uint32_t ADDR7;
+ __I uint32_t ADSTAT;
+ __IO uint32_t ADTRM;
+} LPC_ADC_TypeDef;
+
+/*------------- Digital-to-Analog Converter (DAC) ----------------------------*/
+typedef struct
+{
+ __IO uint32_t DACR;
+ __IO uint32_t DACCTRL;
+ __IO uint16_t DACCNTVAL;
+} LPC_DAC_TypeDef;
+
+/*------------- Multimedia Card Interface (MCI) ------------------------------*/
+typedef struct
+{
+ __IO uint32_t MCIPower; /* Power control */
+ __IO uint32_t MCIClock; /* Clock control */
+ __IO uint32_t MCIArgument;
+ __IO uint32_t MMCCommand;
+ __I uint32_t MCIRespCmd;
+ __I uint32_t MCIResponse0;
+ __I uint32_t MCIResponse1;
+ __I uint32_t MCIResponse2;
+ __I uint32_t MCIResponse3;
+ __IO uint32_t MCIDataTimer;
+ __IO uint32_t MCIDataLength;
+ __IO uint32_t MCIDataCtrl;
+ __I uint32_t MCIDataCnt;
+} LPC_MCI_TypeDef;
+
+/*------------- Controller Area Network (CAN) --------------------------------*/
+typedef struct
+{
+ __IO uint32_t mask[512]; /* ID Masks */
+} LPC_CANAF_RAM_TypeDef;
+
+typedef struct /* Acceptance Filter Registers */
+{
+ __IO uint32_t AFMR;
+ __IO uint32_t SFF_sa;
+ __IO uint32_t SFF_GRP_sa;
+ __IO uint32_t EFF_sa;
+ __IO uint32_t EFF_GRP_sa;
+ __IO uint32_t ENDofTable;
+ __I uint32_t LUTerrAd;
+ __I uint32_t LUTerr;
+} LPC_CANAF_TypeDef;
+
+typedef struct /* Central Registers */
+{
+ __I uint32_t CANTxSR;
+ __I uint32_t CANRxSR;
+ __I uint32_t CANMSR;
+} LPC_CANCR_TypeDef;
+
+typedef struct /* Controller Registers */
+{
+ __IO uint32_t MOD;
+ __O uint32_t CMR;
+ __IO uint32_t GSR;
+ __I uint32_t ICR;
+ __IO uint32_t IER;
+ __IO uint32_t BTR;
+ __IO uint32_t EWL;
+ __I uint32_t SR;
+ __IO uint32_t RFS;
+ __IO uint32_t RID;
+ __IO uint32_t RDA;
+ __IO uint32_t RDB;
+ __IO uint32_t TFI1;
+ __IO uint32_t TID1;
+ __IO uint32_t TDA1;
+ __IO uint32_t TDB1;
+ __IO uint32_t TFI2;
+ __IO uint32_t TID2;
+ __IO uint32_t TDA2;
+ __IO uint32_t TDB2;
+ __IO uint32_t TFI3;
+ __IO uint32_t TID3;
+ __IO uint32_t TDA3;
+ __IO uint32_t TDB3;
+} LPC_CAN_TypeDef;
+
+/*------------- General Purpose Direct Memory Access (GPDMA) -----------------*/
+typedef struct /* Common Registers */
+{
+ __I uint32_t DMACIntStat;
+ __I uint32_t DMACIntTCStat;
+ __O uint32_t DMACIntTCClear;
+ __I uint32_t DMACIntErrStat;
+ __O uint32_t DMACIntErrClr;
+ __I uint32_t DMACRawIntTCStat;
+ __I uint32_t DMACRawIntErrStat;
+ __I uint32_t DMACEnbldChns;
+ __IO uint32_t DMACSoftBReq;
+ __IO uint32_t DMACSoftSReq;
+ __IO uint32_t DMACSoftLBReq;
+ __IO uint32_t DMACSoftLSReq;
+ __IO uint32_t DMACConfig;
+ __IO uint32_t DMACSync;
+} LPC_GPDMA_TypeDef;
+
+typedef struct /* Channel Registers */
+{
+ __IO uint32_t DMACCSrcAddr;
+ __IO uint32_t DMACCDestAddr;
+ __IO uint32_t DMACCLLI;
+ __IO uint32_t DMACCControl;
+ __IO uint32_t DMACCConfig;
+} LPC_GPDMACH_TypeDef;
+
+/*------------- Universal Serial Bus (USB) -----------------------------------*/
+typedef struct
+{
+ __I uint32_t HcRevision; /* USB Host Registers */
+ __IO uint32_t HcControl;
+ __IO uint32_t HcCommandStatus;
+ __IO uint32_t HcInterruptStatus;
+ __IO uint32_t HcInterruptEnable;
+ __IO uint32_t HcInterruptDisable;
+ __IO uint32_t HcHCCA;
+ __I uint32_t HcPeriodCurrentED;
+ __IO uint32_t HcControlHeadED;
+ __IO uint32_t HcControlCurrentED;
+ __IO uint32_t HcBulkHeadED;
+ __IO uint32_t HcBulkCurrentED;
+ __I uint32_t HcDoneHead;
+ __IO uint32_t HcFmInterval;
+ __I uint32_t HcFmRemaining;
+ __I uint32_t HcFmNumber;
+ __IO uint32_t HcPeriodicStart;
+ __IO uint32_t HcLSTreshold;
+ __IO uint32_t HcRhDescriptorA;
+ __IO uint32_t HcRhDescriptorB;
+ __IO uint32_t HcRhStatus;
+ __IO uint32_t HcRhPortStatus1;
+ __IO uint32_t HcRhPortStatus2;
+ uint32_t RESERVED0[40];
+ __I uint32_t Module_ID;
+
+ __I uint32_t OTGIntSt; /* USB On-The-Go Registers */
+ __IO uint32_t OTGIntEn;
+ __O uint32_t OTGIntSet;
+ __O uint32_t OTGIntClr;
+ __IO uint32_t OTGStCtrl;
+ __IO uint32_t OTGTmr;
+ uint32_t RESERVED1[58];
+
+ __I uint32_t USBDevIntSt; /* USB Device Interrupt Registers */
+ __IO uint32_t USBDevIntEn;
+ __O uint32_t USBDevIntClr;
+ __O uint32_t USBDevIntSet;
+
+ __O uint32_t USBCmdCode; /* USB Device SIE Command Registers */
+ __I uint32_t USBCmdData;
+
+ __I uint32_t USBRxData; /* USB Device Transfer Registers */
+ __O uint32_t USBTxData;
+ __I uint32_t USBRxPLen;
+ __O uint32_t USBTxPLen;
+ __IO uint32_t USBCtrl;
+ __O uint32_t USBDevIntPri;
+
+ __I uint32_t USBEpIntSt; /* USB Device Endpoint Interrupt Regs */
+ __IO uint32_t USBEpIntEn;
+ __O uint32_t USBEpIntClr;
+ __O uint32_t USBEpIntSet;
+ __O uint32_t USBEpIntPri;
+
+ __IO uint32_t USBReEp; /* USB Device Endpoint Realization Reg*/
+ __O uint32_t USBEpInd;
+ __IO uint32_t USBMaxPSize;
+
+ __I uint32_t USBDMARSt; /* USB Device DMA Registers */
+ __O uint32_t USBDMARClr;
+ __O uint32_t USBDMARSet;
+ uint32_t RESERVED2[9];
+ __IO uint32_t USBUDCAH;
+ __I uint32_t USBEpDMASt;
+ __O uint32_t USBEpDMAEn;
+ __O uint32_t USBEpDMADis;
+ __I uint32_t USBDMAIntSt;
+ __IO uint32_t USBDMAIntEn;
+ uint32_t RESERVED3[2];
+ __I uint32_t USBEoTIntSt;
+ __O uint32_t USBEoTIntClr;
+ __O uint32_t USBEoTIntSet;
+ __I uint32_t USBNDDRIntSt;
+ __O uint32_t USBNDDRIntClr;
+ __O uint32_t USBNDDRIntSet;
+ __I uint32_t USBSysErrIntSt;
+ __O uint32_t USBSysErrIntClr;
+ __O uint32_t USBSysErrIntSet;
+ uint32_t RESERVED4[15];
+
+ __I uint32_t I2C_RX; /* USB OTG I2C Registers */
+ __O uint32_t I2C_WO;
+ __I uint32_t I2C_STS;
+ __IO uint32_t I2C_CTL;
+ __IO uint32_t I2C_CLKHI;
+ __O uint32_t I2C_CLKLO;
+ uint32_t RESERVED5[823];
+
+ union {
+ __IO uint32_t USBClkCtrl; /* USB Clock Control Registers */
+ __IO uint32_t OTGClkCtrl;
+ };
+ union {
+ __I uint32_t USBClkSt;
+ __I uint32_t OTGClkSt;
+ };
+} LPC_USB_TypeDef;
+
+/*------------- Ethernet Media Access Controller (EMAC) ----------------------*/
+typedef struct
+{
+ __IO uint32_t MAC1; /* MAC Registers */
+ __IO uint32_t MAC2;
+ __IO uint32_t IPGT;
+ __IO uint32_t IPGR;
+ __IO uint32_t CLRT;
+ __IO uint32_t MAXF;
+ __IO uint32_t SUPP;
+ __IO uint32_t TEST;
+ __IO uint32_t MCFG;
+ __IO uint32_t MCMD;
+ __IO uint32_t MADR;
+ __O uint32_t MWTD;
+ __I uint32_t MRDD;
+ __I uint32_t MIND;
+ uint32_t RESERVED0[2];
+ __IO uint32_t SA0;
+ __IO uint32_t SA1;
+ __IO uint32_t SA2;
+ uint32_t RESERVED1[45];
+ __IO uint32_t Command; /* Control Registers */
+ __I uint32_t Status;
+ __IO uint32_t RxDescriptor;
+ __IO uint32_t RxStatus;
+ __IO uint32_t RxDescriptorNumber;
+ __I uint32_t RxProduceIndex;
+ __IO uint32_t RxConsumeIndex;
+ __IO uint32_t TxDescriptor;
+ __IO uint32_t TxStatus;
+ __IO uint32_t TxDescriptorNumber;
+ __IO uint32_t TxProduceIndex;
+ __I uint32_t TxConsumeIndex;
+ uint32_t RESERVED2[10];
+ __I uint32_t TSV0;
+ __I uint32_t TSV1;
+ __I uint32_t RSV;
+ uint32_t RESERVED3[3];
+ __IO uint32_t FlowControlCounter;
+ __I uint32_t FlowControlStatus;
+ uint32_t RESERVED4[34];
+ __IO uint32_t RxFilterCtrl; /* Rx Filter Registers */
+ __IO uint32_t RxFilterWoLStatus;
+ __IO uint32_t RxFilterWoLClear;
+ uint32_t RESERVED5;
+ __IO uint32_t HashFilterL;
+ __IO uint32_t HashFilterH;
+ uint32_t RESERVED6[882];
+ __I uint32_t IntStatus; /* Module Control Registers */
+ __IO uint32_t IntEnable;
+ __O uint32_t IntClear;
+ __O uint32_t IntSet;
+ uint32_t RESERVED7;
+ __IO uint32_t PowerDown;
+ uint32_t RESERVED8;
+ __IO uint32_t Module_ID;
+} LPC_EMAC_TypeDef;
+
+#pragma no_anon_unions
+
+
+/******************************************************************************/
+/* Peripheral memory map */
+/******************************************************************************/
+/* Base addresses */
+
+/* AHB Peripheral # 0 */
+
+/*
+#define FLASH_BASE (0x00000000UL)
+#define RAM_BASE (0x10000000UL)
+#define GPIO_BASE (0x2009C000UL)
+#define APB0_BASE (0x40000000UL)
+#define APB1_BASE (0x40080000UL)
+#define AHB_BASE (0x50000000UL)
+#define CM3_BASE (0xE0000000UL)
+*/
+
+// TODO - #define VIC_BASE_ADDR 0xFFFFF000
+
+#define LPC_WDT_BASE (0xE0000000)
+#define LPC_TIM0_BASE (0xE0004000)
+#define LPC_TIM1_BASE (0xE0008000)
+#define LPC_UART0_BASE (0xE000C000)
+#define LPC_UART1_BASE (0xE0010000)
+#define LPC_PWM1_BASE (0xE0018000)
+#define LPC_I2C0_BASE (0xE001C000)
+#define LPC_SPI_BASE (0xE0020000)
+#define LPC_RTC_BASE (0xE0024000)
+#define LPC_GPIOINT_BASE (0xE0028080)
+#define LPC_PINCON_BASE (0xE002C000)
+#define LPC_SSP1_BASE (0xE0030000)
+#define LPC_ADC_BASE (0xE0034000)
+#define LPC_CANAF_RAM_BASE (0xE0038000)
+#define LPC_CANAF_BASE (0xE003C000)
+#define LPC_CANCR_BASE (0xE0040000)
+#define LPC_CAN1_BASE (0xE0044000)
+#define LPC_CAN2_BASE (0xE0048000)
+#define LPC_I2C1_BASE (0xE005C000)
+#define LPC_SSP0_BASE (0xE0068000)
+#define LPC_DAC_BASE (0xE006C000)
+#define LPC_TIM2_BASE (0xE0070000)
+#define LPC_TIM3_BASE (0xE0074000)
+#define LPC_UART2_BASE (0xE0078000)
+#define LPC_UART3_BASE (0xE007C000)
+#define LPC_I2C2_BASE (0xE0080000)
+#define LPC_I2S_BASE (0xE0088000)
+#define LPC_MCI_BASE (0xE008C000)
+#define LPC_SC_BASE (0xE01FC000)
+#define LPC_EMAC_BASE (0xFFE00000)
+#define LPC_GPDMA_BASE (0xFFE04000)
+#define LPC_GPDMACH0_BASE (0xFFE04100)
+#define LPC_GPDMACH1_BASE (0xFFE04120)
+#define LPC_USB_BASE (0xFFE0C000)
+#define LPC_VIC_BASE (0xFFFFF000)
+
+/* GPIOs */
+#define LPC_GPIO0_BASE (0x3FFFC000)
+#define LPC_GPIO1_BASE (0x3FFFC020)
+#define LPC_GPIO2_BASE (0x3FFFC040)
+#define LPC_GPIO3_BASE (0x3FFFC060)
+#define LPC_GPIO4_BASE (0x3FFFC080)
+
+
+/******************************************************************************/
+/* Peripheral declaration */
+/******************************************************************************/
+#define LPC_SC (( LPC_SC_TypeDef *) LPC_SC_BASE)
+#define LPC_GPIO0 (( LPC_GPIO_TypeDef *) LPC_GPIO0_BASE)
+#define LPC_GPIO1 (( LPC_GPIO_TypeDef *) LPC_GPIO1_BASE)
+#define LPC_GPIO2 (( LPC_GPIO_TypeDef *) LPC_GPIO2_BASE)
+#define LPC_GPIO3 (( LPC_GPIO_TypeDef *) LPC_GPIO3_BASE)
+#define LPC_GPIO4 (( LPC_GPIO_TypeDef *) LPC_GPIO4_BASE)
+#define LPC_WDT (( LPC_WDT_TypeDef *) LPC_WDT_BASE)
+#define LPC_TIM0 (( LPC_TIM_TypeDef *) LPC_TIM0_BASE)
+#define LPC_TIM1 (( LPC_TIM_TypeDef *) LPC_TIM1_BASE)
+#define LPC_TIM2 (( LPC_TIM_TypeDef *) LPC_TIM2_BASE)
+#define LPC_TIM3 (( LPC_TIM_TypeDef *) LPC_TIM3_BASE)
+#define LPC_UART0 (( LPC_UART_TypeDef *) LPC_UART0_BASE)
+#define LPC_UART1 (( LPC_UART1_TypeDef *) LPC_UART1_BASE)
+#define LPC_UART2 (( LPC_UART_TypeDef *) LPC_UART2_BASE)
+#define LPC_UART3 (( LPC_UART_TypeDef *) LPC_UART3_BASE)
+#define LPC_PWM1 (( LPC_PWM_TypeDef *) LPC_PWM1_BASE)
+#define LPC_I2C0 (( LPC_I2C_TypeDef *) LPC_I2C0_BASE)
+#define LPC_I2C1 (( LPC_I2C_TypeDef *) LPC_I2C1_BASE)
+#define LPC_I2C2 (( LPC_I2C_TypeDef *) LPC_I2C2_BASE)
+#define LPC_I2S (( LPC_I2S_TypeDef *) LPC_I2S_BASE)
+#define LPC_SPI (( LPC_SPI_TypeDef *) LPC_SPI_BASE)
+#define LPC_RTC (( LPC_RTC_TypeDef *) LPC_RTC_BASE)
+#define LPC_GPIOINT (( LPC_GPIOINT_TypeDef *) LPC_GPIOINT_BASE)
+#define LPC_PINCON (( LPC_PINCON_TypeDef *) LPC_PINCON_BASE)
+#define LPC_SSP0 (( LPC_SSP_TypeDef *) LPC_SSP0_BASE)
+#define LPC_SSP1 (( LPC_SSP_TypeDef *) LPC_SSP1_BASE)
+#define LPC_ADC (( LPC_ADC_TypeDef *) LPC_ADC_BASE)
+#define LPC_DAC (( LPC_DAC_TypeDef *) LPC_DAC_BASE)
+#define LPC_CANAF_RAM ((LPC_CANAF_RAM_TypeDef *) LPC_CANAF_RAM_BASE)
+#define LPC_CANAF (( LPC_CANAF_TypeDef *) LPC_CANAF_BASE)
+#define LPC_CANCR (( LPC_CANCR_TypeDef *) LPC_CANCR_BASE)
+#define LPC_CAN1 (( LPC_CAN_TypeDef *) LPC_CAN1_BASE)
+#define LPC_CAN2 (( LPC_CAN_TypeDef *) LPC_CAN2_BASE)
+#define LPC_MCI (( LPC_MCI_TypeDef *) LPC_MCI_BASE)
+#define LPC_EMAC (( LPC_EMAC_TypeDef *) LPC_EMAC_BASE)
+#define LPC_GPDMA (( LPC_GPDMA_TypeDef *) LPC_GPDMA_BASE)
+#define LPC_GPDMACH0 (( LPC_GPDMACH_TypeDef *) LPC_GPDMACH0_BASE)
+#define LPC_GPDMACH1 (( LPC_GPDMACH_TypeDef *) LPC_GPDMACH1_BASE)
+#define LPC_USB (( LPC_USB_TypeDef *) LPC_USB_BASE)
+#define LPC_VIC (( LPC_VIC_TypeDef *) LPC_VIC_BASE)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // __LPC23xx_H
+
Binary file mbed/LPC2368/capi.ar has changed
Binary file mbed/LPC2368/cmsis_nvic.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC2368/core_arm7.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,242 @@
+/* mbed Microcontroller Library
+ * Copyright (C) 2008-2009 ARM Limited. All rights reserved.
+ *
+ * ARM7 version of CMSIS-like functionality - not advised for use outside mbed!
+ * based on core_cm3.h, V1.20
+ */
+
+#ifndef __ARM7_CORE_H__
+#define __ARM7_CORE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */
+#define __CM3_CMSIS_VERSION_SUB (0x20) /*!< [15:0] CMSIS HAL sub version */
+#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
+
+#define __CORTEX_M (0x03) /*!< Cortex core */
+
+/**
+ * Lint configuration \n
+ * ----------------------- \n
+ *
+ * The following Lint messages will be suppressed and not shown: \n
+ * \n
+ * --- Error 10: --- \n
+ * register uint32_t __regBasePri __asm("basepri"); \n
+ * Error 10: Expecting ';' \n
+ * \n
+ * --- Error 530: --- \n
+ * return(__regBasePri); \n
+ * Warning 530: Symbol '__regBasePri' (line 264) not initialized \n
+ * \n
+ * --- Error 550: --- \n
+ * __regBasePri = (basePri & 0x1ff); \n
+ * } \n
+ * Warning 550: Symbol '__regBasePri' (line 271) not accessed \n
+ * \n
+ * --- Error 754: --- \n
+ * uint32_t RESERVED0[24]; \n
+ * Info 754: local structure member '<some, not used in the HAL>' (line 109, file ./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 750: --- \n
+ * #define __CM3_CORE_H__ \n
+ * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 528: --- \n
+ * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n
+ * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced \n
+ * \n
+ * --- Error 751: --- \n
+ * } InterruptType_Type; \n
+ * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced \n
+ * \n
+ * \n
+ * Note: To re-enable a Message, insert a space before 'lint' * \n
+ *
+ */
+
+/*lint -save */
+/*lint -e10 */
+/*lint -e530 */
+/*lint -e550 */
+/*lint -e754 */
+/*lint -e750 */
+/*lint -e528 */
+/*lint -e751 */
+
+#include <stdint.h> /* Include standard types */
+
+/**
+ * @brief Return the Main Stack Pointer (current ARM7 stack)
+ *
+ * @param none
+ * @return uint32_t Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+
+
+#if defined (__ICCARM__)
+ #include <intrinsics.h> /* IAR Intrinsics */
+#endif
+
+
+#ifndef __NVIC_PRIO_BITS
+ #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */
+#endif
+
+typedef struct
+{
+ uint32_t IRQStatus;
+ uint32_t FIQStatus;
+ uint32_t RawIntr;
+ uint32_t IntSelect;
+ uint32_t IntEnable;
+ uint32_t IntEnClr;
+ uint32_t SoftInt;
+ uint32_t SoftIntClr;
+ uint32_t Protection;
+ uint32_t SWPriorityMask;
+ uint32_t RESERVED0[54];
+ uint32_t VectAddr[32];
+ uint32_t RESERVED1[32];
+ uint32_t VectPriority[32];
+ uint32_t RESERVED2[800];
+ uint32_t Address;
+} NVIC_TypeDef;
+
+#define NVIC_BASE (0xFFFFF000)
+#define NVIC (( NVIC_TypeDef *) NVIC_BASE)
+
+
+
+/**
+ * IO definitions
+ *
+ * define access restrictions to peripheral registers
+ */
+
+#ifdef __cplusplus
+#define __I volatile /*!< defines 'read only' permissions */
+#else
+#define __I volatile const /*!< defines 'read only' permissions */
+#endif
+#define __O volatile /*!< defines 'write only' permissions */
+#define __IO volatile /*!< defines 'read / write' permissions */
+
+
+
+
+
+#if defined ( __CC_ARM )
+ #define __ASM __asm /*!< asm keyword for ARM Compiler */
+ #define __INLINE __inline /*!< inline keyword for ARM Compiler */
+
+#elif defined ( __ICCARM__ )
+ #define __ASM __asm /*!< asm keyword for IAR Compiler */
+ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
+
+#elif defined ( __GNUC__ )
+ #define __ASM __asm /*!< asm keyword for GNU Compiler */
+ #define __INLINE inline /*!< inline keyword for GNU Compiler */
+
+#elif defined ( __TASKING__ )
+ #define __ASM __asm /*!< asm keyword for TASKING Compiler */
+ #define __INLINE inline /*!< inline keyword for TASKING Compiler */
+
+#endif
+
+
+/* ################### Compiler specific Intrinsics ########################### */
+
+#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
+/* ARM armcc specific functions */
+
+#define __enable_fault_irq __enable_fiq
+#define __disable_fault_irq __disable_fiq
+
+#define __NOP __nop
+//#define __WFI __wfi
+//#define __WFE __wfe
+//#define __SEV __sev
+//#define __ISB() __isb(0)
+//#define __DSB() __dsb(0)
+//#define __DMB() __dmb(0)
+//#define __REV __rev
+//#define __RBIT __rbit
+#define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
+#define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
+#define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
+#define __STREXB(value, ptr) __strex(value, ptr)
+#define __STREXH(value, ptr) __strex(value, ptr)
+#define __STREXW(value, ptr) __strex(value, ptr)
+
+
+#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
+
+#define __enable_irq __enable_interrupt /*!< global Interrupt enable */
+#define __disable_irq __disable_interrupt /*!< global Interrupt disable */
+#define __NOP __no_operation() /*!< no operation intrinsic in IAR Compiler */
+
+#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
+
+static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }
+static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); }
+
+static __INLINE void __NOP() { __ASM volatile ("nop"); }
+
+#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
+/* TASKING carm specific functions */
+
+/*
+ * The CMSIS functions have been implemented as intrinsics in the compiler.
+ * Please use "carm -?i" to get an up to date list of all instrinsics,
+ * Including the CMSIS ones.
+ */
+
+#endif
+
+
+/**
+ * @brief Enable Interrupt in NVIC Interrupt Controller
+ *
+ * @param IRQn_Type IRQn specifies the interrupt number
+ * @return none
+ *
+ * Enable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
+{
+ NVIC->IntEnable = 1 << (uint32_t)IRQn;
+}
+
+
+/**
+ * @brief Disable the interrupt line for external interrupt specified
+ *
+ * @param IRQn_Type IRQn is the positive number of the external interrupt
+ * @return none
+ *
+ * Disable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
+{
+ NVIC->IntEnClr = 1 << (uint32_t)IRQn;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ARM7_CORE_H__ */
+
+/*lint -restore */
Binary file mbed/LPC2368/core_arm7.o has changed
Binary file mbed/LPC2368/mbed.ar has changed
Binary file mbed/LPC2368/stackheap.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LPC2368/system_LPC23xx.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,44 @@
+/* mbed Microcontroller Library
+ * Copyright (C) 2008-2009 ARM Limited. All rights reserved.
+ *
+ * ARM7 version of CMSIS-like functionality - not advised for use outside mbed!
+ * based on cmsis system_LPC17xx.h
+ */
+
+#ifndef __SYSTEM_LPC23xx_H
+#define __SYSTEM_LPC23xx_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
+
+/**
+ * Initialize the system
+ *
+ * @param none
+ * @return none
+ *
+ * @brief Setup the microcontroller system.
+ * Initialize the System and update the SystemCoreClock variable.
+ */
+extern void SystemInit (void);
+
+/**
+ * Update SystemCoreClock variable
+ *
+ * @param none
+ * @return none
+ *
+ * @brief Updates the SystemCoreClock with current core Clock
+ * retrieved from cpu registers.
+ */
+extern void SystemCoreClockUpdate (void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Binary file mbed/LPC2368/system_LPC23xx.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed/LPC2368/vector_defns.h Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,76 @@ +/* mbed Microcontroller Library - Vectors + * Copyright (c) 2006-2009 ARM Limited. All rights reserved. + * sford, jbrawn + */ + +#ifndef MBED_VECTOR_DEFNS_H +#define MBED_VECTOR_DEFNS_H + +// Assember Macros +#ifdef __ARMCC_VERSION +#define EXPORT(x) EXPORT x +#define WEAK_EXPORT(x) EXPORT x [WEAK] +#define IMPORT(x) IMPORT x +#define LABEL(x) x +#else +#define EXPORT(x) .global x +#define WEAK_EXPORT(x) .weak x +#define IMPORT(x) .global x +#define LABEL(x) x: +#endif + +// RealMonitor +// Requires RAM (0x40000040-0x4000011F) to be allocated by the linker + +// RealMonitor entry points +#define rm_init_entry 0x7fffff91 +#define rm_undef_handler 0x7fffffa0 +#define rm_prefetchabort_handler 0x7fffffb0 +#define rm_dataabort_handler 0x7fffffc0 +#define rm_irqhandler2 0x7fffffe0 +//#define rm_RunningToStopped 0x7ffff808 // ARM - MBED64 +#define rm_RunningToStopped 0x7ffff820 // ARM - PHAT40 + +// Unofficial RealMonitor entry points and variables +#define RM_MSG_SWI 0x00940000 +#define StateP 0x40000040 + +// VIC register addresses +#define VIC_Base 0xfffff000 +#define VICAddress_Offset 0xf00 +#define VICVectAddr2_Offset 0x108 +#define VICVectAddr3_Offset 0x10c +#define VICIntEnClr_Offset 0x014 +#define VICIntEnClr (*(volatile unsigned long *)(VIC_Base + 0x014)) +#define VICVectAddr2 (*(volatile unsigned long *)(VIC_Base + 0x108)) +#define VICVectAddr3 (*(volatile unsigned long *)(VIC_Base + 0x10C)) + +// ARM Mode bits and Interrupt flags in PSRs +#define Mode_USR 0x10 +#define Mode_FIQ 0x11 +#define Mode_IRQ 0x12 +#define Mode_SVC 0x13 +#define Mode_ABT 0x17 +#define Mode_UND 0x1B +#define Mode_SYS 0x1F +#define I_Bit 0x80 // when I bit is set, IRQ is disabled +#define F_Bit 0x40 // when F bit is set, FIQ is disabled + +// MCU RAM +#define LPC2368_RAM_ADDRESS 0x40000000 // RAM Base +#define LPC2368_RAM_SIZE 0x8000 // 32KB + +// ISR Stack Allocation +#define UND_stack_size 0x00000040 +#define SVC_stack_size 0x00000040 +#define ABT_stack_size 0x00000040 +#define FIQ_stack_size 0x00000000 +#define IRQ_stack_size 0x00000040 + +#define ISR_stack_size (UND_stack_size + SVC_stack_size + ABT_stack_size + FIQ_stack_size + IRQ_stack_size) + +// Full Descending Stack, so top-most stack points to just above the top of RAM +#define LPC2368_STACK_TOP (LPC2368_RAM_ADDRESS + LPC2368_RAM_SIZE) +#define USR_STACK_TOP (LPC2368_STACK_TOP - ISR_stack_size) + +#endif
Binary file mbed/LPC2368/vector_functions.o has changed
Binary file mbed/LPC2368/vector_realmonitor.o has changed
Binary file mbed/LPC2368/vector_table.o has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/LocalFileSystem.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,61 @@
+/* mbed Microcontroller Library - LocalFileSystem
+ * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
+ * 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PeripheralNames.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,90 @@
+/* mbed Microcontroller Library - PeripheralNames
+ * Copyright (C) 2008-2009 ARM Limited. All rights reserved.
+ *
+ * Provides the mappings for peripherals
+ * Implementation specific to the LPC1768/LPC2368
+ * sford
+ */
+
+#ifndef MBED_PERIPHERALNAMES_H
+#define MBED_PERIPHERALNAMES_H
+
+#include "cmsis.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum UARTName UARTName;
+enum UARTName {
+ UART_0 = (int)LPC_UART0_BASE
+ , UART_1 = (int)LPC_UART1_BASE
+ , UART_2 = (int)LPC_UART2_BASE
+ , UART_3 = (int)LPC_UART3_BASE
+};
+
+typedef enum ADCName ADCName;
+enum ADCName {
+ ADC0_0 = 0
+ , ADC0_1
+ , ADC0_2
+ , ADC0_3
+ , ADC0_4
+ , ADC0_5
+ , ADC0_6
+ , ADC0_7
+};
+
+typedef enum DACName DACName;
+enum DACName {
+ DAC_0 = 0
+};
+
+typedef enum SPIName SPIName;
+enum SPIName {
+ SPI_0 = (int)LPC_SSP0_BASE
+ , SPI_1 = (int)LPC_SSP1_BASE
+};
+
+typedef enum I2CName I2CName;
+enum I2CName {
+ I2C_0 = (int)LPC_I2C0_BASE
+ , I2C_1 = (int)LPC_I2C1_BASE
+ , I2C_2 = (int)LPC_I2C2_BASE
+};
+
+typedef enum PWMName PWMName;
+enum PWMName {
+ PWM_1 = 1
+ , PWM_2
+ , PWM_3
+ , PWM_4
+ , PWM_5
+ , PWM_6
+};
+
+typedef enum TimerName TimerName;
+enum TimerName {
+ TIMER_0 = (int)LPC_TIM0_BASE
+ , TIMER_1 = (int)LPC_TIM1_BASE
+ , TIMER_2 = (int)LPC_TIM2_BASE
+ , TIMER_3 = (int)LPC_TIM3_BASE
+};
+
+typedef enum CANName CANName;
+enum CANName {
+ CAN_1 = (int)LPC_CAN1_BASE,
+ CAN_2 = (int)LPC_CAN2_BASE
+};
+
+#define STDIO_UART_TX USBTX
+#define STDIO_UART_RX USBRX
+#define STDIO_UART UART_0
+#define US_TICKER_TIMER TIMER_3
+#define US_TICKER_TIMER_IRQn TIMER3_IRQn
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PinNames.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,96 @@
+/* mbed Microcontroller Library - PinNames
+ * Copyright (C) 2008-2009 ARM Limited. All rights reserved.
+ *
+ * Provides the mapping of mbed DIP and LPC Pin Names
+ * This is an LPC1768/LPC2368 specific implementation
+ * sford
+ */
+
+#ifndef MBED_PINNAMES_H
+#define MBED_PINNAMES_H
+
+#include "cmsis.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum PinName PinName;
+enum PinName {
+
+ // LPC Pin Names
+ P0_0 = LPC_GPIO0_BASE, P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7
+ , P0_8, P0_9, P0_10, P0_11, P0_12, P0_13, P0_14, P0_15
+ , P0_16, P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23
+ , P0_24, P0_25, P0_26, P0_27, P0_28, P0_29, P0_30, P0_31
+ , P1_0, P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7
+ , P1_8, P1_9, P1_10, P1_11, P1_12, P1_13, P1_14, P1_15
+ , P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23
+ , P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31
+ , P2_0, P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7
+ , P2_8, P2_9, P2_10, P2_11, P2_12, P2_13, P2_14, P2_15
+ , P2_16, P2_17, P2_18, P2_19, P2_20, P2_21, P2_22, P2_23
+ , P2_24, P2_25, P2_26, P2_27, P2_28, P2_29, P2_30, P2_31
+ , P3_0, P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7
+ , P3_8, P3_9, P3_10, P3_11, P3_12, P3_13, P3_14, P3_15
+ , P3_16, P3_17, P3_18, P3_19, P3_20, P3_21, P3_22, P3_23
+ , P3_24, P3_25, P3_26, P3_27, P3_28, P3_29, P3_30, P3_31
+ , P4_0, P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7
+ , P4_8, P4_9, P4_10, P4_11, P4_12, P4_13, P4_14, P4_15
+ , P4_16, P4_17, P4_18, P4_19, P4_20, P4_21, P4_22, P4_23
+ , P4_24, P4_25, P4_26, P4_27, P4_28, P4_29, P4_30, P4_31
+
+ // mbed DIP Pin Names
+ , p5 = P0_9
+ , p6 = P0_8
+ , p7 = P0_7
+ , p8 = P0_6
+ , p9 = P0_0
+ , p10 = P0_1
+ , p11 = P0_18
+ , p12 = P0_17
+ , p13 = P0_15
+ , p14 = P0_16
+ , p15 = P0_23
+ , p16 = P0_24
+ , p17 = P0_25
+ , p18 = P0_26
+ , p19 = P1_30
+ , p20 = P1_31
+ , p21 = P2_5
+ , p22 = P2_4
+ , p23 = P2_3
+ , p24 = P2_2
+ , p25 = P2_1
+ , p26 = P2_0
+ , p27 = P0_11
+ , p28 = P0_10
+ , p29 = P0_5
+ , p30 = P0_4
+
+ // Other mbed Pin Names
+ , LED1 = P1_18
+ , LED2 = P1_20
+ , LED3 = P1_21
+ , LED4 = P1_23
+ , USBTX = P0_2
+ , USBRX = P0_3
+
+ // Not connected
+ , NC = (int)0xFFFFFFFF
+
+};
+
+typedef enum PinMode PinMode;
+enum PinMode {
+ PullUp = 0
+ , PullDown = 3
+ , PullNone = 2
+ , OpenDrain = 4
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PortIn.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,80 @@
+/* mbed Microcontroller Library - PortInOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ */
+
+#ifndef MBED_PORTIN_H
+#define MBED_PORTIN_H
+
+#include "PortNames.h"
+#include "PinNames.h"
+
+namespace mbed {
+
+/* Class: PortIn
+ * A multiple pin digital input
+ *
+ * Example:
+ * > // Switch on an LED if any of mbed pins 21-26 is high
+ * >
+ * > #include "mbed.h"
+ * >
+ * > PortIn p(Port2, 0x0000003F); // p21-p26
+ * > DigitalOut ind(LED4);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > int pins = p.read();
+ * > if(pins) {
+ * > ind = 1;
+ * > } else {
+ * > ind = 0;
+ * > }
+ * > }
+ * > }
+ */
+class PortIn {
+public:
+
+ /* Constructor: PortIn
+ * Create an PortIn, connected to the specified port
+ *
+ * Variables:
+ * port - Port to connect to (Port0-Port5)
+ * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
+ */
+ PortIn(PortName port, int mask = 0xFFFFFFFF);
+
+ /* Function: read
+ * Read the value currently output on the port
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to associated port pin setting
+ */
+ int read() {
+ return _gpio->FIOPIN & _mask;
+ }
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone, OpenDrain
+ */
+ void mode(PinMode mode);
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int() {
+ return read();
+ }
+
+private:
+ LPC_GPIO_TypeDef *_gpio;
+ PortName _port;
+ uint32_t _mask;
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PortInOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,95 @@
+/* mbed Microcontroller Library - PortInOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ */
+
+#ifndef MBED_PORTINOUT_H
+#define MBED_PORTINOUT_H
+
+#include "PortNames.h"
+#include "PinNames.h"
+
+namespace mbed {
+
+/* Class: PortInOut
+ * A multiple pin digital in/out used to set/read multiple bi-directional pins
+ */
+class PortInOut {
+public:
+
+ /* Constructor: PortInOut
+ * Create an PortInOut, connected to the specified port
+ *
+ * Variables:
+ * port - Port to connect to (Port0-Port5)
+ * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
+ */
+ PortInOut(PortName port, int mask = 0xFFFFFFFF);
+
+ /* Function: write
+ * Write the value to the output port
+ *
+ * Variables:
+ * value - An integer specifying a bit to write for every corresponding port pin
+ */
+ void write(int value) {
+ _gpio->FIOSET = value & _mask;
+ _gpio->FIOCLR = ~(value) & _mask;
+ }
+
+ /* Function: read
+ * Read the value currently output on the port
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to associated port pin setting
+ */
+ int read() {
+ return _gpio->FIOPIN & _mask;
+ }
+
+ /* Function: output
+ * Set as an output
+ */
+ void output();
+
+ /* Function: input
+ * Set as an input
+ */
+ void input();
+
+ /* Function: mode
+ * Set the input pin mode
+ *
+ * Variables:
+ * mode - PullUp, PullDown, PullNone, OpenDrain
+ */
+ void mode(PinMode mode);
+
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ PortInOut& operator= (int value) {
+ write(value);
+ return *this;
+ }
+
+ PortInOut& operator= (PortInOut& rhs) {
+ write(rhs.read());
+ return *this;
+ }
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int() {
+ return read();
+ }
+
+private:
+ LPC_GPIO_TypeDef *_gpio;
+ PortName _port;
+ uint32_t _mask;
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PortNames.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,26 @@
+/* mbed Microcontroller Library - PortName
+ * Copyright (c) 2010 ARM Limited. All rights reserved.
+ * jward
+ */
+
+#ifndef MBED_PORTNAMES_H
+#define MBED_PORTNAMES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum PortName PortName;
+enum PortName {
+ Port0 = 0
+ , Port1 = 1
+ , Port2 = 2
+ , Port3 = 3
+ , Port4 = 4
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PortOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,98 @@
+/* mbed Microcontroller Library - PortOut
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ */
+
+#ifndef MBED_PORTOUT_H
+#define MBED_PORTOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "Base.h"
+
+#include "PortNames.h"
+
+namespace mbed {
+/* Class: PortOut
+ * A multiple pin digital out
+ *
+ * Example:
+ * > // Toggle all four LEDs
+ * >
+ * > #include "mbed.h"
+ * >
+ * > // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
+ * > #define LED_MASK 0x00B40000
+ * >
+ * > PortOut ledport(Port1, LED_MASK);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > ledport = LED_MASK;
+ * > wait(1);
+ * > ledport = 0;
+ * > wait(1);
+ * > }
+ * > }
+ */
+class PortOut {
+public:
+
+ /* Constructor: PortOut
+ * Create an PortOut, connected to the specified port
+ *
+ * Variables:
+ * port - Port to connect to (Port0-Port5)
+ * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
+ */
+ PortOut(PortName port, int mask = 0xFFFFFFFF);
+
+ /* Function: write
+ * Write the value to the output port
+ *
+ * Variables:
+ * value - An integer specifying a bit to write for every corresponding PortOut pin
+ */
+ void write(int value) {
+ _gpio->FIOSET = value & _mask;
+ _gpio->FIOCLR = ~(value) & _mask;
+ }
+
+ /* Function: read
+ * Read the value currently output on the port
+ *
+ * Variables:
+ * returns - An integer with each bit corresponding to associated PortOut pin setting
+ */
+ int read() {
+ return _gpio->FIOPIN & _mask;
+ }
+
+ /* Function: operator=
+ * A shorthand for <write>
+ */
+ PortOut& operator= (int value) {
+ write(value);
+ return *this;
+ }
+
+ PortOut& operator= (PortOut& rhs) {
+ write(rhs.read());
+ return *this;
+ }
+
+ /* Function: operator int()
+ * A shorthand for <read>
+ */
+ operator int() {
+ return read();
+ }
+
+private:
+ LPC_GPIO_TypeDef *_gpio;
+ PortName _port;
+ uint32_t _mask;
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/PwmOut.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,143 @@
+/* mbed Microcontroller Library - PwmOut
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_PWMOUT_H
+#define MBED_PWMOUT_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: PwmOut
+ * A pulse-width modulation digital output
+ *
+ * Example
+ * > // Fade a led on.
+ * > #include "mbed.h"
+ * >
+ * > PwmOut led(LED1);
+ * >
+ * > int main() {
+ * > while(1) {
+ * > led = led + 0.01;
+ * > wait(0.2);
+ * > if(led == 1.0) {
+ * > led = 0;
+ * > }
+ * > }
+ * > }
+ *
+ * Note that on the LPC1768 and LPC2368, the PWMs all share the same
+ * period - if you change the period for one, you change it for all.
+ * Although routines that change the period maintain the duty cycle
+ * for its PWM, all other PWMs will require their duty cycle to be
+ * refreshed.
+ */
+class PwmOut : public Base {
+
+public:
+
+ /* Constructor: PwmOut
+ * Create a PwmOut connected to the specified pin
+ *
+ * Variables:
+ * pin - PwmOut pin to connect to
+ */
+ PwmOut(PinName pin, const char *name = NULL);
+
+ /* Function: write
+ * Set the ouput duty-cycle, specified as a percentage (float)
+ *
+ * Variables:
+ * value - A floating-point value representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ * Values outside this range will be saturated to 0.0f or 1.0f.
+ */
+ void write(float value);
+
+ /* Function: read
+ * Return the current output duty-cycle setting, measured as a percentage (float)
+ *
+ * Variables:
+ * returns - A floating-point value representing the current duty-cycle being output on the pin,
+ * measured as a percentage. The returned value will lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ *
+ * Note:
+ * This value may not match exactly the value set by a previous <write>.
+ */
+ float read();
+
+ /* Function: period
+ * Set the PWM period, specified in seconds (float), keeping the
+ * duty cycle the same.
+ *
+ * Note:
+ * The resolution is currently in microseconds; periods smaller than this
+ * will be set to zero.
+ */
+ void period(float seconds);
+
+ /* Function: period_ms
+ * Set the PWM period, specified in milli-seconds (int), keeping the
+ * duty cycle the same.
+ */
+ void period_ms(int ms);
+
+ /* Function: period_us
+ * Set the PWM period, specified in micro-seconds (int), keeping the
+ * duty cycle the same.
+ */
+ void period_us(int us);
+
+ /* Function: pulsewidth
+ * Set the PWM pulsewidth, specified in seconds (float), keeping the
+ * period the same.
+ */
+ void pulsewidth(float seconds);
+
+ /* Function: pulsewidth_ms
+ * Set the PWM pulsewidth, specified in milli-seconds (int), keeping
+ * the period the same.
+ */
+ void pulsewidth_ms(int ms);
+
+ /* Function: pulsewidth_us
+ * Set the PWM pulsewidth, specified in micro-seconds (int), keeping
+ * the period the same.
+ */
+ void pulsewidth_us(int us);
+
+#ifdef MBED_OPERATORS
+ /* Function: operator=
+ * A operator shorthand for <write()>
+ */
+ PwmOut& operator= (float value);
+ PwmOut& operator= (PwmOut& rhs);
+
+ /* Function: operator float()
+ * An operator shorthand for <read()>
+ */
+ operator float();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ PWMName _pwm;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/SPI.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,108 @@
+/* mbed Microcontroller Library - SPI
+ * Copyright (c) 2010 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_SPI_H
+#define MBED_SPI_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: SPI
+ * A SPI Master, used for communicating with SPI slave devices
+ *
+ * The default format is set to 8-bits, mode 0, and a clock frequency of 1MHz
+ *
+ * Most SPI devices will also require Chip Select and Reset signals. These
+ * can be controlled using <DigitalOut> pins
+ *
+ * Example:
+ * > // Send a byte to a SPI slave, and record the response
+ * >
+ * > #include "mbed.h"
+ * >
+ * > SPI device(p5, p6, p7); // mosi, miso, sclk
+ * >
+ * > int main() {
+ * > int response = device.write(0xFF);
+ * > }
+ */
+class SPI : public Base {
+
+public:
+
+ /* Constructor: SPI
+ * Create a SPI master connected to the specified pins
+ *
+ * Variables:
+ * mosi - SPI Master Out, Slave In pin
+ * miso - SPI Master In, Slave Out pin
+ * sclk - SPI Clock pin
+ * name - (optional) A string to identify the object
+ *
+ * Pin Options:
+ * (5, 6, 7) or (11, 12, 13)
+ *
+ * mosi or miso can be specfied as NC if not used
+ */
+ SPI(PinName mosi, PinName miso, PinName sclk, const char *name = NULL);
+
+ /* Function: format
+ * Configure the data transmission format
+ *
+ * Variables:
+ * bits - Number of bits per SPI frame (4 - 16)
+ * mode - Clock polarity and phase mode (0 - 3)
+ *
+ * > mode | POL PHA
+ * > -----+--------
+ * > 0 | 0 0
+ * > 1 | 0 1
+ * > 2 | 1 0
+ * > 3 | 1 1
+ */
+ void format(int bits, int mode = 0);
+
+ /* Function: frequency
+ * Set the spi bus clock frequency
+ *
+ * Variables:
+ * hz - SCLK frequency in hz (default = 1MHz)
+ */
+ void frequency(int hz = 1000000);
+
+ /* Function: write
+ * Write to the SPI Slave and return the response
+ *
+ * Variables:
+ * value - Data to be sent to the SPI slave
+ * returns - Response from the SPI slave
+ */
+ virtual int write(int value);
+
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ SPIName _spi;
+
+ void aquire(void);
+ static SPI *_owner;
+ int _bits;
+ int _mode;
+ int _hz;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/SPIHalfDuplex.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,113 @@
+/* mbed Microcontroller Library - SPI
+ * Copyright (c) 2010 ARM Limited. All rights reserved.
+ * jward
+ */
+
+#ifndef MBED_SPIHALFDUPLEX_H
+#define MBED_SPIHALFDUPLEX_H
+
+#include "SPI.h"
+
+namespace mbed {
+
+/* Class: SPIHalfDuplex
+ * A SPI half-duplex master, used for communicating with SPI slave devices
+ * over a shared data line.
+ *
+ * The default format is set to 8-bits for both master and slave, and a
+ * clock frequency of 1MHz
+ *
+ * Most SPI devies will also require Chip Select and Reset signals. These
+ * can be controlled using <DigitalOut> pins.
+ *
+ * Although this is for a shared data line, both MISO and MOSI are defined,
+ * and should be tied together externally to the mbed. This class handles
+ * the tri-stating of the MOSI pin.
+ *
+ * Example:
+ * > // Send a byte to a SPI half-duplex slave, and record the response
+ * >
+ * > #include "mbed.h"
+ * >
+ * > SPIHalfDuplex device(p5, p6, p7) // mosi, miso, sclk
+ * >
+ * > int main() {
+ * > int respone = device.write(0xAA);
+ * > }
+ */
+
+class SPIHalfDuplex : public SPI {
+
+public:
+
+ /* Constructor: SPIHalfDuplex
+ * Create a SPI half-duplex master connected to the specified pins
+ *
+ * Variables:
+ * mosi - SPI Master Out, Slave In pin
+ * miso - SPI Master In, Slave Out pin
+ * sclk - SPI Clock pin
+ * name - (optional) A string to identify the object
+ *
+ * Pin Options:
+ * (5, 6, 7) or (11, 12, 13)
+ *
+ * mosi or miso can be specfied as NC if not used
+ */
+ SPIHalfDuplex(PinName mosi, PinName miso, PinName sclk,
+ const char *name = NULL);
+
+#if 0 // Inherited from SPI - documentation only
+ /* Function: format
+ * Configure the data transmission format
+ *
+ * Variables:
+ * bits - Number of bits per SPI frame (4 - 16)
+ * mode - Clock polarity and phase mode (0 - 3)
+ *
+ * > mode | POL PHA
+ * > -----+--------
+ * > 0 | 0 0
+ * > 1 | 0 1
+ * > 2 | 1 0
+ * > 3 | 1 1
+ */
+ void format(int bits, int mode = 0);
+
+ /* Function: frequency
+ * Set the spi bus clock frequency
+ *
+ * Variables:
+ * hz - SCLK frequency in hz (default = 1MHz)
+ */
+ void frequency(int hz = 1000000);
+#endif
+
+ /* Function: write
+ * Write to the SPI Slave and return the response
+ *
+ * Variables:
+ * value - Data to be sent to the SPI slave
+ * returns - Response from the SPI slave
+ */
+ virtual int write(int value);
+
+ /* Function: slave_format
+ * Set the number of databits expected from the slave, from 4-16
+ *
+ * Variables:
+ * sbits - Number of expected bits in the slave response
+ */
+ void slave_format(int sbits);
+
+protected:
+
+ PinName _mosi;
+ PinName _miso;
+ int _sbits;
+
+}; // End of class
+
+} // End of namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/SPISlave.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,122 @@
+/* mbed Microcontroller Library - SPI
+ * Copyright (c) 2010 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_SPISLAVE_H
+#define MBED_SPISLAVE_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: SPISlave
+ * A SPI slave, used for communicating with a SPI Master device
+ *
+ * The default format is set to 8-bits, mode 0, and a clock frequency of 1MHz
+ *
+ * Example:
+ * > // Reply to a SPI master as slave
+ * >
+ * > #include "mbed.h"
+ * >
+ * > SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel
+ * >
+ * > int main() {
+ * > device.reply(0x00); // Prime SPI with first reply
+ * > while(1) {
+ * > if(device.receive()) {
+ * > int v = device.read(); // Read byte from master
+ * > v = (v + 1) % 0x100; // Add one to it, modulo 256
+ * > device.reply(v); // Make this the next reply
+ * > }
+ * > }
+ * > }
+ */
+class SPISlave : public Base {
+
+public:
+
+ /* Constructor: SPI
+ * Create a SPI slave connected to the specified pins
+ *
+ * Variables:
+ * mosi - SPI Master Out, Slave In pin
+ * miso - SPI Master In, Slave Out pin
+ * sclk - SPI Clock pin
+ * ssel - SPI chip select pin
+ * name - (optional) A string to identify the object
+ *
+ * Pin Options:
+ * (5, 6, 7i, 8) or (11, 12, 13, 14)
+ *
+ * mosi or miso can be specfied as NC if not used
+ */
+ SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel,
+ const char *name = NULL);
+
+ /* Function: format
+ * Configure the data transmission format
+ *
+ * Variables:
+ * bits - Number of bits per SPI frame (4 - 16)
+ * mode - Clock polarity and phase mode (0 - 3)
+ *
+ * > mode | POL PHA
+ * > -----+--------
+ * > 0 | 0 0
+ * > 1 | 0 1
+ * > 2 | 1 0
+ * > 3 | 1 1
+ */
+ void format(int bits, int mode = 0);
+
+ /* Function: frequency
+ * Set the spi bus clock frequency
+ *
+ * Variables:
+ * hz - SCLK frequency in hz (default = 1MHz)
+ */
+ void frequency(int hz = 1000000);
+
+ /* Function: receive
+ * Polls the SPI to see if data has been received
+ *
+ * Variables:
+ * returns - zero if no data, 1 otherwise
+ */
+ int receive(void);
+
+ /* Function: read
+ * Retrieve data from receive buffer as slave
+ *
+ * Variables:
+ * returns - the data in the receive buffer
+ */
+ int read(void);
+
+ /* Function: reply
+ * Fill the transmission buffer with the value to be written out
+ * as slave on the next received message from the master.
+ *
+ * Variables:
+ * value - the data to be transmitted next
+ */
+ void reply(int value);
+
+protected:
+
+ SPIName _spi;
+
+ int _bits;
+ int _mode;
+ int _hz;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Serial.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,178 @@
+/* mbed Microcontroller Library - Serial
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_SERIAL_H
+#define MBED_SERIAL_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Stream.h"
+#include "FunctionPointer.h"
+
+namespace mbed {
+
+/* Class: Serial
+ * A serial port (UART) for communication with other serial devices
+ *
+ * Example:
+ * > // Print "Hello World" to the PC
+ * >
+ * > #include "mbed.h"
+ * >
+ * > Serial pc(USBTX, USBRX);
+ * >
+ * > int main() {
+ * > pc.printf("Hello World\n");
+ * > }
+ */
+class Serial : public Stream {
+
+public:
+
+ /* Constructor: Serial
+ * Create a Serial port, connected to the specified transmit and receive pins
+ *
+ * Variables:
+ * tx - Transmit pin
+ * rx - Receive pin
+ *
+ * Note: Either tx or rx may be specified as NC if unused
+ */
+ Serial(PinName tx, PinName rx, const char *name = NULL);
+
+ /* Function: baud
+ * Set the baud rate of the serial port
+ *
+ * Variables:
+ * baudrate - The baudrate of the serial port (default = 9600).
+ */
+ void baud(int baudrate);
+
+ enum Parity {
+ None = 0
+ , Odd
+ , Even
+ , Forced1
+ , Forced0
+ };
+
+ enum IrqType {
+ RxIrq = 0
+ , TxIrq
+ };
+
+ /* Function: format
+ * Set the transmission format used by the Serial port
+ *
+ * Variables:
+ * bits - The number of bits in a word (5-8; default = 8)
+ * parity - The parity used (Serial::None, Serial::Odd, Serial::Even, Serial::Forced1, Serial::Forced0; default = Serial::None)
+ * stop - The number of stop bits (1 or 2; default = 1)
+ */
+ void format(int bits = 8, Parity parity = Serial::None, int stop_bits = 1);
+
+#if 0 // Inhereted from Stream, for documentation only
+
+ /* Function: putc
+ * Write a character
+ *
+ * Variables:
+ * c - The character to write to the serial port
+ */
+ int putc(int c);
+
+ /* Function: getc
+ * Read a character
+ *
+ * Variables:
+ * returns - The character read from the serial port
+ */
+ int getc();
+
+ /* Function: printf
+ * Write a formated string
+ *
+ * Variables:
+ * format - A printf-style format string, followed by the
+ * variables to use in formating the string.
+ */
+ int printf(const char* format, ...);
+
+ /* Function: scanf
+ * Read a formated string
+ *
+ * Variables:
+ * format - A scanf-style format string,
+ * followed by the pointers to variables to store the results.
+ */
+ int scanf(const char* format, ...);
+
+#endif
+
+ /* Function: readable
+ * Determine if there is a character available to read
+ *
+ * Variables:
+ * returns - 1 if there is a character available to read, else 0
+ */
+ int readable();
+
+ /* Function: writeable
+ * Determine if there is space available to write a character
+ *
+ * Variables:
+ * returns - 1 if there is space to write a character, else 0
+ */
+ int writeable();
+
+ /* Function: attach
+ * Attach a function to call whenever a serial interrupt is generated
+ *
+ * Variables:
+ * fptr - A pointer to a void function, or 0 to set as none
+ * type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
+ */
+ void attach(void (*fptr)(void), IrqType type = RxIrq);
+
+ /* Function: attach
+ * Attach a member function to call whenever a serial interrupt is generated
+ *
+ * Variables:
+ * tptr - pointer to the object to call the member function on
+ * mptr - pointer to the member function to be called
+ * type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
+ */
+ template<typename T>
+ void attach(T* tptr, void (T::*mptr)(void), IrqType type = RxIrq) {
+ if((mptr != NULL) && (tptr != NULL)) {
+ _irq[type].attach(tptr, mptr);
+ setup_interrupt(type);
+ }
+ }
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ void setup_interrupt(IrqType type);
+ void remove_interrupt(IrqType type);
+
+ virtual int _getc();
+ virtual int _putc(int c);
+
+ UARTName _uart;
+ FunctionPointer _irq[2];
+ int _uidx;
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/SerialHalfDuplex.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,161 @@
+/* mbed Microcontroller Library - SerialHalfDuplex
+ * Copyright (c) 2010 ARM Limited. All rights reserved.
+ * jward
+ */
+
+#ifndef MBED_SERIALHALFDUPLEX_H
+#define MBED_SERIALHALFDUPLEX_H
+
+#include "Serial.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+
+namespace mbed {
+
+/* Class: SerialHalfDuplex
+ * A serial port (UART) for communication with other devices, with a single
+ * shared transmit and receive line.
+ *
+ * If the device both transmits and receives, then both (separate) pins need
+ * to be defined, and tied together externally.
+ *
+ * Example:
+ * > // Send a byte as a master, and receive a byte as a slave
+ * >
+ * > #include "mbed.h"
+ * >
+ * > SerialHalfDuplex master(p9, p10);
+ * >
+ * > int main() {
+ * > int outbyte = master.putc(0x55);
+ * > int retbyte = master.getc();
+ * > printf("Wrote: %02X Read: %02X\n", outbyte, retbyte);
+ * > }
+ */
+class SerialHalfDuplex : public Serial {
+
+public:
+ /* Constructor: SerialHalfDuplex
+ * Create a half-duplex serial port, connected to the specified transmit
+ * and receive pins.
+ *
+ * Variables:
+ * tx - Transmit pin
+ * rx - Receive pin
+ *
+ * Note: Either tx or rx may be specified as NC if unused
+ */
+
+ SerialHalfDuplex(PinName tx, PinName rx, const char *name = NULL);
+
+#if 0 // Inherited from Serial class, for documentation
+ /* Function: baud
+ * Set the baud rate of the serial port
+ *
+ * Variables:
+ * baudrate - The baudrate of the serial port (default = 9600).
+ */
+ void baud(int baudrate);
+
+ enum Parity {
+ None = 0
+ , Odd
+ , Even
+ , Forced1
+ , Forced0
+ };
+
+ /* Function: format
+ * Set the transmission format used by the Serial port
+ *
+ * Variables:
+ * bits - The number of bits in a word (5-8; default = 8)
+ * parity - The parity used (Serial::None, Serial::Odd,
+Serial::Even, Serial::Forced1, Serial::Forced0; default = Serial::None)
+ * stop - The number of stop bits (1 or 2; default = 1)
+ */
+ void format(int bits = 8, Parity parity = Serial::None, int stop_bits
+= 1);
+
+ /* Function: putc
+ * Write a character
+ *
+ * Variables:
+ * c - The character to write to the serial port
+ */
+ int putc(int c);
+
+ /* Function: getc
+ * Read a character
+ *
+ * Variables:
+ * returns - The character read from the serial port
+ */
+ int getc();
+
+ /* Function: printf
+ * Write a formated string
+ *
+ * Variables:
+ * format - A printf-style format string, followed by the
+ * variables to use in formating the string.
+ */
+ int printf(const char* format, ...);
+
+ /* Function: scanf
+ * Read a formated string
+ *
+ * Variables:
+ * format - A scanf-style format string,
+ * followed by the pointers to variables to store the results.
+ */
+ int scanf(const char* format, ...);
+
+ /* Function: readable
+ * Determine if there is a character available to read
+ *
+ * Variables:
+ * returns - 1 if there is a character available to read, else 0
+ */
+ int readable();
+
+ /* Function: writeable
+ * Determine if there is space available to write a character
+ *
+ * Variables:
+ * returns - 1 if there is space to write a character, else 0
+ */
+ int writeable();
+
+ /* Function: attach
+ * Attach a function to call whenever a serial interrupt is generated
+ *
+ * Variables:
+ * fptr - A pointer to a void function, or 0 to set as none
+ */
+ void attach(void (*fptr)(void));
+
+ /* Function: attach
+ * Attach a member function to call whenever a serial interrupt is generated
+ *
+ * Variables:
+ * tptr - pointer to the object to call the member function on
+ * mptr - pointer to the member function to be called
+ */
+ template<typename T>
+ void attach(T* tptr, void (T::*mptr)(void));
+
+#endif
+
+protected:
+ PinName _txpin;
+ int _pinfunc;
+
+ virtual int _putc(int c);
+ virtual int _getc(void);
+
+}; // End class SerialHalfDuplex
+
+} // End namespace
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Stream.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,67 @@
+/* mbed Microcontroller Library - Stream
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_STREAM_H
+#define MBED_STREAM_H
+
+#include "FileLike.h"
+#include "platform.h"
+#include <cstdio>
+
+namespace mbed {
+
+class Stream : public FileLike {
+
+public:
+
+ Stream(const char *name = NULL);
+ virtual ~Stream();
+
+ 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, ...);
+
+ operator std::FILE*() { return _file; }
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+#endif
+
+protected:
+
+ 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();
+ virtual off_t flen();
+
+ virtual int _putc(int c) = 0;
+ virtual int _getc() = 0;
+
+ std::FILE *_file;
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Ticker.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,118 @@
+/* mbed Microcontroller Library - Ticker
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * 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.
+ *
+ * Example:
+ * > // Toggle the blinking led after 5 seconds
+ * >
+ * > #include "mbed.h"
+ * >
+ * > Ticker timer;
+ * > DigitalOut led1(LED1);
+ * > DigitalOut led2(LED2);
+ * >
+ * > int flip = 0;
+ * >
+ * > void attime() {
+ * > flip = !flip;
+ * > }
+ * >
+ * > int main() {
+ * > timer.attach(&attime, 5);
+ * > while(1) {
+ * > if(flip == 0) {
+ * > led1 = !led1;
+ * > } else {
+ * > led2 = !led2;
+ * > }
+ * > wait(0.2);
+ * > }
+ * > }
+ *
+ */
+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;
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Timeout.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,109 @@
+/* mbed Microcontroller Library - Timeout
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * 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.
+ *
+ * Example:
+ * > // Blink until timeout.
+ * >
+ * > #include "mbed.h"
+ * >
+ * > Timeout timeout;
+ * > DigitalOut led(LED1);
+ * >
+ * > int on = 1;
+ * >
+ * > void attimeout() {
+ * > on = 0;
+ * > }
+ * >
+ * > int main() {
+ * > timeout.attach(&attimeout, 5);
+ * > while(on) {
+ * > led = !led;
+ * > wait(0.2);
+ * > }
+ * > }
+ */
+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();
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/Timer.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,95 @@
+/* mbed Microcontroller Library - Timer
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_TIMER_H
+#define MBED_TIMER_H
+
+#include "platform.h"
+#include "PinNames.h"
+#include "PeripheralNames.h"
+#include "Base.h"
+
+namespace mbed {
+
+/* Class: Timer
+ * A general purpose timer
+ *
+ * Example:
+ * > // Count the time to toggle a LED
+ * >
+ * > #include "mbed.h"
+ * >
+ * > Timer timer;
+ * > DigitalOut led(LED1);
+ * > int begin, end;
+ * >
+ * > int main() {
+ * > timer.start();
+ * > begin = timer.read_us();
+ * > led = !led;
+ * > end = timer.read_us();
+ * > printf("Toggle the led takes %d us", end - begin);
+ * > }
+ */
+class Timer : public Base {
+
+public:
+
+ Timer(const char *name = NULL);
+
+ /* Function: start
+ * Start the timer
+ */
+ void start();
+
+ /* Function: stop
+ * Stop the timer
+ */
+ void stop();
+
+ /* Function: reset
+ * Reset the timer to 0.
+ *
+ * If it was already counting, it will continue
+ */
+ void reset();
+
+ /* Function: read
+ * Get the time passed in seconds
+ */
+ float read();
+
+ /* Function: read_ms
+ * Get the time passed in mili-seconds
+ */
+ int read_ms();
+
+ /* Function: read_us
+ * Get the time passed in micro-seconds
+ */
+ int read_us();
+
+#ifdef MBED_OPERATORS
+ operator float();
+#endif
+
+#ifdef MBED_RPC
+ virtual const struct rpc_method *get_rpc_methods();
+ static struct rpc_class *get_rpc_class();
+#endif
+
+protected:
+
+ int slicetime();
+ int _running; // whether the timer is running
+ unsigned int _start; // the start time of the latest slice
+ int _time; // any accumulated time from previous slices
+
+};
+
+} // namespace mbed
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/TimerEvent.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,46 @@
+/* mbed Microcontroller Library - TimerEvent
+ * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_TIMEREVENT_H
+#define MBED_TIMEREVENT_H
+
+namespace mbed {
+
+// Base abstraction for timer interrupts
+class TimerEvent {
+
+public:
+
+ TimerEvent();
+
+ // 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
+
+};
+
+} // namespace mbed
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/can_helper.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,38 @@
+/* mbed Microcontroller Library - can_helper
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * rmeyer
+ */
+
+#ifndef MBED_CAN_HELPER_H
+#define MBED_CAN_HELPER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum CANFormat CANFormat;
+enum CANFormat {
+ CANStandard = 0,
+ CANExtended = 1
+};
+
+typedef enum CANType CANType;
+enum CANType {
+ CANData = 0,
+ CANRemote = 1
+};
+
+typedef struct CAN_Message CAN_Message;
+struct CAN_Message {
+ unsigned int id; // 29 bit identifier
+ unsigned char data[8]; // Data field
+ unsigned char len; // Length of data field in bytes
+ CANFormat format; // 0 - STANDARD, 1- EXTENDED IDENTIFIER
+ CANType type; // 0 - DATA FRAME, 1 - REMOTE FRAME
+};
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // MBED_CAN_HELPER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed/cmsis.h Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,21 @@ +/* mbed Microcontroller Library - CMSIS + * Copyright (C) 2009 ARM Limited. All rights reserved. + * + * A generic CMSIS include header, pulling in the appropriate + * target specific CMSIS files + */ + +#ifndef MBED_CMSIS_H +#define MBED_CMSIS_H + +#if defined(TARGET_LPC1768) +#include "LPC17xx.h" +#elif defined(TARGET_LPC2368) +#include "LPC23xx.h" +#else +#error "CMSIS Target not recognised" +#endif + +#include "cmsis_nvic.h" + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/cmsis_nvic.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,24 @@
+/* mbed Microcontroller Library - cmsis_nvic
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * sford
+ *
+ * CMSIS-style functionality to support dynamic vectors
+ */
+
+#ifndef MBED_CMSIS_NVIC_H
+#define MBED_CMSIS_NVIC_H
+
+#include "cmsis.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
+uint32_t NVIC_GetVector(IRQn_Type IRQn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/error.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,61 @@
+/* mbed Microcontroller Library - error
+ * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_ERROR_H
+#define MBED_ERROR_H
+
+/* Reporting Compile-Time Errors:
+ * To generate a fatal compile-time error, you can use the pre-processor #error directive.
+ *
+ * > #error "That shouldn't have happened!"
+ *
+ * If the compiler evaluates this line, it will report the error and stop the compile.
+ *
+ * For example, you could use this to check some user-defined compile-time variables:
+ *
+ * > #define NUM_PORTS 7
+ * > #if (NUM_PORTS > 4)
+ * > #error "NUM_PORTS must be less than 4"
+ * > #endif
+ *
+ * Reporting Run-Time Errors:
+ * To generate a fatal run-time error, you can use the mbed error() function.
+ *
+ * > error("That shouldn't have happened!");
+ *
+ * If the mbed running the program executes this function, it will print the
+ * message via the USB serial port, and then die with the blue lights of death!
+ *
+ * The message can use printf-style formatting, so you can report variables in the
+ * message too. For example, you could use this to check a run-time condition:
+ *
+ * > if(x >= 5) {
+ * > error("expected x to be less than 5, but got %d", x);
+ * > }
+ */
+
+#if 0 // for documentation only
+/* Function: error
+ * Report a fatal runtime error
+ *
+ * Outputs the specified error message to stderr so it will appear via the USB
+ * serial port, and then calls exit(1) to die with the blue lights of death.
+ *
+ * Variables:
+ * format - printf-style format string, followed by associated variables
+ */
+void error(const char* format, ...);
+#endif
+
+#include <stdlib.h>
+
+#ifdef NDEBUG
+ #define error(...) (exit(1))
+#else
+ #include <stdio.h>
+ #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1))
+#endif
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed/mbed.h Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,60 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2009 ARM Limited. All rights reserved. + * sford + */ + +#ifndef MBED_H +#define MBED_H + +#define MBED_LIBRARY_VERSION 24 + +// Useful C libraries +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> + +// mbed Debug libraries +#include "error.h" + +// mbed Peripheral components +#include "DigitalIn.h" +#include "DigitalOut.h" +#include "DigitalInOut.h" +#include "BusIn.h" +#include "BusOut.h" +#include "BusInOut.h" +#include "PortIn.h" +#include "PortInOut.h" +#include "PortOut.h" +#include "AnalogIn.h" +#include "AnalogOut.h" +#include "PwmOut.h" +#include "Serial.h" +#include "SerialHalfDuplex.h" +#include "SPI.h" +#include "SPISlave.h" +#include "SPIHalfDuplex.h" +#include "I2C.h" +#include "I2CSlave.h" +#include "Ethernet.h" +#include "CAN.h" +//#include "SPI3.h" + +// mbed Internal components +#include "Timer.h" +#include "Ticker.h" +#include "Timeout.h" +#include "LocalFileSystem.h" +#include "InterruptIn.h" +//#include "rpc.h" +//#include "rtc.h" +#include "wait_api.h" +#include "rtc_time.h" + +using namespace mbed; +using namespace std; + +#endif +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed/platform.h Fri Jan 31 23:19:28 2014 +0000 @@ -0,0 +1,12 @@ +/* mbed Microcontroller Library - platform + * Copyright (c) 2009 ARM Limited. All rights reserved. + * sford + */ + +#ifndef MBED_PLATFORM_H +#define MBED_PLATFORM_H + +#define MBED_RPC +#define MBED_OPERATORS + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/rpc.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,589 @@
+/* mbed Microcontroller Library - RPC
+ * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#ifndef MBED_RPC_H
+#define MBED_RPC_H
+
+/* Section rpc
+ * Helpers for rpc handling.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include "Base.h"
+
+#include "PinNames.h"
+#include <stdint.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);
+
+inline char parse_char(const char *arg, const char **next) {
+ char c = *arg++;
+ if(c == '\\') {
+ c = *arg++;
+ switch(c) {
+ case 'a': c = '\a'; break;
+ case 'b': c = '\b'; break;
+ case 't': c = '\t'; break;
+ case 'n': c = '\n'; break;
+ case 'v': c = '\v'; break;
+ case 'f': c = '\f'; break;
+ case 'r': c = '\r'; break;
+ case 'x':
+ {
+ /* two-character hexadecimal */
+ char buf[3];
+ buf[0] = *arg++;
+ buf[1] = *arg++;
+ buf[2] = 0;
+ c = strtol(buf, NULL, 16);
+ }
+ break;
+ default:
+ if(isdigit(c)) {
+ /* three-character octal */
+ char buf[4];
+ buf[0] = c;
+ buf[1] = *arg++;
+ buf[2] = *arg++;
+ buf[3] = 0;
+ c = strtol(buf, NULL, 8);
+ }
+ break;
+ }
+ }
+ *next = arg;
+ return c;
+}
+
+/* signed integer types */
+
+template<> inline int parse_arg<int>(const char *arg, const char **next) {
+ if(arg[0] == '\'') {
+ char c = parse_char(arg+1, &arg);
+ if(next != NULL) *next = arg+1;
+ return c;
+ } else {
+ return strtol(arg, const_cast<char**>(next), 0);
+ }
+}
+
+template<> inline char parse_arg<char>(const char *arg, const char **next) {
+ return parse_arg<int>(arg,next);
+}
+
+template<> inline short int parse_arg<short int>(const char *arg, const char **next) {
+ return parse_arg<int>(arg,next);
+}
+
+template<> inline long int parse_arg<long int>(const char *arg, const char **next) {
+ return parse_arg<int>(arg,next);
+}
+
+template<> inline long long parse_arg<long long>(const char *arg, const char **next) {
+ return strtoll(arg, const_cast<char**>(next), 0);
+}
+
+/* unsigned integer types */
+
+template<> inline unsigned int parse_arg<unsigned int>(const char *arg, const char **next) {
+ if(arg[0] == '\'') {
+ char c = parse_char(arg+1, &arg);
+ if(next != NULL) *next = arg+1;
+ return c;
+ } else {
+ return strtoul(arg, const_cast<char**>(next), 0);
+ }
+}
+
+template<> inline unsigned char parse_arg<unsigned char>(const char *arg, const char **next) {
+ return parse_arg<unsigned int>(arg,next);
+}
+
+template<> inline unsigned short int parse_arg<unsigned short int>(const char *arg, const char **next) {
+ return parse_arg<unsigned int>(arg,next);
+}
+
+template<> inline unsigned long int parse_arg<unsigned long int>(const char *arg, const char **next) {
+ return parse_arg<unsigned int>(arg,next);
+}
+
+template<> inline unsigned long long parse_arg<unsigned long long>(const char *arg, const char **next) {
+ return strtoull(arg, const_cast<char**>(next), 0);
+}
+
+/* floating types */
+
+template<> inline float parse_arg<float>(const char *arg, const char **next) {
+#if !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 410000
+ return strtof(arg,const_cast<char**>(next));
+#elif __ARMCC_VERSION >= 310000
+ /* bug in header means no using declaration for strtof */
+ return std::strtof(arg,const_cast<char**>(next));
+#else
+ /* strtof not supported */
+ 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));
+}
+
+/* string */
+
+template<> inline char *parse_arg<char*>(const char *arg, const char **next) {
+ const char *ptr = arg;
+ char *res = NULL;
+ if(*arg == '"') {
+ /* quoted string */
+ ptr = ++arg;
+ int len = 0;
+ /* find the end (and length) of the quoted string */
+ for(char c = *ptr; c != 0 && c != '"'; c = *++ptr) {
+ len++;
+ if(c == '\\') {
+ ptr++;
+ }
+ }
+ /* copy the quoted string, and unescape characters */
+ if(len != 0) {
+ res = new char[len+1];
+ char *resptr = res;
+ while(arg != ptr) {
+ *resptr++ = parse_char(arg, &arg);
+ }
+ *resptr = 0;
+ }
+ } else {
+ /* unquoted string */
+ while(isalnum(*ptr) || *ptr=='_') {
+ ptr++;
+ }
+ int len = ptr-arg;
+ if(len!=0) {
+ res = new char[len+1];
+ memcpy(res, arg, len);
+ res[len] = 0;
+ }
+ }
+
+ if(next != NULL) {
+ *next = ptr;
+ }
+ return res;
+}
+
+template<> inline const char *parse_arg<const char*>(const char *arg, const char **next) {
+ return parse_arg<char*>(arg,next);
+}
+
+/* Pins */
+
+
+inline PinName parse_pins(const char *str) {
+ const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
+ , p15, p16, p17, p18, p19, p20, p21, p22, p23
+ , p24, p25, p26, p27, p28, p29, p30};
+
+ if(str[0] == 'P') { // Pn_n
+ uint32_t port = str[1] - '0';
+ uint32_t pin = str[3] - '0'; // Pn_n
+ uint32_t pin2 = str[4] - '0'; // Pn_nn
+ if(pin2 <= 9) {
+ pin = pin * 10 + pin2;
+ }
+ return (PinName)(LPC_GPIO0_BASE + port * 32 + pin);
+ } else if(str[0] == 'p') { // pn
+ uint32_t pin = str[1] - '0'; // pn
+ uint32_t pin2 = str[2] - '0'; // pnn
+ if(pin2 <= 9) {
+ pin = pin * 10 + pin2;
+ }
+ if(pin < 5 || pin > 30) {
+ return NC;
+ }
+ return pin_names[pin - 5];
+ } else if(str[0] == 'L') { // LEDn
+ switch(str[3]) {
+ case '1' : return LED1;
+ case '2' : return LED2;
+ case '3' : return LED3;
+ case '4' : return LED4;
+ }
+ } else if(str[0] == 'U') { // USB?X
+ switch(str[3]) {
+ case 'T' : return USBTX;
+ case 'R' : return USBRX;
+ }
+ }
+ return NC;
+}
+
+template<> inline PinName parse_arg<PinName>(const char *arg, const char **next) {
+ const char *ptr = arg;
+ PinName pinname = NC;
+ while(isalnum(*ptr) || *ptr=='_') {
+ ptr++;
+ }
+ int len = ptr-arg;
+ if(len!=0) {
+ pinname = parse_pins(arg);
+
+ }
+ if(next != NULL) {
+ *next = ptr;
+ }
+ return pinname;
+}
+
+
+/* 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, "%.17g", val);
+}
+
+template<> inline void write_result<double>(double val, char *result) {
+ sprintf(result, "%.17g", val);
+}
+
+template<> inline void write_result<long double>(long double val, char *result) {
+ sprintf(result, "%.17Lg", val);
+}
+
+
+/* string */
+
+template<> inline void write_result<char*>(char *val, char *result) {
+ if(val==NULL) {
+ result[0] = 0;
+ } else {
+ strcpy(result, val);
+ }
+}
+
+template<> inline void write_result<const char*>(const char *val, char *result) {
+ if(val==NULL) {
+ result[0] = 0;
+ } else {
+ strcpy(result, val);
+ }
+}
+
+
+inline const char *next_arg(const char* next) {
+ while(*next == ' ') next++;
+ if(*next == ',' || *next == '?') next++;
+ while(*next == ' ') next++;
+ return next;
+}
+
+
+/* Function rpc_method_caller
+ */
+template<class T, void (T::*member)(const char *,char *)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+ (static_cast<T*>(this_ptr)->*member)(arguments,result);
+}
+
+
+/* Function rpc_method_caller
+ */
+template<class T, void (T::*member)()>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+ (static_cast<T*>(this_ptr)->*member)();
+ if(result != NULL) {
+ result[0] = '\0';
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<class T, typename A1, void (T::*member)(A1)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),NULL);
+
+ (static_cast<T*>(this_ptr)->*member)(arg1);
+ if(result != NULL) {
+ result[0] = '\0';
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<class T, typename A1, typename A2, void (T::*member)(A1,A2)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),NULL);
+
+ (static_cast<T*>(this_ptr)->*member)(arg1,arg2);
+ if(result != NULL) {
+ result[0] = '\0';
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<class T, typename A1, typename A2, typename A3, void (T::*member)(A1,A2,A3)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),&next);
+ A3 arg3 = parse_arg<A3>(next_arg(next),NULL);
+
+ (static_cast<T*>(this_ptr)->*member)(arg1,arg2,arg3);
+ if(result != NULL) {
+ result[0] = '\0';
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<typename R, class T, R (T::*member)()>
+void rpc_method_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 rpc_method_caller
+ */
+template<typename R, class T, typename A1, R (T::*member)(A1)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),NULL);
+
+ R res = (static_cast<T*>(this_ptr)->*member)(arg1);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<typename R, class T, typename A1, typename A2, R (T::*member)(A1,A2)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),NULL);
+
+ R res = (static_cast<T*>(this_ptr)->*member)(arg1,arg2);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_method_caller
+ */
+template<typename R, class T, typename A1, typename A2, typename A3, R (T::*member)(A1,A2,A3)>
+void rpc_method_caller(Base *this_ptr, const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),&next);
+ A3 arg3 = parse_arg<A3>(next_arg(next),NULL);
+
+ R res = (static_cast<T*>(this_ptr)->*member)(arg1,arg2,arg3);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_function caller
+ */
+template<typename R, R (*func)()>
+void rpc_function_caller(const char *arguments, char *result) {
+ R res = (*func)();
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_function caller
+ */
+template<typename R, typename A1, R (*func)(A1)>
+void rpc_function_caller(const char *arguments, char *result) {
+ A1 arg1 = parse_arg<A1>(next_arg(arguments),NULL);
+ R res = (*func)(arg1);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_function caller
+ */
+template<typename R, typename A1, typename A2, R (*func)(A1,A2)>
+void rpc_function_caller(const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),NULL);
+
+ R res = (*func)(arg1,arg2);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_function caller
+ */
+template<typename R, typename A1, typename A2, typename A3, R (*func)(A1,A2,A3)>
+void rpc_function_caller(const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),&next);
+ A3 arg3 = parse_arg<A3>(next_arg(next),NULL);
+
+ R res = (*func)(arg1,arg2,arg3);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+/* Function rpc_function caller
+ */
+template<typename R, typename A1, typename A2, typename A3, typename A4, R (*func)(A1,A2,A3,A4)>
+void rpc_function_caller(const char *arguments, char *result) {
+
+ const char *next = arguments;
+ A1 arg1 = parse_arg<A1>(next_arg(next),&next);
+ A2 arg2 = parse_arg<A2>(next_arg(next),&next);
+ A3 arg3 = parse_arg<A3>(next_arg(next),&next);
+ A4 arg4 = parse_arg<A4>(next_arg(next),NULL);
+
+ R res = (*func)(arg1,arg2,arg3,arg4);
+ if(result != NULL) {
+ write_result<R>(res, result);
+ }
+}
+
+
+struct rpc_method {
+ const char *name;
+ typedef void (*caller_t)(Base*, const char*, char*);
+ typedef const struct rpc_method *(*super_t)(Base*);
+ union {
+ caller_t caller;
+ super_t super;
+ };
+};
+
+template<class C>
+const struct rpc_method *rpc_super(Base *this_ptr) {
+ return static_cast<C*>(this_ptr)->C::get_rpc_methods();
+}
+
+#define RPC_METHOD_END { NULL, NULL }
+#define RPC_METHOD_SUPER(C) { NULL, (rpc_method::caller_t)(rpc_method::super_t)rpc_super<C> }
+
+/* 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/rtc_time.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,207 @@
+/* Title: time
+ * Implementation of the C time.h functions
+ *
+ * Provides mechanisms to set and read the current time, based
+ * on the microcontroller Real-Time Clock (RTC), plus some
+ * standard C manipulation and formating functions.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
+ * >
+ * > while(1) {
+ * > time_t seconds = time(NULL);
+ * >
+ * > printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+ * >
+ * > printf("Time as a basic string = %s", ctime(&seconds));
+ * >
+ * > char buffer[32];
+ * > strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
+ * > printf("Time as a custom formatted string = %s", buffer);
+ * >
+ * > wait(1);
+ * > }
+ * > }
+ */
+
+/* mbed Microcontroller Library - rtc_time
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if 0 // for documentation only
+/* Function: time
+ * Get the current time
+ *
+ * Returns the current timestamp as the number of seconds since January 1, 1970
+ * (the UNIX timestamp). The value is based on the current value of the
+ * microcontroller Real-Time Clock (RTC), which can be set using <set_time>.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > time_t seconds = time(NULL);
+ * > printf("It is %d seconds since January 1, 1970\n", seconds);
+ * > }
+ *
+ * Variables:
+ * t - Pointer to a time_t to be set, or NULL if not used
+ * returns - Number of seconds since January 1, 1970 (the UNIX timestamp)
+ */
+time_t time(time_t *t);
+#endif
+
+/* Function: set_time
+ * Set the current time
+ *
+ * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
+ * to the time represented by the number of seconds since January 1, 1970
+ * (the UNIX timestamp).
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
+ * > }
+ *
+ * Variables:
+ * t - Number of seconds since January 1, 1970 (the UNIX timestamp)
+ */
+void set_time(time_t t);
+
+#if 0 // for documentation only
+/* Function: mktime
+ * Converts a tm structure in to a timestamp
+ *
+ * Converts the tm structure in to a timestamp in seconds since January 1, 1970
+ * (the UNIX timestamp). The values of tm_wday and tm_yday of the tm structure
+ * are also updated to their appropriate values.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > // setup time structure for Wed, 28 Oct 2009 11:35:37
+ * > struct tm t;
+ * > t.tm_sec = 37; // 0-59
+ * > t.tm_min = 35; // 0-59
+ * > t.tm_hour = 11; // 0-23
+ * > t.tm_mday = 28; // 1-31
+ * > t.tm_mon = 9; // 0-11
+ * > t.tm_year = 109; // year since 1900
+ * >
+ * > // convert to timestamp and display (1256729737)
+ * > time_t seconds = mktime(&t);
+ * > printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+ * > }
+ *
+ * Variables:
+ * t - The tm structure to convert
+ * returns - The converted timestamp
+ */
+time_t mktime(struct tm *t);
+#endif
+
+#if 0 // for documentation only
+/* Function: localtime
+ * Converts a timestamp in to a tm structure
+ *
+ * Converts the timestamp pointed to by t to a (statically allocated)
+ * tm structure.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > time_t seconds = 1256729737;
+ * > struct tm *t = localtime(&seconds);
+ * > }
+ *
+ * Variables:
+ * t - Pointer to the timestamp
+ * returns - Pointer to the (statically allocated) tm structure
+ */
+struct tm *localtime(const time_t *t);
+#endif
+
+#if 0 // for documentation only
+/* Function: ctime
+ * Converts a timestamp to a human-readable string
+ *
+ * Converts a time_t timestamp in seconds since January 1, 1970 (the UNIX
+ * timestamp) to a human readable string format. The result is of the
+ * format: "Wed Oct 28 11:35:37 2009\n"
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > time_t seconds = time(NULL);
+ * > printf("Time as a string = %s", ctime(&seconds));
+ * > }
+ *
+ * Variables:
+ * t - The timestamp to convert
+ * returns - Pointer to a (statically allocated) string containing the
+ * human readable representation, including a '\n' character
+ */
+char *ctime(const time_t *t);
+#endif
+
+#if 0 // for documentation only
+/* Function: strftime
+ * Converts a tm structure to a custom format human-readable string
+ *
+ * Creates a formated string from a tm structure, based on a string format
+ * specifier provided.
+ *
+ * Format Specifiers:
+ * %S - Second (00-59)
+ * %M - Minute (00-59)
+ * %H - Hour (00-23)
+ * %d - Day (01-31)
+ * %m - Month (01-12)
+ * %Y/%y - Year (2009/09)
+ *
+ * %A/%a - Weekday Name (Monday/Mon)
+ * %B/%b - Month Name (January/Jan)
+ * %I - 12 Hour Format (01-12)
+ * %p - "AM" or "PM"
+ * %X - Time (14:55:02)
+ * %x - Date (08/23/01)
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > int main() {
+ * > time_t seconds = time(NULL);
+ * >
+ * > char buffer[32];
+ * > strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
+ * > printf("Time as a formatted string = %s", buffer);
+ * > }
+ *
+ * Variables:
+ * buffer - String buffer to store the result
+ * max - Maximum number of characters to store in the buffer
+ * format - Format specifier string
+ * t - Pointer to the tm structure to convert
+ * returns - Number of characters copied
+ */
+size_t strftime(char *buffer, size_t max, const char *format, const struct tm *t);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/wait_api.h Fri Jan 31 23:19:28 2014 +0000
@@ -0,0 +1,64 @@
+/* Title: wait
+ * Generic wait functions.
+ *
+ * These provide simple NOP type wait capabilities.
+ *
+ * Example:
+ * > #include "mbed.h"
+ * >
+ * > DigitalOut heartbeat(LED1);
+ * >
+ * > int main() {
+ * > while (1) {
+ * > heartbeat = 1;
+ * > wait(0.5);
+ * > heartbeat = 0;
+ * > wait(0.5);
+ * > }
+ * > }
+ */
+
+/* mbed Microcontroller Library - wait_api
+ * Copyright (c) 2009 ARM Limited. All rights reserved.
+ * sford
+ */
+
+// GENERIC
+
+#ifndef MBED_WAIT_API_H
+#define MBED_WAIT_API_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Function: wait
+ * Waits for a number of seconds, with microsecond resolution (within
+ * the accuracy of single precision floating point).
+ *
+ * Variables:
+ * s - number of seconds to wait
+ */
+void wait(float s);
+
+/* Function: wait_ms
+ * Waits a number of milliseconds.
+ *
+ * Variables:
+ * ms - the whole number of milliseconds to wait
+ */
+void wait_ms(int ms);
+
+/* Function: wait_us
+ * Waits a number of microseconds.
+ *
+ * Variables:
+ * us - the whole number of microseconds to wait
+ */
+void wait_us(int us);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
