如题,使用自制板,测试HID_Keyboard和HID_Mouse例程正常,移植到工程里,定时发送也正常,加入轮询按键发包就不正常,表现为快速按几下就容易重启,不能稳定复现。如果不启用休眠,就不那么容易,但还是会有重启/卡死现象。
按键处理逻辑如下:(在 uint16_t HidEmu_ProcessEvent(uint8_t task_id, uint16_t events) 中)
static BOOL pressed = FALSE; if (events & START_REPORT_MOUSE_EVT) { // Mouse event if (!GPIOA_ReadPortPin(GPIO_K4)) { if (!pressed) { GPIOA_SetBits(GPIO_LED); hidEmuSendMouseReport(1, 0, 0); pressed = TRUE; PRINT("K4\n"); } } else { if (pressed) { hidEmuSendMouseReport(0, 0, 0); pressed = FALSE; GPIOA_ResetBits(GPIO_LED); } } tmos_start_task(hidEmuTaskId, START_REPORT_MOUSE_EVT, MS1_TO_SYSTEM_TIME(100)); return (events ^ START_REPORT_MOUSE_EVT); }
连接参数如下:
// Param update delay #define START_PARAM_UPDATE_EVT_DELAY 12800 // HID idle timeout in msec; set to zero to disable timeout #define DEFAULT_HID_IDLE_TIMEOUT 60000 // What is the advertising interval when device is discoverable (units of 625us, 80=50ms) #define DEFAULT_ADVERTISING_INTERVAL 400 // Minimum connection interval (units of 1.25ms) #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 70 // Maximum connection interval (units of 1.25ms) #define DEFAULT_DESIRED_MAX_CONN_INTERVAL 80 // Slave latency to use if parameter update request #define DEFAULT_DESIRED_SLAVE_LATENCY 0 // Supervision timeout value (units of 10ms) #define DEFAULT_DESIRED_CONN_TIMEOUT 500
急求解,卡了几天了....