C

Qt Quick Ultralite interrupt_handler Example

/****************************************************************************** ** ** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include "board_config.h" #include "interrupt_queue.h" #include "r_typedefs.h" #include "r_bsp_hmi_api.h" #include "r_gpio_api.h" #include "r_bsp_hmi_knob.h" void button_handler() { HWButtonInput::instance().postEventFromInterrupt(0); } static void qulButtonCenterAction(void) { uint8_t level = R_GPIO_ReadIntPin(BSP_BTN_CENTER_INTP); if (level == 0u) { R_BSP_BtnAction(BSP_BTN_CENTER_PRESS); } else { R_BSP_BtnAction(BSP_BTN_CENTER_RELEASE); } } static void overrideButtonAction() { //Disable interrupt R_GPIO_DeInitInt(BSP_BTN_CENTER_INTP); //Assign custom button action r_gpio_IntConfig_t cfg; cfg.Port = BSP_BTN_CENTER_PORT; cfg.Pin = BSP_BTN_CENTER_PIN; cfg.Trigger = R_GPIO_INT_BOTH_EDGES; cfg.Callback = &qulButtonCenterAction; R_GPIO_InitInt(BSP_BTN_CENTER_INTP, &cfg); //Enable interrupt R_GPIO_EnableInt(BSP_BTN_CENTER_INTP); } void ConfigureBoard() { R_BSP_HMI_Init(); overrideButtonAction(); R_BSP_SetButtonCallback(BSP_BTN_CENTER_PRESS, button_handler); }