projet_pololu_et5_ees
Fork of FastIO by
Devices/FastIO_LPC11XX.h@23:6b6ea8ba43e3, 2018-03-09 (annotated)
- Committer:
- lesuperguerrier
- Date:
- Fri Mar 09 10:03:26 2018 +0000
- Revision:
- 23:6b6ea8ba43e3
- Parent:
- 7:1e784ae11fba
projet_pololu_et5_ees
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 7:1e784ae11fba | 1 | #ifdef TARGET_LPC11XX_11CXX |
Sissors | 7:1e784ae11fba | 2 | |
Sissors | 7:1e784ae11fba | 3 | #include "mbed.h" |
Sissors | 7:1e784ae11fba | 4 | #include "pinmap.h" |
Sissors | 7:1e784ae11fba | 5 | #include "reserved_pins.h" |
Sissors | 7:1e784ae11fba | 6 | |
Sissors | 7:1e784ae11fba | 7 | typedef struct { |
Sissors | 7:1e784ae11fba | 8 | } fastio_vars; |
Sissors | 7:1e784ae11fba | 9 | |
Sissors | 7:1e784ae11fba | 10 | #define PORT ((LPC_GPIO_TypeDef *) (LPC_GPIO0_BASE + (((pin & 0xF000) >> PORT_SHIFT) * 0x10000))) |
Sissors | 7:1e784ae11fba | 11 | #define PIN ((pin & 0x0F00) >> 8 ) |
Sissors | 7:1e784ae11fba | 12 | #define MASKDATA (*((volatile uint32_t*) ((uint32_t)PORT + (1 << (PIN + 2))))) |
Sissors | 7:1e784ae11fba | 13 | static inline void initpin(PinName pin); |
Sissors | 7:1e784ae11fba | 14 | static const PinName reserved_pins[] = TARGET_RESERVED_PINS; |
Sissors | 7:1e784ae11fba | 15 | |
Sissors | 7:1e784ae11fba | 16 | #define INIT_PIN initpin(pin) |
Sissors | 7:1e784ae11fba | 17 | #define DESTROY_PIN |
Sissors | 7:1e784ae11fba | 18 | |
Sissors | 7:1e784ae11fba | 19 | #define SET_DIR_INPUT (PORT->DIR &= ~(1 << PIN)) |
Sissors | 7:1e784ae11fba | 20 | #define SET_DIR_OUTPUT (PORT->DIR |= (1<<PIN)) |
Sissors | 7:1e784ae11fba | 21 | #define SET_MODE(pull) (pin_mode(pin, pull)) |
Sissors | 7:1e784ae11fba | 22 | |
Sissors | 7:1e784ae11fba | 23 | #define WRITE_PIN_SET (MASKDATA = 0xFFFF) |
Sissors | 7:1e784ae11fba | 24 | #define WRITE_PIN_CLR (MASKDATA = 0) |
Sissors | 7:1e784ae11fba | 25 | |
Sissors | 7:1e784ae11fba | 26 | #define READ_PIN ((MASKDATA == 0) ? 0 : 1) |
Sissors | 7:1e784ae11fba | 27 | |
Sissors | 7:1e784ae11fba | 28 | static inline void initpin(PinName pin) { |
Sissors | 7:1e784ae11fba | 29 | unsigned i; |
Sissors | 7:1e784ae11fba | 30 | int f = 0; |
Sissors | 7:1e784ae11fba | 31 | |
Sissors | 7:1e784ae11fba | 32 | for (i = 0; i < sizeof(reserved_pins) / sizeof(PinName); i ++) { |
Sissors | 7:1e784ae11fba | 33 | if (pin == reserved_pins[i]) { |
Sissors | 7:1e784ae11fba | 34 | f = 1; |
Sissors | 7:1e784ae11fba | 35 | break; |
Sissors | 7:1e784ae11fba | 36 | } |
Sissors | 7:1e784ae11fba | 37 | } |
Sissors | 7:1e784ae11fba | 38 | pin_function(pin, f); |
Sissors | 7:1e784ae11fba | 39 | } |
Sissors | 7:1e784ae11fba | 40 | |
Sissors | 7:1e784ae11fba | 41 | #endif |