projet_pololu_et5_ees
Fork of FastIO by
Devices/FastIO_LPC43XX.h@23:6b6ea8ba43e3, 2018-03-09 (annotated)
- Committer:
- lesuperguerrier
- Date:
- Fri Mar 09 10:03:26 2018 +0000
- Revision:
- 23:6b6ea8ba43e3
- Parent:
- 19:89d6ae484a35
projet_pololu_et5_ees
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nameless129 | 19:89d6ae484a35 | 1 | #ifdef TARGET_LPC43XX |
nameless129 | 19:89d6ae484a35 | 2 | |
nameless129 | 19:89d6ae484a35 | 3 | #include "mbed.h" |
nameless129 | 19:89d6ae484a35 | 4 | #include "pinmap.h" |
nameless129 | 19:89d6ae484a35 | 5 | |
nameless129 | 19:89d6ae484a35 | 6 | typedef struct { |
nameless129 | 19:89d6ae484a35 | 7 | uint32_t mask; |
nameless129 | 19:89d6ae484a35 | 8 | } fastio_vars; |
nameless129 | 19:89d6ae484a35 | 9 | |
nameless129 | 19:89d6ae484a35 | 10 | #define PORT (((unsigned int)pin >> PORT_SHIFT) & 0x0000000F) |
nameless129 | 19:89d6ae484a35 | 11 | #define PINMASK (1 << ((int)pin & 0x1F)) |
nameless129 | 19:89d6ae484a35 | 12 | static inline void initpin(PinName pin); |
nameless129 | 19:89d6ae484a35 | 13 | |
nameless129 | 19:89d6ae484a35 | 14 | #define INIT_PIN container.mask = PINMASK; initpin(pin) |
nameless129 | 19:89d6ae484a35 | 15 | #define DESTROY_PIN |
nameless129 | 19:89d6ae484a35 | 16 | |
nameless129 | 19:89d6ae484a35 | 17 | #define SET_DIR_INPUT ( ((LPC_GPIO_T *)(LPC_GPIO_PORT_BASE))->DIR[PORT] &= ~PINMASK ) |
nameless129 | 19:89d6ae484a35 | 18 | #define SET_DIR_OUTPUT ( ((LPC_GPIO_T *)(LPC_GPIO_PORT_BASE))->DIR[PORT] |= PINMASK ) |
nameless129 | 19:89d6ae484a35 | 19 | #define SET_MODE(pull) (pin_mode(pin, pull)) |
nameless129 | 19:89d6ae484a35 | 20 | |
nameless129 | 19:89d6ae484a35 | 21 | #define WRITE_PIN_SET ( ((LPC_GPIO_T *)(LPC_GPIO_PORT_BASE))->SET[PORT] = PINMASK ) |
nameless129 | 19:89d6ae484a35 | 22 | #define WRITE_PIN_CLR ( ((LPC_GPIO_T *)(LPC_GPIO_PORT_BASE))->CLR[PORT] = PINMASK ) |
nameless129 | 19:89d6ae484a35 | 23 | |
nameless129 | 19:89d6ae484a35 | 24 | #define READ_PIN ( (((LPC_GPIO_T *)(LPC_GPIO_PORT_BASE))->PIN[PORT] & container.mask) ? 1 : 0 ) |
nameless129 | 19:89d6ae484a35 | 25 | |
nameless129 | 19:89d6ae484a35 | 26 | static inline void initpin(PinName pin) { |
nameless129 | 19:89d6ae484a35 | 27 | unsigned int port = (unsigned int)MBED_GPIO_PORT(pin); |
nameless129 | 19:89d6ae484a35 | 28 | int f = SCU_PINIO_FAST | ((port > 4) ? (4) : (0)); |
nameless129 | 19:89d6ae484a35 | 29 | pin_function(pin, f); |
nameless129 | 19:89d6ae484a35 | 30 | } |
nameless129 | 19:89d6ae484a35 | 31 | |
nameless129 | 19:89d6ae484a35 | 32 | #endif |