David Rimer / FastIO

Fork of FastIO by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Fri Jul 04 17:28:45 2014 +0000
Parent:
1:85a4a54f15e3
Child:
3:3dd9466e73fc
Commit message:
Added support for unsupported targets :P

Changed in this revision

FastIO.h Show annotated file Show diff for this revision Revisions of this file
FastIO_KLXX.h Show annotated file Show diff for this revision Revisions of this file
FastIO_LPC11UXX.h Show annotated file Show diff for this revision Revisions of this file
FastIO_LPC1768.h Show annotated file Show diff for this revision Revisions of this file
FastIO_LPC81X.h Show annotated file Show diff for this revision Revisions of this file
FastIO_Unsupported.h Show annotated file Show diff for this revision Revisions of this file
--- a/FastIO.h	Wed Jul 02 06:01:51 2014 +0000
+++ b/FastIO.h	Fri Jul 04 17:28:45 2014 +0000
@@ -7,7 +7,9 @@
 #include "FastIO_KLXX.h"
 
 #ifndef INIT_PIN
-#error Target is not supported
+#warning Target is not supported by FastIO
+#warning Reverting to regular DigitalInOut
+#include "FastIO_Unsupported.h"
 #endif
 
 #include "mbed.h"
@@ -36,6 +38,10 @@
     FastInOut() {
         INIT_PIN;
     }
+    
+    ~FastInOut() {
+        DESTROY_PIN;
+    }
 
     void write(int value) {
         if ( value )
--- a/FastIO_KLXX.h	Wed Jul 02 06:01:51 2014 +0000
+++ b/FastIO_KLXX.h	Fri Jul 04 17:28:45 2014 +0000
@@ -12,6 +12,7 @@
 #define PCR             ((__IO uint32_t*)(PORTA_BASE + pin))
 
 #define INIT_PIN        container.mask = PINMASK; pin_function(pin, 1)
+#define DESTROY_PIN     
 
 #define SET_DIR_INPUT   (PORT_BASE->PDDR &= ~PINMASK)
 #define SET_DIR_OUTPUT  (PORT_BASE->PDDR |= PINMASK)
--- a/FastIO_LPC11UXX.h	Wed Jul 02 06:01:51 2014 +0000
+++ b/FastIO_LPC11UXX.h	Fri Jul 04 17:28:45 2014 +0000
@@ -12,6 +12,7 @@
 static inline void initpin(PinName pin);
 
 #define INIT_PIN        container.mask = PINMASK; initpin(pin)
+#define DESTROY_PIN     
 
 #define SET_DIR_INPUT   (LPC_GPIO->DIR[PORT] &= ~PINMASK)
 #define SET_DIR_OUTPUT  (LPC_GPIO->DIR[PORT] |= PINMASK)
--- a/FastIO_LPC1768.h	Wed Jul 02 06:01:51 2014 +0000
+++ b/FastIO_LPC1768.h	Fri Jul 04 17:28:45 2014 +0000
@@ -14,6 +14,7 @@
 #define PINSELMASK          (0x03 << (((pin - P0_0)%16)*2) )
 
 #define INIT_PIN            container.mask = PINMASK; (PINSELREG &= ~PINSELMASK)
+#define DESTROY_PIN     
 
 #define SET_DIR_INPUT       (LPC_GPIO->FIODIR &= ~PINMASK)
 #define SET_DIR_OUTPUT      (LPC_GPIO->FIODIR |= PINMASK)
--- a/FastIO_LPC81X.h	Wed Jul 02 06:01:51 2014 +0000
+++ b/FastIO_LPC81X.h	Fri Jul 04 17:28:45 2014 +0000
@@ -12,6 +12,7 @@
 static void gpio_enable(void);
 
 #define INIT_PIN        container.mask = PINMASK; container.reg_in = &LPC_GPIO_PORT->PIN0; gpio_enable(); pin_function(pin, 0)
+#define DESTROY_PIN     
 
 #define SET_DIR_INPUT   (LPC_GPIO_PORT->DIR0 &= ~PINMASK)
 #define SET_DIR_OUTPUT  (LPC_GPIO_PORT->DIR0 |= PINMASK)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FastIO_Unsupported.h	Fri Jul 04 17:28:45 2014 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+typedef struct {
+    DigitalInOut *_pin;
+} fastio_vars;
+
+#define INIT_PIN        container._pin = new DigitalInOut(pin)
+#define DESTROY_PIN     delete(container._pin)
+
+#define SET_DIR_INPUT   container._pin->input()
+#define SET_DIR_OUTPUT  container._pin->output()
+#define SET_MODE(pull)  container._pin->mode(pull)
+
+#define WRITE_PIN_SET   container._pin->write(1)
+#define WRITE_PIN_CLR   container._pin->write(0)
+
+#define READ_PIN        container._pin->read()
+