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:
- 33:6a2301a89e92
- Parent:
- 32:6c0f43fda460
- Child:
- 34:7da766a8aa96
--- a/main.cpp Thu Aug 25 00:07:21 2016 +0000
+++ b/main.cpp Thu Aug 25 00:43:55 2016 +0000
@@ -140,6 +140,7 @@
MCP23017::GPIOA,
~(1<<i)
);
+ wait_us(1);
keys[i] = gpio1.read8(MCP23017::GPIOB, ok);
}
@@ -157,6 +158,7 @@
MCP23017::GPIOA,
~(1<<i)
);
+ wait_us(1);
keys[i+8] = gpio2.read8(MCP23017::GPIOB, ok);
}
@@ -187,6 +189,7 @@
0b00000000
);
}
+
}
void enableInterrupt() {
@@ -246,7 +249,7 @@
void buttonIntCallback() {
// just for wakeup
- pollCount = 100;
+ pollCount = 25;
}
void powerOff() {
@@ -267,7 +270,7 @@
class WatchDog {
static const uint32_t RELOAD_VALUE = 0x6E524635;
- static const uint8_t WDT_TIMEOUT = 2; // sec
+ static const uint8_t WDT_TIMEOUT = 5; // sec
public:
static void init() {
// timeout [s] = (CRV + 1) / 32768;
@@ -284,7 +287,14 @@
};
int main(void) {
- printf("init\r\n");
+ {
+ uint32_t reason = NRF_POWER->RESETREAS;
+ NRF_POWER->RESETREAS = 0xffffffff; // clear reason
+ printf("init [%x]\r\n", reason);
+ }
+
+
+
// Enable Pin-reset on DEBUG mode
// This makes possiable booting without normal mode easily.
@@ -320,7 +330,7 @@
buttonInt.fall(buttonIntCallback);
keyboardMatrixController.init();
- buttonIntCallback();
+ pollCount = 10;
HIDController::init();
@@ -335,7 +345,9 @@
if (pollCount > 0) {
printf("scan keys\r\n");
- while (pollCount -- > 0) {
+ while (pollCount-- > 0) {
+ WatchDog::reload();
+
uint8_t (&keysCurr)[COLS] = state ? keysA : keysB;
uint8_t (&keysPrev)[COLS] = state ? keysB : keysA;