Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed. (modified for use opendrain in stm32)
Fork of FastIO by
Devices/FastIO_K20D50M.h@4:6ebbf25b9167, 2014-07-16 (annotated)
- Committer:
- Sissors
- Date:
- Wed Jul 16 19:31:35 2014 +0000
- Revision:
- 4:6ebbf25b9167
- Parent:
- FastIO_K20D50M.h@3:3dd9466e73fc
First Nucleo, first version added: F401RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 3:3dd9466e73fc | 1 | #ifdef TARGET_K20D50M |
Sissors | 3:3dd9466e73fc | 2 | |
Sissors | 3:3dd9466e73fc | 3 | #include "mbed.h" |
Sissors | 3:3dd9466e73fc | 4 | #include "pinmap.h" |
Sissors | 3:3dd9466e73fc | 5 | |
Sissors | 3:3dd9466e73fc | 6 | typedef struct { |
Sissors | 3:3dd9466e73fc | 7 | uint32_t mask; |
Sissors | 3:3dd9466e73fc | 8 | } fastio_vars; |
Sissors | 3:3dd9466e73fc | 9 | |
Sissors | 3:3dd9466e73fc | 10 | #define PORT_BASE ((GPIO_Type *)(PTA_BASE + ((unsigned int)pin >> PORT_SHIFT) * 0x40)) |
Sissors | 3:3dd9466e73fc | 11 | #define PINMASK (1 << ((pin & 0x7F) >> 2)) |
Sissors | 3:3dd9466e73fc | 12 | #define PCR ((__IO uint32_t*)(PORTA_BASE + pin)) |
Sissors | 3:3dd9466e73fc | 13 | |
Sissors | 3:3dd9466e73fc | 14 | #define INIT_PIN container.mask = PINMASK; pin_function(pin, 1) |
Sissors | 3:3dd9466e73fc | 15 | #define DESTROY_PIN |
Sissors | 3:3dd9466e73fc | 16 | |
Sissors | 3:3dd9466e73fc | 17 | #define SET_DIR_INPUT (PORT_BASE->PDDR &= ~PINMASK) |
Sissors | 3:3dd9466e73fc | 18 | #define SET_DIR_OUTPUT (PORT_BASE->PDDR |= PINMASK) |
Sissors | 3:3dd9466e73fc | 19 | #define SET_MODE(pull) (*PCR = (*PCR & ~0x3) | pull) |
Sissors | 3:3dd9466e73fc | 20 | |
Sissors | 3:3dd9466e73fc | 21 | #define WRITE_PIN_SET (PORT_BASE->PSOR |= container.mask) |
Sissors | 3:3dd9466e73fc | 22 | #define WRITE_PIN_CLR (PORT_BASE->PCOR |= container.mask) |
Sissors | 3:3dd9466e73fc | 23 | |
Sissors | 3:3dd9466e73fc | 24 | #define READ_PIN ((PORT_BASE->PDIR & container.mask) ? 1 : 0) |
Sissors | 3:3dd9466e73fc | 25 | |
Sissors | 3:3dd9466e73fc | 26 | #endif |