Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of FastIO by
Devices/FastIO_STM32F4.h@13:0e21ffc6cb84, 2015-05-17 (annotated)
- Committer:
- Sissors
- Date:
- Sun May 17 10:48:26 2015 +0000
- Revision:
- 13:0e21ffc6cb84
- Child:
- 14:f0a48027b2b3
Generalized it to all STMF4 platforms. (Holy crap the F407 is fast)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 13:0e21ffc6cb84 | 1 | #if defined(TARGET_STM32F4) |
Sissors | 13:0e21ffc6cb84 | 2 | |
Sissors | 13:0e21ffc6cb84 | 3 | #include "mbed.h" |
Sissors | 13:0e21ffc6cb84 | 4 | #include "pinmap.h" |
Sissors | 13:0e21ffc6cb84 | 5 | |
Sissors | 13:0e21ffc6cb84 | 6 | typedef struct { |
Sissors | 13:0e21ffc6cb84 | 7 | uint32_t mask; |
Sissors | 13:0e21ffc6cb84 | 8 | } fastio_vars; |
Sissors | 13:0e21ffc6cb84 | 9 | |
Sissors | 13:0e21ffc6cb84 | 10 | #define PINMASK (1 << STM_PIN(pin)) |
Sissors | 13:0e21ffc6cb84 | 11 | #define PORT ((GPIO_TypeDef *)(GPIOA_BASE + 0x0400 * STM_PORT(pin))) |
Sissors | 13:0e21ffc6cb84 | 12 | |
Sissors | 13:0e21ffc6cb84 | 13 | #define INIT_PIN RCC->AHB1ENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK |
Sissors | 13:0e21ffc6cb84 | 14 | #define DESTROY_PIN |
Sissors | 13:0e21ffc6cb84 | 15 | |
Sissors | 13:0e21ffc6cb84 | 16 | #define SET_DIR_INPUT (PORT->MODER &= ~(GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2))) |
Sissors | 13:0e21ffc6cb84 | 17 | #define SET_DIR_OUTPUT (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2))) |
Sissors | 13:0e21ffc6cb84 | 18 | #define SET_MODE(pull) pin_mode(pin, pull); |
Sissors | 13:0e21ffc6cb84 | 19 | |
Sissors | 13:0e21ffc6cb84 | 20 | #define WRITE_PIN_SET (PORT->BSRRL = PINMASK) |
Sissors | 13:0e21ffc6cb84 | 21 | #define WRITE_PIN_CLR (PORT->BSRRH = PINMASK) |
Sissors | 13:0e21ffc6cb84 | 22 | |
Sissors | 13:0e21ffc6cb84 | 23 | #define READ_PIN ((PORT->IDR & container.mask) ? 1 : 0) |
Sissors | 13:0e21ffc6cb84 | 24 | |
Sissors | 13:0e21ffc6cb84 | 25 | #endif |