uint32_t app_gpiote_user_disable(app_gpiote_user_id_t user_id)
{
    // Check state and parameters.
    if (mp_users == NULL)
    {
				printf("app_gpiote_user_disable\r\n");  				
        return NRF_ERROR_INVALID_STATE;
    }
    if (user_id >= m_user_count)
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    
    // Disable sensing for all pins for specified user.
    pins_sense_disable(user_id);

    // Disable user.
    m_enabled_users_mask &= ~(1UL << user_id);
    if (m_enabled_users_mask == 0)
    {
        NRF_GPIOTE->INTENCLR = GPIOTE_INTENSET_PORT_Msk;
    }
    
    return NRF_SUCCESS;
}
uint32_t app_gpiote_user_register(app_gpiote_user_id_t *     p_user_id,
                                  uint32_t                   pins_low_to_high_mask,
                                  uint32_t                   pins_high_to_low_mask,
                                  app_gpiote_event_handler_t event_handler)
{
    // Check state and parameters.
    if (mp_users == NULL)
    {
#ifdef  DEBUG_LOG
				printf("app_gpiote_user_register\r\n"); 
#endif			
        return NRF_ERROR_INVALID_STATE;
    }
    if (event_handler == NULL)
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    if (m_user_count >= m_user_array_size)
    {
        return NRF_ERROR_NO_MEM;
    }
    
    // Allocate new user.
    mp_users[m_user_count].pins_mask             = pins_low_to_high_mask | pins_high_to_low_mask;
    mp_users[m_user_count].pins_low_to_high_mask = pins_low_to_high_mask;
    mp_users[m_user_count].pins_high_to_low_mask = pins_high_to_low_mask;
    mp_users[m_user_count].event_handler         = event_handler;
    
    *p_user_id = m_user_count++;
    
    // Make sure SENSE is disabled for all pins.
    pins_sense_disable(*p_user_id);
    
    return NRF_SUCCESS;
}
uint32_t app_gpiote_user_register(app_gpiote_user_id_t *     p_user_id,
                                  uint32_t                   pins_low_to_high_mask,
                                  uint32_t                   pins_high_to_low_mask,
                                  app_gpiote_event_handler_t event_handler)
{
    //Check state and parameters.
    VERIFY_MODULE_INITIALIZED();

    if (event_handler == NULL)
    {
        return NRF_ERROR_INVALID_PARAM;
    }

    if (m_user_count >= m_user_array_size)
    {
        return NRF_ERROR_NO_MEM;
    }

    //Allocate new user.
    mp_users[m_user_count].pins_mask             = pins_low_to_high_mask | pins_high_to_low_mask;
    mp_users[m_user_count].pins_low_to_high_mask = pins_low_to_high_mask;
    mp_users[m_user_count].pins_high_to_low_mask = pins_high_to_low_mask;
    mp_users[m_user_count].event_handler         = event_handler;

    *p_user_id = m_user_count++;

    //Make sure SENSE is disabled for all pins.
    pins_sense_disable(*p_user_id);

    return NRF_SUCCESS;
}
uint32_t app_gpiote_user_disable(app_gpiote_user_id_t user_id)
{
    //Check state and parameters.
    VERIFY_MODULE_INITIALIZED();

    if (user_id >= m_user_count)
    {
        return NRF_ERROR_INVALID_PARAM;
    }

    //Disable sensing for all pins for specified user.
    pins_sense_disable(user_id);

    //Disable user.
    m_enabled_users_mask &= ~(1UL << user_id);

    if (m_enabled_users_mask == 0)
    {
        NRF_GPIOTE->INTENCLR = GPIOTE_INTENSET_PORT_Msk;
    }

    return NRF_SUCCESS;
}