#include "interface_gpio.h" Timer gpio_timer_interface; void gpioTimerProcess(void *signal_id) { (void)signal_id; // 标记变量为已使用,避免编译器警告 // uint32_t time_boot = getCurrentTime();//记录当前时间 //-------------------------------------------- un_sw_sample.bit_data.emergency_stop_switch = sdrv_gpio_read_pin_input_level(GPIO_A4); un_sw_sample.bit_data.High_voltage_switch = sdrv_gpio_read_pin_input_level(GPIO_C7); publishMessage(&un_sw_sample, 1);//发射信号 timerStart(&gpio_timer_interface, 100,1); printf("sw state %d\n",un_sw_sample.arr[0]); } // APP模块的初始化 void gpioInterfaceInit(void) { // 初始化定时器 timerInit(&gpio_timer_interface); // 订阅定时器信号,用于定时采集 subscribe(&gpio_timer_interface, gpioTimerProcess); timerStart(&gpio_timer_interface, 100,1); printf("gpioInterface: initial OK %d\n",getCurrentTime()); }