Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed.

Fork of FastIO by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Tue Jul 29 18:58:05 2014 +0000
Parent:
6:da3730030c07
Child:
8:b0d725519c4f
Commit message:
Added LPC1114

Changed in this revision

Devices/FastIO_LPC11XX.h Show annotated file Show diff for this revision Revisions of this file
Devices/FastIO_NUCLEO_F030.h Show annotated file Show diff for this revision Revisions of this file
Devices/FastIO_NUCLEO_F401.h Show annotated file Show diff for this revision Revisions of this file
FastIO.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Devices/FastIO_LPC11XX.h	Tue Jul 29 18:58:05 2014 +0000
@@ -0,0 +1,41 @@
+#ifdef TARGET_LPC11XX_11CXX
+
+#include "mbed.h"
+#include "pinmap.h"
+#include "reserved_pins.h"
+
+typedef struct {
+} fastio_vars;
+
+#define PORT            ((LPC_GPIO_TypeDef *) (LPC_GPIO0_BASE + (((pin & 0xF000) >> PORT_SHIFT) * 0x10000)))
+#define PIN             ((pin & 0x0F00) >> 8 )
+#define MASKDATA        (*((volatile uint32_t*) ((uint32_t)PORT + (1 << (PIN + 2)))))
+static inline void initpin(PinName pin);
+static const PinName reserved_pins[] = TARGET_RESERVED_PINS;
+
+#define INIT_PIN        initpin(pin)
+#define DESTROY_PIN     
+
+#define SET_DIR_INPUT   (PORT->DIR &= ~(1 << PIN))
+#define SET_DIR_OUTPUT  (PORT->DIR |= (1<<PIN))
+#define SET_MODE(pull)  (pin_mode(pin, pull))
+
+#define WRITE_PIN_SET   (MASKDATA = 0xFFFF)
+#define WRITE_PIN_CLR   (MASKDATA = 0)
+
+#define READ_PIN        ((MASKDATA == 0) ? 0 : 1)
+
+static inline void initpin(PinName pin) {
+    unsigned i;
+    int f = 0;
+
+    for (i = 0; i < sizeof(reserved_pins) / sizeof(PinName); i ++) {
+        if (pin == reserved_pins[i]) {
+            f = 1;
+            break;
+        }
+    }
+    pin_function(pin, f);
+}
+
+#endif
\ No newline at end of file
--- a/Devices/FastIO_NUCLEO_F030.h	Thu Jul 17 15:08:03 2014 +0000
+++ b/Devices/FastIO_NUCLEO_F030.h	Tue Jul 29 18:58:05 2014 +0000
@@ -13,7 +13,7 @@
 #define INIT_PIN            RCC->AHBENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK
 #define DESTROY_PIN     
 
-#define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0 << (STM_PIN(pin) * 2)))
+#define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_DIR_OUTPUT      (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_MODE(pull)      pin_mode(pin, pull);
 
--- a/Devices/FastIO_NUCLEO_F401.h	Thu Jul 17 15:08:03 2014 +0000
+++ b/Devices/FastIO_NUCLEO_F401.h	Tue Jul 29 18:58:05 2014 +0000
@@ -13,7 +13,7 @@
 #define INIT_PIN            RCC->AHB1ENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK
 #define DESTROY_PIN     
 
-#define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0 << (STM_PIN(pin) * 2)))
+#define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_DIR_OUTPUT      (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
 #define SET_MODE(pull)      pin_mode(pin, pull);
 
--- a/FastIO.h	Thu Jul 17 15:08:03 2014 +0000
+++ b/FastIO.h	Tue Jul 29 18:58:05 2014 +0000
@@ -8,6 +8,7 @@
 #include "FastIO_K20D50M.h"
 #include "FastIO_NUCLEO_F401.h"
 #include "FastIO_NUCLEO_F030.h"
+#include "FastIO_LPC11XX.h"
 
 #ifndef INIT_PIN
 #warning Target is not supported by FastIO