projet_pololu_et5_ees

Fork of FastIO by Erik -

Committer:
lesuperguerrier
Date:
Fri Mar 09 10:03:26 2018 +0000
Revision:
23:6b6ea8ba43e3
Parent:
20:ed72895a2402
projet_pololu_et5_ees

Who changed what in which revision?

UserRevisionLine numberNew 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