Skip to content

Commit 76c1830

Browse files
authored
Add gpio_deinit (earlephilhower#793)
1 parent c66a2c1 commit 76c1830

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/rp2_common/hardware_gpio/gpio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ void gpio_init(uint gpio) {
217217
gpio_set_function(gpio, GPIO_FUNC_SIO);
218218
}
219219

220+
void gpio_deinit(uint gpio) {
221+
gpio_set_function(gpio, GPIO_FUNC_NULL);
222+
}
223+
220224
void gpio_init_mask(uint gpio_mask) {
221225
for(uint i=0;i<32;i++) {
222226
if (gpio_mask & 1) {

src/rp2_common/hardware_gpio/include/hardware/gpio.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ void gpio_acknowledge_irq(uint gpio, uint32_t events);
414414
*/
415415
void gpio_init(uint gpio);
416416

417+
/*! \brief Resets a GPIO back to the NULL function, i.e. disables it.
418+
* \ingroup hardware_gpio
419+
*
420+
* \param gpio GPIO number
421+
*/
422+
void gpio_deinit(uint gpio);
423+
417424
/*! \brief Initialise multiple GPIOs (enabled I/O and set func to GPIO_FUNC_SIO)
418425
* \ingroup hardware_gpio
419426
*

0 commit comments

Comments
 (0)