Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed. (modified for use opendrain in stm32)
Fork of FastIO by
Devices/FastIO_NUCLEO_F401.h
- Committer:
- Sissors
- Date:
- 2014-07-16
- Revision:
- 4:6ebbf25b9167
- Child:
- 5:3dd1ab9bbc59
File content as of revision 4:6ebbf25b9167:
#ifdef TARGET_NUCLEO_F401RE #include "mbed.h" #include "pinmap.h" typedef struct { uint32_t mask; } fastio_vars; #define PINMASK (1 << STM_PIN(pin)) #define PORT ((GPIO_TypeDef *)(GPIOA_BASE + 0x0400 * STM_PORT(pin))) #define INIT_PIN RCC->AHB1ENR |= (1 << STM_PORT(pin)); container.mask = PINMASK #define DESTROY_PIN #define SET_DIR_INPUT (PORT->MODER &= ~(GPIO_MODER_MODER0 << (STM_PIN(pin) * 2))) #define SET_DIR_OUTPUT (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2))) #define SET_MODE(pull) pin_mode(pin, pull); #define WRITE_PIN_SET (PORT->BSRRL = PINMASK) #define WRITE_PIN_CLR (PORT->BSRRH = PINMASK) #define READ_PIN ((PORT->IDR & container.mask) ? 1 : 0) #endif