Skip to content

Commit a386b22

Browse files
gmarullmasz-nordic
authored andcommitted
nrfx: hal: gpio: add nrf_gpio_port_retain_enable/disable
So we can set/clear retention status in a single atomic write. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 46bf084 commit a386b22

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

nrfx/hal/nrf_gpio.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ extern "C" {
149149
#define NRF_GPIO_HAS_RETENTION 0
150150
#endif
151151

152+
#if (defined(GPIO_RETAINSET_ResetValue) && defined(GPIO_RETAINCLR_ResetValue)) || \
153+
defined(__NRFX_DOXYGEN__)
154+
/** @brief Presence of register retention set/clear. */
155+
#define NRF_GPIO_HAS_RETENTION_SETCLEAR 1
156+
#else
157+
#define NRF_GPIO_HAS_RETENTION_SETCLEAR 0
158+
#endif
159+
152160
#if defined(GPIO_DETECTMODE_DETECTMODE_Msk) || defined(__NRFX_DOXYGEN__)
153161
/** @brief Presence of detect mode. */
154162
#define NRF_GPIO_HAS_DETECT_MODE 1
@@ -750,6 +758,25 @@ NRF_STATIC_INLINE void nrf_gpio_port_retain_set(NRF_GPIO_Type * p_reg, uint32_t
750758
NRF_STATIC_INLINE uint32_t nrf_gpio_port_retain_get(NRF_GPIO_Type const * p_reg);
751759
#endif
752760

761+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
762+
/**
763+
* @brief Function for enabling the retention of the registers.
764+
*
765+
* @param p_reg Pointer to the structure of registers of the peripheral.
766+
* @param mask Mask of pins to have retention enabled, created using @ref nrf_gpio_retain_mask_t.
767+
*/
768+
NRF_STATIC_INLINE void nrf_gpio_port_retain_enable(NRF_GPIO_Type * p_reg, uint32_t mask);
769+
770+
/**
771+
* @brief Function for disabling the retention of the registers.
772+
*
773+
* @param p_reg Pointer to the structure of registers of the peripheral.
774+
* @param mask Mask of pins to have retention be disabled, created using @ref nrf_gpio_retain_mask_t.
775+
*/
776+
NRF_STATIC_INLINE void nrf_gpio_port_retain_disable(NRF_GPIO_Type * p_reg, uint32_t mask);
777+
#endif
778+
779+
753780
#if NRF_GPIO_HAS_DETECT_MODE
754781
/**
755782
* @brief Function for setting the latched detect behaviour.
@@ -1319,6 +1346,18 @@ NRF_STATIC_INLINE uint32_t nrf_gpio_port_retain_get(NRF_GPIO_Type const * p_reg)
13191346
}
13201347
#endif
13211348

1349+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
1350+
NRF_STATIC_INLINE void nrf_gpio_port_retain_enable(NRF_GPIO_Type * p_reg, uint32_t mask)
1351+
{
1352+
p_reg->RETAINSET = mask;
1353+
}
1354+
1355+
NRF_STATIC_INLINE void nrf_gpio_port_retain_disable(NRF_GPIO_Type * p_reg, uint32_t mask)
1356+
{
1357+
p_reg->RETAINCLR = mask;
1358+
}
1359+
#endif
1360+
13221361
#if NRF_GPIO_HAS_DETECT_MODE
13231362
NRF_STATIC_INLINE void nrf_gpio_port_detect_latch_set(NRF_GPIO_Type * p_reg, bool enable)
13241363
{

0 commit comments

Comments
 (0)