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 May 17 20:06:23 2016 +0000
Parent:
19:89d6ae484a35
Child:
21:a1dfa6c65400
Commit message:
Initial version for the NRF51822. I am reasonably sure it works, but with lacking an LED on my board or a logic analyzer it might have issues :).

Changed in this revision

Devices/FastIO_NRF51822.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_NRF51822.h	Tue May 17 20:06:23 2016 +0000
@@ -0,0 +1,28 @@
+#ifdef TARGET_MCU_NRF51822
+
+#include "mbed.h"
+#include "gpio_api.h"
+
+typedef struct {
+    uint32_t mask;
+} fastio_vars;
+
+#define PINMASK         (1 << pin)
+
+
+#define INIT_PIN        container.mask = PINMASK; NRF_GPIO->PIN_CNF[pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
+                                        | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) \
+                                        | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \
+                                        | (NRF_GPIO->PIN_CNF[pin] & 0x01);      
+#define DESTROY_PIN     
+
+#define SET_DIR_INPUT   NRF_GPIO->DIRCLR = PINMASK
+#define SET_DIR_OUTPUT  NRF_GPIO->DIRSET = PINMASK    
+#define SET_MODE(pull)  NRF_GPIO->PIN_CNF[pin] = (NRF_GPIO->PIN_CNF[pin] & (~GPIO_PIN_CNF_PULL_Msk)) | pull
+
+#define WRITE_PIN_SET   NRF_GPIO->OUTSET = PINMASK    
+#define WRITE_PIN_CLR   NRF_GPIO->OUTCLR = PINMASK     
+
+#define READ_PIN        ((NRF_GPIO->IN & container.mask) ? 1 : 0)    
+
+#endif
\ No newline at end of file
--- a/FastIO.h	Fri Feb 05 14:47:23 2016 +0000
+++ b/FastIO.h	Tue May 17 20:06:23 2016 +0000
@@ -12,6 +12,7 @@
 #include "FastIO_LPC11XX.h"
 #include "FastIO_EFM32.h"
 #include "FastIO_LPC43XX.h"
+#include "FastIO_NRF51822.h"
 
 #ifndef INIT_PIN
 #warning Target is not supported by FastIO