projet_pololu_et5_ees
Fork of FastIO by
Devices/FastIO_NRF51822.h@20:ed72895a2402, 2016-05-17 (annotated)
- Committer:
- Sissors
- Date:
- Tue May 17 20:06:23 2016 +0000
- Revision:
- 20:ed72895a2402
Initial version for the NRF51822. I am reasonably sure it works, but with lacking an LED on my board or a logic analyzer it might have issues :).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 20:ed72895a2402 | 1 | #ifdef TARGET_MCU_NRF51822 |
Sissors | 20:ed72895a2402 | 2 | |
Sissors | 20:ed72895a2402 | 3 | #include "mbed.h" |
Sissors | 20:ed72895a2402 | 4 | #include "gpio_api.h" |
Sissors | 20:ed72895a2402 | 5 | |
Sissors | 20:ed72895a2402 | 6 | typedef struct { |
Sissors | 20:ed72895a2402 | 7 | uint32_t mask; |
Sissors | 20:ed72895a2402 | 8 | } fastio_vars; |
Sissors | 20:ed72895a2402 | 9 | |
Sissors | 20:ed72895a2402 | 10 | #define PINMASK (1 << pin) |
Sissors | 20:ed72895a2402 | 11 | |
Sissors | 20:ed72895a2402 | 12 | |
Sissors | 20:ed72895a2402 | 13 | #define INIT_PIN container.mask = PINMASK; NRF_GPIO->PIN_CNF[pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ |
Sissors | 20:ed72895a2402 | 14 | | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) \ |
Sissors | 20:ed72895a2402 | 15 | | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) \ |
Sissors | 20:ed72895a2402 | 16 | | (NRF_GPIO->PIN_CNF[pin] & 0x01); |
Sissors | 20:ed72895a2402 | 17 | #define DESTROY_PIN |
Sissors | 20:ed72895a2402 | 18 | |
Sissors | 20:ed72895a2402 | 19 | #define SET_DIR_INPUT NRF_GPIO->DIRCLR = PINMASK |
Sissors | 20:ed72895a2402 | 20 | #define SET_DIR_OUTPUT NRF_GPIO->DIRSET = PINMASK |
Sissors | 20:ed72895a2402 | 21 | #define SET_MODE(pull) NRF_GPIO->PIN_CNF[pin] = (NRF_GPIO->PIN_CNF[pin] & (~GPIO_PIN_CNF_PULL_Msk)) | pull |
Sissors | 20:ed72895a2402 | 22 | |
Sissors | 20:ed72895a2402 | 23 | #define WRITE_PIN_SET NRF_GPIO->OUTSET = PINMASK |
Sissors | 20:ed72895a2402 | 24 | #define WRITE_PIN_CLR NRF_GPIO->OUTCLR = PINMASK |
Sissors | 20:ed72895a2402 | 25 | |
Sissors | 20:ed72895a2402 | 26 | #define READ_PIN ((NRF_GPIO->IN & container.mask) ? 1 : 0) |
Sissors | 20:ed72895a2402 | 27 | |
Sissors | 20:ed72895a2402 | 28 | #endif |