Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed. (modified for use opendrain in stm32)

Dependents:   hctl2032_encoder

Fork of FastIO by Erik -

Committer:
Sissors
Date:
Fri Jul 04 17:28:45 2014 +0000
Revision:
2:1a6ed4b84590
Parent:
0:d394ebd01052
Added support for unsupported targets :P

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 0:d394ebd01052 1 #ifdef TARGET_KLXX
Sissors 0:d394ebd01052 2
Sissors 0:d394ebd01052 3 #include "mbed.h"
Sissors 0:d394ebd01052 4 #include "pinmap.h"
Sissors 0:d394ebd01052 5
Sissors 0:d394ebd01052 6 typedef struct {
Sissors 0:d394ebd01052 7 uint32_t mask;
Sissors 0:d394ebd01052 8 } fastio_vars;
Sissors 0:d394ebd01052 9
Sissors 0:d394ebd01052 10 #define PORT_BASE ((FGPIO_Type *)(FPTA_BASE + ((unsigned int)pin >> PORT_SHIFT) * 0x40))
Sissors 0:d394ebd01052 11 #define PINMASK (1 << ((pin & 0x7F) >> 2))
Sissors 0:d394ebd01052 12 #define PCR ((__IO uint32_t*)(PORTA_BASE + pin))
Sissors 0:d394ebd01052 13
Sissors 0:d394ebd01052 14 #define INIT_PIN container.mask = PINMASK; pin_function(pin, 1)
Sissors 2:1a6ed4b84590 15 #define DESTROY_PIN
Sissors 0:d394ebd01052 16
Sissors 0:d394ebd01052 17 #define SET_DIR_INPUT (PORT_BASE->PDDR &= ~PINMASK)
Sissors 0:d394ebd01052 18 #define SET_DIR_OUTPUT (PORT_BASE->PDDR |= PINMASK)
Sissors 0:d394ebd01052 19 #define SET_MODE(pull) (*PCR = (*PCR & ~0x3) | pull)
Sissors 0:d394ebd01052 20
Sissors 0:d394ebd01052 21 #define WRITE_PIN_SET (PORT_BASE->PSOR |= PINMASK)
Sissors 0:d394ebd01052 22 #define WRITE_PIN_CLR (PORT_BASE->PCOR |= PINMASK)
Sissors 0:d394ebd01052 23
Sissors 0:d394ebd01052 24 #define READ_PIN ((PORT_BASE->PDIR & container.mask) ? 1 : 0)
Sissors 0:d394ebd01052 25
Sissors 0:d394ebd01052 26 #endif