#include "bsp.h" #include "gpio.h" #include "board_gpio.h" #include "multi_button.h" uint8_t btn1_id = 0; struct Button btn1; extern RF_States rf_statues; static uint8_t read_button_GPIO(uint8_t button_id) { // you can share the GPIO read function with multiple Buttons switch(button_id) { case 0: return Gpio_GetInputIO(GPIO_PORT_KEY, GPIO_PIN_KEY); break; default: return 0; break; } } static void BTN1_SINGLE_CLICK_Handler(void* btn) { //do something... //HAL_DBG_TRACE_INFO("button SINGLE_CLICK\r\n"); rf_statues = RF_START_TX; } void multibutton_init(void) { button_init(&btn1, read_button_GPIO, 0, btn1_id); button_attach(&btn1, SINGLE_CLICK,BTN1_SINGLE_CLICK_Handler); button_start(&btn1); }