Beispiel #1
0
/* This is a callback function. It is called when button is pressed or released. */
void pushbutton_cb(int pin, void *data)
{
    if (pin == button_1 && button1_sem != 0)
    {
        os_semaphore_put(&button1_sem);
    }

    if (pin == button_2 && button2_sem != 0)
    {
        os_semaphore_put(&button2_sem);
    }
}
static void button_1_press_handle(GPIO_IO_Type pin_level)
{
    if (pin_level == GPIO_IO_LOW) {
        LOG_INFO("button pressed\r\n");

        if (os_timer_is_running(&g_reset_prov_timer)) {
            if (WM_SUCCESS != os_timer_deactivate(&g_reset_prov_timer)) {
                LOG_ERROR("deactivating reset provision timer failed\r\n");
            }
        }
		
        if(WM_SUCCESS != os_timer_activate(&g_reset_prov_timer)) {
			LOG_ERROR("activating reset provision timer failed\r\n");
		}

    } else {
        LOG_INFO("button released\r\n");
        os_semaphore_put(&btn_pressed_sem);

        if (os_timer_is_running(&g_reset_prov_timer)) {
            if (WM_SUCCESS != os_timer_deactivate(&g_reset_prov_timer)) {
                LOG_ERROR("deactivating reset provision timer failed\r\n");
            }
        }
    }
}