Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed-dev nRF51822
Diff: main.cpp
- Revision:
- 39:b7889285c9ef
- Parent:
- 38:115875b8cb6c
- Child:
- 40:364deaa190fe
--- a/main.cpp Fri Aug 26 15:22:31 2016 +0000
+++ b/main.cpp Fri Aug 26 15:39:03 2016 +0000
@@ -294,7 +294,7 @@
class WatchDog {
static const uint32_t RELOAD_VALUE = 0x6E524635;
- static const uint8_t WDT_TIMEOUT = 5; // sec
+ static const uint8_t WDT_TIMEOUT = 3; // sec
public:
static void init() {
// timeout [s] = (CRV + 1) / 32768;
@@ -469,12 +469,11 @@
uint8_t batteryPercentage = Battery::readBatteryPercentage(batteryVoltage);
bool isLowBattery = batteryVoltage < Battery::BATTERY_LOW;
- printf("%f.2V : %d/100 [%d:%s] %s\r\n",
- batteryVoltage,
+ printf("%d%% [%d:%s] %s\r\n",
batteryPercentage,
HIDController::status(),
HIDController::statusString(),
- isLowBattery ? "low battery" : "waitForEvent"
+ isLowBattery ? "LOWBAT" : "WFE"
);
HIDController::updateBatteryLevel(batteryPercentage);
@@ -483,30 +482,27 @@
powerOff();
}
- // allow printf in some interrupts while connecting
- if (HIDController::connected()) {
- // disable internal HFCLK RC Clock surely. It consume 1mA constantly
- // TWI / SPI / UART must be disabled and boot without debug mode
- while (NRF_UART0->EVENTS_TXDRDY != 1);
-
- uint32_t tx = NRF_UART0->PSELTXD;
-
- NRF_UART0->TASKS_STOPTX = 1;
- NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Disabled << UART_ENABLE_ENABLE_Pos);
-
- HIDController::waitForEvent();
-
- NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
- NRF_UART0->TASKS_STARTTX = 1;
- // dummy send to wakeup...
- NRF_UART0->PSELTXD = 0xFFFFFFFF;
- NRF_UART0->EVENTS_TXDRDY = 0;
- NRF_UART0->TXD = 0;
- while (NRF_UART0->EVENTS_TXDRDY != 1);
- NRF_UART0->PSELTXD = tx;
- } else {
- HIDController::waitForEvent();
- }
+
+ // disable internal HFCLK RC Clock surely. It consume 1mA constantly
+ // TWI / SPI / UART must be disabled and boot without debug mode
+ while (NRF_UART0->EVENTS_TXDRDY != 1);
+
+ uint32_t tx = NRF_UART0->PSELTXD;
+
+ NRF_UART0->TASKS_STOPTX = 1;
+ NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Disabled << UART_ENABLE_ENABLE_Pos);
+
+ HIDController::waitForEvent();
+
+ NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
+ NRF_UART0->TASKS_STARTTX = 1;
+ // dummy send to wakeup...
+ NRF_UART0->PSELTXD = 0xFFFFFFFF;
+ NRF_UART0->EVENTS_TXDRDY = 0;
+ NRF_UART0->TXD = 0;
+ while (NRF_UART0->EVENTS_TXDRDY != 1);
+ NRF_UART0->PSELTXD = tx;
+
}
}
}
\ No newline at end of file