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:
Sat Sep 20 13:02:00 2014 +0000
Parent:
8:b0d725519c4f
Child:
10:bb22a3dbedb4
Commit message:
Added support for KSPDK (K22F/K64F)

Changed in this revision

Devices/FastIO_K20D50M.h Show diff for this revision Revisions of this file
Devices/FastIO_K20D50M_KSPDK.h Show annotated file Show diff for this revision Revisions of this file
--- a/Devices/FastIO_K20D50M.h	Tue Aug 12 07:15:20 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#ifdef TARGET_K20D50M
-
-#include "mbed.h"
-#include "pinmap.h"
-
-typedef struct {
-    uint32_t mask;
-} fastio_vars;
-
-#define PORT_BASE       ((GPIO_Type *)(PTA_BASE + ((unsigned int)pin >> PORT_SHIFT) * 0x40))
-#define PINMASK         (1 << ((pin & 0x7F) >> 2))
-#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)
-#define SET_MODE(pull)  (*PCR = (*PCR & ~0x3) | pull)
-
-#define WRITE_PIN_SET   (PORT_BASE->PSOR |= container.mask)
-#define WRITE_PIN_CLR   (PORT_BASE->PCOR |= container.mask)
-
-#define READ_PIN        ((PORT_BASE->PDIR & container.mask) ? 1 : 0)
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Devices/FastIO_K20D50M_KSPDK.h	Sat Sep 20 13:02:00 2014 +0000
@@ -0,0 +1,34 @@
+#if defined(TARGET_K20D50M) | defined(TARGET_KPSDK_MCUS)
+
+#include "mbed.h"
+#include "pinmap.h"
+
+typedef struct {
+    uint32_t mask;
+} fastio_vars;
+
+//K20D50M and KPSDK use slightly different pinnames, shifted 2
+#ifdef TARGET_KPSDK_MCUS
+#define PORT_SHIFT      GPIO_PORT_SHIFT
+#define PINMASK         (1 << (pin & 0x1F))
+#define PCR             ((__IO uint32_t*)(PORTA_BASE + ((pin & 0x1F) << 2) + ((pin >> PORT_SHIFT) << PORT_SHIFT)  ))
+#else
+#define PINMASK         (1 << ((pin & 0x7F) >> 2))
+#define PCR             ((__IO uint32_t*)(PORTA_BASE + pin))
+#endif
+
+#define PORT_BASE       ((GPIO_Type *)(PTA_BASE + ((unsigned int)pin >> PORT_SHIFT) * 0x40))
+
+#define INIT_PIN        container.mask = PINMASK; pin_function(pin, 1); printf("PINMASK = %d, BASE = %X\r\n", PINMASK, PORT_BASE)
+#define DESTROY_PIN     
+
+#define SET_DIR_INPUT   (PORT_BASE->PDDR &= ~PINMASK)
+#define SET_DIR_OUTPUT  (PORT_BASE->PDDR |= PINMASK)
+#define SET_MODE(pull)  (*PCR = (*PCR & ~0x3) | pull)
+
+#define WRITE_PIN_SET   (PORT_BASE->PSOR |= container.mask)
+#define WRITE_PIN_CLR   (PORT_BASE->PCOR |= container.mask)
+
+#define READ_PIN        ((PORT_BASE->PDIR & container.mask) ? 1 : 0)
+
+#endif