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

FastIO_STM32L073XX.h

00001 #if defined(STM32L073xx)
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->IOPENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODE0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK
00014 #define DESTROY_PIN     
00015 
00016 #define SET_DIR_INPUT       (PORT->MODER &= ~(GPIO_MODER_MODE0_0 << (STM_PIN(pin) * 2)))
00017 #define SET_DIR_OUTPUT      (PORT->MODER |= (GPIO_MODER_MODE0_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