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_LPC11U6X.h Source File

FastIO_LPC11U6X.h

00001 #ifdef TARGET_LPC11U6X
00002 
00003 #include "mbed.h"
00004 #include "pinmap.h"
00005 
00006 typedef struct {
00007     uint32_t mask;
00008 } fastio_vars;
00009 
00010 #define PORT            ((unsigned int)pin >> PORT_SHIFT)
00011 #define PINMASK         ( 1 << ((int)pin >> PIN_SHIFT & 0x1F) )
00012 static inline void initpin(PinName pin);
00013 
00014 #define INIT_PIN        container.mask = PINMASK; initpin(pin)
00015 #define DESTROY_PIN     
00016 
00017 #define SET_DIR_INPUT   (LPC_GPIO_PORT->DIR[PORT] &= ~PINMASK)
00018 #define SET_DIR_OUTPUT  (LPC_GPIO_PORT->DIR[PORT] |= PINMASK)
00019 #define SET_MODE(pull)  (pin_mode(pin, pull))
00020 
00021 #define WRITE_PIN_SET   (LPC_GPIO_PORT->SET[PORT] = PINMASK)
00022 #define WRITE_PIN_CLR   (LPC_GPIO_PORT->CLR[PORT] = PINMASK)
00023 
00024 #define READ_PIN        ((LPC_GPIO_PORT->PIN[PORT] & container.mask) ? 1 : 0)
00025 
00026 static inline void initpin(PinName pin) {
00027     int f =  ((pin == P0_0)  ||
00028               (pin == P0_10) ||
00029               (pin == P0_11) ||
00030               (pin == P0_12) ||
00031               (pin == P0_13) ||
00032               (pin == P0_14) ||
00033               (pin == P0_15)) ? (1) : (0);
00034     pin_function(pin, f);
00035 }
00036 
00037 #endif