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

Dependents:   Eavesdropper BitstreamGenerator SimpleDecimationFilter 11U68_MP3Player with TFTLCD ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FastIO_NRF51822.h Source File

FastIO_NRF51822.h

00001 #ifdef TARGET_MCU_NRF51822
00002 
00003 #include "mbed.h"
00004 #include "gpio_api.h"
00005 
00006 typedef struct {
00007     uint32_t mask;
00008 } fastio_vars;
00009 
00010 #define PINMASK         (1 << pin)
00011 
00012 
00013 #define INIT_PIN        container.mask = PINMASK; NRF_GPIO->PIN_CNF[pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
00014                                         | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) \
00015                                         | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \
00016                                         | (NRF_GPIO->PIN_CNF[pin] & 0x01);      
00017 #define DESTROY_PIN     
00018 
00019 #define SET_DIR_INPUT   NRF_GPIO->DIRCLR = PINMASK
00020 #define SET_DIR_OUTPUT  NRF_GPIO->DIRSET = PINMASK    
00021 #define SET_MODE(pull)  NRF_GPIO->PIN_CNF[pin] = (NRF_GPIO->PIN_CNF[pin] & (~GPIO_PIN_CNF_PULL_Msk)) | pull
00022 
00023 #define WRITE_PIN_SET   NRF_GPIO->OUTSET = PINMASK    
00024 #define WRITE_PIN_CLR   NRF_GPIO->OUTCLR = PINMASK     
00025 
00026 #define READ_PIN        ((NRF_GPIO->IN & container.mask) ? 1 : 0)    
00027 
00028 #endif