add LPC4337
Fork of FastIO by
Devices/FastIO_LPC11U6X.h@19:89d6ae484a35, 2016-02-05 (annotated)
- Committer:
- nameless129
- Date:
- Fri Feb 05 14:47:23 2016 +0000
- Revision:
- 19:89d6ae484a35
- Parent:
- 18:c95920122b2e
Added LPC43XX(4337)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nameless129 | 18:c95920122b2e | 1 | #ifdef TARGET_LPC11U6X |
nameless129 | 18:c95920122b2e | 2 | |
nameless129 | 18:c95920122b2e | 3 | #include "mbed.h" |
nameless129 | 18:c95920122b2e | 4 | #include "pinmap.h" |
nameless129 | 18:c95920122b2e | 5 | |
nameless129 | 18:c95920122b2e | 6 | typedef struct { |
nameless129 | 18:c95920122b2e | 7 | uint32_t mask; |
nameless129 | 18:c95920122b2e | 8 | } fastio_vars; |
nameless129 | 18:c95920122b2e | 9 | |
nameless129 | 18:c95920122b2e | 10 | #define PORT ((unsigned int)pin >> PORT_SHIFT) |
nameless129 | 18:c95920122b2e | 11 | #define PINMASK ( 1 << ((int)pin >> PIN_SHIFT & 0x1F) ) |
nameless129 | 18:c95920122b2e | 12 | static inline void initpin(PinName pin); |
nameless129 | 18:c95920122b2e | 13 | |
nameless129 | 18:c95920122b2e | 14 | #define INIT_PIN container.mask = PINMASK; initpin(pin) |
nameless129 | 18:c95920122b2e | 15 | #define DESTROY_PIN |
nameless129 | 18:c95920122b2e | 16 | |
nameless129 | 18:c95920122b2e | 17 | #define SET_DIR_INPUT (LPC_GPIO_PORT->DIR[PORT] &= ~PINMASK) |
nameless129 | 18:c95920122b2e | 18 | #define SET_DIR_OUTPUT (LPC_GPIO_PORT->DIR[PORT] |= PINMASK) |
nameless129 | 18:c95920122b2e | 19 | #define SET_MODE(pull) (pin_mode(pin, pull)) |
nameless129 | 18:c95920122b2e | 20 | |
nameless129 | 18:c95920122b2e | 21 | #define WRITE_PIN_SET (LPC_GPIO_PORT->SET[PORT] = PINMASK) |
nameless129 | 18:c95920122b2e | 22 | #define WRITE_PIN_CLR (LPC_GPIO_PORT->CLR[PORT] = PINMASK) |
nameless129 | 18:c95920122b2e | 23 | |
nameless129 | 18:c95920122b2e | 24 | #define READ_PIN ((LPC_GPIO_PORT->PIN[PORT] & container.mask) ? 1 : 0) |
nameless129 | 18:c95920122b2e | 25 | |
nameless129 | 18:c95920122b2e | 26 | static inline void initpin(PinName pin) { |
nameless129 | 18:c95920122b2e | 27 | int f = ((pin == P0_0) || |
nameless129 | 18:c95920122b2e | 28 | (pin == P0_10) || |
nameless129 | 18:c95920122b2e | 29 | (pin == P0_11) || |
nameless129 | 18:c95920122b2e | 30 | (pin == P0_12) || |
nameless129 | 18:c95920122b2e | 31 | (pin == P0_13) || |
nameless129 | 18:c95920122b2e | 32 | (pin == P0_14) || |
nameless129 | 18:c95920122b2e | 33 | (pin == P0_15)) ? (1) : (0); |
nameless129 | 18:c95920122b2e | 34 | pin_function(pin, f); |
nameless129 | 18:c95920122b2e | 35 | } |
nameless129 | 18:c95920122b2e | 36 | |
nameless129 | 18:c95920122b2e | 37 | #endif |