From d2f9544556b13b26e3315e531ff44a576ff0d17f Mon Sep 17 00:00:00 2001 From: Matias N Date: Wed, 20 Jan 2021 18:29:23 -0300 Subject: [PATCH] nRF52 GPIO: tiny optimization, do not decode PORT when no PORT1 --- arch/arm/src/nrf52/nrf52_gpio.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/nrf52/nrf52_gpio.c b/arch/arm/src/nrf52/nrf52_gpio.c index 83e70b038b6..aa4fda9ece5 100644 --- a/arch/arm/src/nrf52/nrf52_gpio.c +++ b/arch/arm/src/nrf52/nrf52_gpio.c @@ -269,14 +269,17 @@ static inline void nrf52_gpio_drive(nrf52_pinset_t cfgset, int nrf52_gpio_config(nrf52_pinset_t cfgset) { - unsigned int port; + unsigned int port = 0; unsigned int pin; irqstate_t flags; int ret = OK; /* Verify that this hardware supports the select GPIO port */ +#ifdef CONFIG_NRF52_HAVE_PORT1 port = (cfgset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; +#endif + if (port < NRF52_GPIO_NPORTS) { /* Get the pin number and select the port configuration register for @@ -341,13 +344,15 @@ int nrf52_gpio_config(nrf52_pinset_t cfgset) int nrf52_gpio_unconfig(nrf52_pinset_t cfgset) { unsigned int pin; - unsigned int port; + unsigned int port = 0; uint32_t offset; /* Get port and pin number */ pin = GPIO_PIN_DECODE(cfgset); +#ifdef CONFIG_NRF52_HAVE_PORT1 port = GPIO_PORT_DECODE(cfgset); +#endif /* Get address offset */ @@ -371,13 +376,15 @@ int nrf52_gpio_unconfig(nrf52_pinset_t cfgset) void nrf52_gpio_write(nrf52_pinset_t pinset, bool value) { unsigned int pin; - unsigned int port; + unsigned int port = 0; uint32_t offset; /* Get port and pin number */ pin = GPIO_PIN_DECODE(pinset); +#ifdef CONFIG_NRF52_HAVE_PORT1 port = GPIO_PORT_DECODE(pinset); +#endif /* Get register address */