add LPC4337

Fork of FastIO by Erik -

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FastIO_NUCLEO_F030.h Source File

FastIO_NUCLEO_F030.h

00001 #ifdef TARGET_NUCLEO_F030R8
00002 
00003 #include "mbed.h"
00004 #include "pinmap.h"
00005 
00006 typedef struct {
00007     uint32_t mask;
00008 } fastio_vars;
00009 
00010 #define PINMASK             (1 << STM_PIN(pin))
00011 #define PORT                ((GPIO_TypeDef *)(GPIOA_BASE + 0x0400 * STM_PORT(pin)))
00012 
00013 #define INIT_PIN            RCC->AHBENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK
00014 #define DESTROY_PIN     
00015 
00016 #define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
00017 #define SET_DIR_OUTPUT      (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
00018 #define SET_MODE(pull)      pin_mode(pin, pull);
00019 
00020 #define WRITE_PIN_SET       (PORT->BSRR = PINMASK)
00021 #define WRITE_PIN_CLR       (PORT->BRR = PINMASK)
00022 
00023 #define READ_PIN            ((PORT->IDR & container.mask) ? 1 : 0)
00024 
00025 #endif