41 #include <hal/nrf_gpio.h> 42 #include <hal/nrf_gpiote.h> 62 #define GPIO_PIN_ID_WIDTH (6) 63 #define GPIO_PIN_NC (32UL) 75 return (Pin | (Pin << 26)) ;
83 extern const struct port_init_t PortInitTable[32];
84 extern const uint32_t PortInitValue;
86 #if defined(DRIVER_PORT_INIT_TABLE) 90 #define GPIO_PIN_CNF(Direction, Input, Pull, Drive) \ 91 (((Direction) << GPIO_PIN_CNF_DIR_Pos) \ 92 | ((Input) << GPIO_PIN_CNF_INPUT_Pos) \ 93 | ((Pull) << GPIO_PIN_CNF_PULL_Pos) \ 94 | ((Drive) << GPIO_PIN_CNF_DRIVE_Pos)) 101 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Disconnect,
102 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_S0S1),
106 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Disconnect,
107 GPIO_PIN_CNF_PULL_Pulldown, GPIO_PIN_CNF_DRIVE_S0S1),
111 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Disconnect,
112 GPIO_PIN_CNF_PULL_Pullup, GPIO_PIN_CNF_DRIVE_S0S1),
116 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Connect,
117 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_S0S1),
121 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Connect,
122 GPIO_PIN_CNF_PULL_Pulldown, GPIO_PIN_CNF_DRIVE_S0S1),
126 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Input, GPIO_PIN_CNF_INPUT_Connect,
127 GPIO_PIN_CNF_PULL_Pullup, GPIO_PIN_CNF_DRIVE_S0S1),
131 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
132 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_S0S1),
136 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
137 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_H0H1),
141 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
142 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_D0S1),
146 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
147 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_D0H1),
151 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
152 GPIO_PIN_CNF_PULL_Pulldown, GPIO_PIN_CNF_DRIVE_D0S1),
156 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
157 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_S0D1),
161 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
162 GPIO_PIN_CNF_PULL_Pullup, GPIO_PIN_CNF_DRIVE_S0D1),
166 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
167 GPIO_PIN_CNF_PULL_Disabled, GPIO_PIN_CNF_DRIVE_H0D1),
171 = GPIO_PIN_CNF(GPIO_PIN_CNF_DIR_Output, GPIO_PIN_CNF_INPUT_Connect,
172 GPIO_PIN_CNF_PULL_Pullup, GPIO_PIN_CNF_DRIVE_H0D1),
198 NRF_GPIO->PIN_CNF[Pin] = Mode;
211 return nrf_gpio_pin_read(Pin);
223 nrf_gpio_pin_clear(Pin);
235 nrf_gpio_pin_set(Pin);
247 nrf_gpio_pin_toggle(Pin);
260 nrf_gpio_pin_write(Pin, Value);
272 return nrf_gpio_pins_read();
284 nrf_gpio_pins_clear(Mask);
296 nrf_gpio_pins_set(Mask);
308 nrf_gpio_pins_toggle(Mask);
321 NRF_GPIO->OUTSET = (Mask & Value);
322 NRF_GPIO->OUTCLR = (Mask & ~Value);
337 extern uint32_t
GpioGetDebouncedInput(uint32_t BitMask, uint32_t BitInvert, uint8_t Count, uint8_t ShiftRightCount);
344 #endif //DRIVER_GPIO_H static void GpioPinSet(unsigned Pin)
Name: GpioPinSet Sets the pad value for a single pin in a GPIO port to 1.
Port init table generator.
static void GpioPinToggle(unsigned Pin)
Name: GpioPinToggle Toggles a single pin in a GPIO port.
static void GpioPinConfig(unsigned Pin, enum gpio_mode_t Mode)
Name: GpioPinConfig Configures a GPIO pin to the desired mode, sets value for the pin...
static void GpioPortClear(uint32_t Mask)
Name: GpioPortClear Sets the pad values for pins specified by a mask to 0.
static uint32_t GpioPortGet(void)
Name: GpioPortGet Reads the pad values for all the pins in a GPIO port.
static uint32_t GpioUnpackPin(uint32_t Pin)
Name: GpioUnpackPin Converts packed pin number to the format, accepted by hardware blocks...
static bool GpioPinGet(unsigned Pin)
Name: GpioPinGet Reads the pad value for a single pin in a GPIO port.
static void GpioPortSet(uint32_t Mask)
Name: GpioPortSet Sets the pad values for pins specified by a mask to 1.
void GpioInit(void)
Name: GpioInit Initializes ports to default values based on port-init.h.
uint32_t GpioGetDebouncedInput(uint32_t BitMask, uint32_t BitInvert, uint8_t Count, uint8_t ShiftRightCount)
Name: GpioGetDebouncedInput Reads and debounces input pins.
static void GpioPortToggle(uint32_t Mask)
Name: GpioPortToggle Toggles pins specified by a mask in a GPIO port.
static void GpioPortSetValue(uint32_t Value, uint32_t Mask)
Name: GpioPortSetValue Sets the pad value for a single pin in a GPIO port to the value provided...
static void GpioPinClear(unsigned Pin)
Name: GpioPinClear Sets the pad value for a single pin in a GPIO port to 0.
static void GpioPinSetValue(unsigned Pin, bool Value)
Name: GpioPinSetValue Sets the pad value for a single pin in a GPIO port to the value provided...