Fixed constructor for latest mbed library.

Dependents:   Pinscape_Controller_v1 Pinscape_Controller Pinscape_Controller_V2_arnoz Pinscape_Controller_V2

Fork of FastIO by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Wed Jul 02 06:01:51 2014 +0000
Parent:
0:d394ebd01052
Child:
2:1a6ed4b84590
Commit message:
Added LPC81X

Changed in this revision

FastIO.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
--- a/FastIO.h	Tue Jul 01 17:04:08 2014 +0000
+++ b/FastIO.h	Wed Jul 02 06:01:51 2014 +0000
@@ -3,6 +3,7 @@
 
 #include "FastIO_LPC1768.h"
 #include "FastIO_LPC11UXX.h"
+#include "FastIO_LPC81X.h"
 #include "FastIO_KLXX.h"
 
 #ifndef INIT_PIN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FastIO_LPC81X.h	Wed Jul 02 06:01:51 2014 +0000
@@ -0,0 +1,40 @@
+#ifdef TARGET_LPC81X
+
+#include "mbed.h"
+#include "pinmap.h"
+
+typedef struct {
+    __I  uint32_t *reg_in;
+    uint32_t mask;
+} fastio_vars;
+
+#define PINMASK         (1 << ((int)pin & 0x1F))
+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 SET_DIR_INPUT   (LPC_GPIO_PORT->DIR0 &= ~PINMASK)
+#define SET_DIR_OUTPUT  (LPC_GPIO_PORT->DIR0 |= PINMASK)
+#define SET_MODE(pull)  (pin_mode(pin, pull))
+
+#define WRITE_PIN_SET   (LPC_GPIO_PORT->SET0 = PINMASK)
+#define WRITE_PIN_CLR   (LPC_GPIO_PORT->CLR0 = PINMASK)
+
+#define READ_PIN        ((*container.reg_in & container.mask) ? 1 : 0)
+
+static int  gpio_enabled = 0;
+static void gpio_enable(void)
+{
+    if (!gpio_enabled) {
+        gpio_enabled = 1;
+
+        /* Enable AHB clock to the GPIO domain. */
+        LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
+
+        /* Peripheral reset control to GPIO and GPIO INT, a "1" bring it out of reset. */
+        LPC_SYSCON->PRESETCTRL &= ~(0x1<<10);
+        LPC_SYSCON->PRESETCTRL |=  (0x1<<10);
+    }
+}
+
+#endif
\ No newline at end of file