Fixed constructor for latest mbed library.

Dependents:   Pinscape_Controller_v1 Pinscape_Controller Pinscape_Controller_V2_arnoz Pinscape_Controller_V2

Fork of FastIO by Erik -

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FastIO_LPC81X.h Source File

FastIO_LPC81X.h

00001 #ifdef TARGET_LPC81X
00002 
00003 #include "mbed.h"
00004 #include "pinmap.h"
00005 
00006 typedef struct {
00007     __I  uint32_t *reg_in;
00008     uint32_t mask;
00009 } fastio_vars;
00010 
00011 #define PINMASK         (1 << ((int)pin & 0x1F))
00012 static void gpio_enable(void);
00013 
00014 #define INIT_PIN        container.mask = PINMASK; container.reg_in = &LPC_GPIO_PORT->PIN0; gpio_enable(); pin_function(pin, 0)
00015 #define DESTROY_PIN     
00016 
00017 #define SET_DIR_INPUT   (LPC_GPIO_PORT->DIR0 &= ~PINMASK)
00018 #define SET_DIR_OUTPUT  (LPC_GPIO_PORT->DIR0 |= PINMASK)
00019 #define SET_MODE(pull)  (pin_mode(pin, pull))
00020 
00021 #define WRITE_PIN_SET   (LPC_GPIO_PORT->SET0 = PINMASK)
00022 #define WRITE_PIN_CLR   (LPC_GPIO_PORT->CLR0 = PINMASK)
00023 
00024 #define READ_PIN        ((*container.reg_in & container.mask) ? 1 : 0)
00025 
00026 static int  gpio_enabled = 0;
00027 static void gpio_enable(void)
00028 {
00029     if (!gpio_enabled) {
00030         gpio_enabled = 1;
00031 
00032         /* Enable AHB clock to the GPIO domain. */
00033         LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
00034 
00035         /* Peripheral reset control to GPIO and GPIO INT, a "1" bring it out of reset. */
00036         LPC_SYSCON->PRESETCTRL &= ~(0x1<<10);
00037         LPC_SYSCON->PRESETCTRL |=  (0x1<<10);
00038     }
00039 }
00040 
00041 #endif