ble nano hid over gatt
Dependencies: BLE_API mbed-dev nRF51822
Diff: HIDController_BLE.cpp
- Revision:
- 67:81a545a4963c
- Parent:
- 66:a7c6fbe45cf5
- Child:
- 68:13e2343452d5
--- a/HIDController_BLE.cpp Thu Sep 01 19:09:47 2016 +0000 +++ b/HIDController_BLE.cpp Thu Sep 01 19:33:25 2016 +0000 @@ -2,6 +2,7 @@ #include "BLE.h" #include "config.h" +#include "WatchDog.h" #include "KeyboardService.h" #include "BatteryService.h" #include "DeviceInformationService.h" @@ -268,8 +269,13 @@ void HIDController::waitForEvent() { BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); keyboardService->processSend(); + // SoftDevice が waitForEvent 中でも起きて + // じわじわと WDT のカウンタがすすんでリセットされてしまう(きがする) + // ので、waitForEvent 前には止める if (DEBUG_BLE_INTERRUPT) { + WatchDog::disable(); ble.waitForEvent(); + WatchDog::enable(); } else { // disable internal HFCLK RC Clock surely. It consume 1mA constantly // TWI / SPI / UART must be disabled and boot without debug mode @@ -280,7 +286,9 @@ NRF_UART0->TASKS_STOPTX = 1; NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Disabled << UART_ENABLE_ENABLE_Pos); + WatchDog::disable(); ble.waitForEvent(); + WatchDog::enable(); NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos); NRF_UART0->TASKS_STARTTX = 1;