Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed.

Fork of FastIO by Erik -

Committer:
amateusz
Date:
Tue Apr 17 13:28:24 2018 +0000
Revision:
23:23a43a288e2c
Parent:
22:45b32f07e790
Added support for STM32L1xx (checked on Nucleo L152). I'm done this solely cross referenced existing STM32 target files with L152 reference manual.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 6:da3730030c07 1 #ifdef TARGET_NUCLEO_F030R8
Sissors 6:da3730030c07 2
Sissors 6:da3730030c07 3 #include "mbed.h"
Sissors 6:da3730030c07 4 #include "pinmap.h"
Sissors 6:da3730030c07 5
Sissors 6:da3730030c07 6 typedef struct {
Sissors 6:da3730030c07 7 uint32_t mask;
Sissors 6:da3730030c07 8 } fastio_vars;
Sissors 6:da3730030c07 9
Sissors 6:da3730030c07 10 #define PINMASK (1 << STM_PIN(pin))
Sissors 6:da3730030c07 11 #define PORT ((GPIO_TypeDef *)(GPIOA_BASE + 0x0400 * STM_PORT(pin)))
Sissors 6:da3730030c07 12
amateusz 23:23a43a288e2c 13
Sissors 22:45b32f07e790 14 #define INIT_PIN RCC->AHBENR |= (1 << (STM_PORT(pin) + 17)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK
Sissors 6:da3730030c07 15 #define DESTROY_PIN
Sissors 6:da3730030c07 16
Sissors 7:1e784ae11fba 17 #define SET_DIR_INPUT (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
Sissors 6:da3730030c07 18 #define SET_DIR_OUTPUT (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2)))
Sissors 6:da3730030c07 19 #define SET_MODE(pull) pin_mode(pin, pull);
Sissors 6:da3730030c07 20
Sissors 6:da3730030c07 21 #define WRITE_PIN_SET (PORT->BSRR = PINMASK)
Sissors 6:da3730030c07 22 #define WRITE_PIN_CLR (PORT->BRR = PINMASK)
Sissors 6:da3730030c07 23
Sissors 6:da3730030c07 24 #define READ_PIN ((PORT->IDR & container.mask) ? 1 : 0)
Sissors 6:da3730030c07 25
Sissors 6:da3730030c07 26 #endif
Sissors 22:45b32f07e790 27