Skip to content

Commit 373ae9c

Browse files
gmarullmasz-nordic
authored andcommitted
nrfx: hal: gpio: add pin level retention API
So that we can also operate by passing pin numbers. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent a386b22 commit 373ae9c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

nrfx/hal/nrf_gpio.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ NRF_STATIC_INLINE void nrf_gpio_port_retain_set(NRF_GPIO_Type * p_reg, uint32_t
756756
* @return Mask of retention domains set, created using @ref nrf_gpio_retain_mask_t.
757757
*/
758758
NRF_STATIC_INLINE uint32_t nrf_gpio_port_retain_get(NRF_GPIO_Type const * p_reg);
759+
760+
/**
761+
* @brief Function for checking the retention setting of a pin.
762+
*
763+
* @param pin_number Pin number.
764+
*
765+
* @retval true If pin is retained.
766+
* @retval false If pin is not retained.
767+
*/
768+
NRF_STATIC_INLINE bool nrf_gpio_pin_retain_check(uint32_t pin_number);
759769
#endif
760770

761771
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
@@ -774,6 +784,20 @@ NRF_STATIC_INLINE void nrf_gpio_port_retain_enable(NRF_GPIO_Type * p_reg, uint32
774784
* @param mask Mask of pins to have retention be disabled, created using @ref nrf_gpio_retain_mask_t.
775785
*/
776786
NRF_STATIC_INLINE void nrf_gpio_port_retain_disable(NRF_GPIO_Type * p_reg, uint32_t mask);
787+
788+
/**
789+
* @brief Function for enabling the retention of a pin.
790+
*
791+
* @param pin_number Pin number.
792+
*/
793+
NRF_STATIC_INLINE void nrf_gpio_pin_retain_enable(uint32_t pin_number);
794+
795+
/**
796+
* @brief Function for disabling the retention of a pin.
797+
*
798+
* @param pin_number Pin number.
799+
*/
800+
NRF_STATIC_INLINE void nrf_gpio_pin_retain_disable(uint32_t pin_number);
777801
#endif
778802

779803

@@ -1344,6 +1368,13 @@ NRF_STATIC_INLINE uint32_t nrf_gpio_port_retain_get(NRF_GPIO_Type const * p_reg)
13441368
{
13451369
return p_reg->RETAIN;
13461370
}
1371+
1372+
NRF_STATIC_INLINE bool nrf_gpio_pin_retain_check(uint32_t pin_number)
1373+
{
1374+
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
1375+
1376+
return (nrf_gpio_port_retain_get(reg) & (1UL << pin_number)) != 0U;
1377+
}
13471378
#endif
13481379

13491380
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
@@ -1356,6 +1387,20 @@ NRF_STATIC_INLINE void nrf_gpio_port_retain_disable(NRF_GPIO_Type * p_reg, uint3
13561387
{
13571388
p_reg->RETAINCLR = mask;
13581389
}
1390+
1391+
NRF_STATIC_INLINE void nrf_gpio_pin_retain_enable(uint32_t pin_number)
1392+
{
1393+
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
1394+
1395+
nrf_gpio_port_retain_enable(reg, 1UL << pin_number);
1396+
}
1397+
1398+
NRF_STATIC_INLINE void nrf_gpio_pin_retain_disable(uint32_t pin_number)
1399+
{
1400+
NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number);
1401+
1402+
nrf_gpio_port_retain_disable(reg, 1UL << pin_number);
1403+
}
13591404
#endif
13601405

13611406
#if NRF_GPIO_HAS_DETECT_MODE

0 commit comments

Comments
 (0)