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

FastIO_LPC11UXX.h

00001 #ifdef TARGET_LPC11UXX
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 & 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->DIR[PORT] &= ~PINMASK)
00018 #define SET_DIR_OUTPUT  (LPC_GPIO->DIR[PORT] |= PINMASK)
00019 #define SET_MODE(pull)  (pin_mode(pin, pull))
00020 
00021 #define WRITE_PIN_SET   (LPC_GPIO->SET[PORT] = PINMASK)
00022 #define WRITE_PIN_CLR   (LPC_GPIO->CLR[PORT] = PINMASK)
00023 
00024 #define READ_PIN        ((LPC_GPIO->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 
00035     pin_function(pin, f);
00036 }
00037 
00038 #endif