如題,使用自制板,測試HID_Keyboard和HID_Mouse例程正常,移植到工程里,定時發(fā)送也正常,加入輪詢按鍵發(fā)包就不正常,表現(xiàn)為快速按幾下就容易重啟,不能穩(wěn)定復(fù)現(xiàn)。如果不啟用休眠,就不那么容易,但還是會有重啟/卡死現(xiàn)象。
按鍵處理邏輯如下:(在 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); ????}
連接參數(shù)如下:
//?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
急求解,卡了幾天了....