/* Function for toggling sense level for specified pins.  */
static void sense_level_toggle(gpiote_user_t *p_user, uint32_t pins)
/* Function for toggling sense level for specified pins.  */
static void sense_level_toggle(gpiote_user_t *p_user, uint32_t pins)
{
    uint32_t pin_no;
    for (pin_no = 0; pin_no < NO_OF_PINS; pin_no++)
    {
        uint32_t pin_mask = (1 << pin_no);
        if ((pins & pin_mask) != 0)
        {
            uint32_t sense;
            if ((p_user->sense_high_pins & pin_mask) == 0)
            {
                sense                    = GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos;
                p_user->sense_high_pins |= pin_mask;
            }
            else
            {
                sense                    = GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos;
                p_user->sense_high_pins &= ~pin_mask;
            }
            NRF_GPIO->PIN_CNF[pin_no] &= ~GPIO_PIN_CNF_SENSE_Msk;
            NRF_GPIO->PIN_CNF[pin_no] |= sense;
        }
    }
}