ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

WatchDog.h

Committer:
cho45
Date:
2016-09-02
Revision:
68:13e2343452d5
Parent:
67:81a545a4963c
Child:
69:9d6ecd584a0c

File content as of revision 68:13e2343452d5:


class WatchDog {
    static const uint8_t WDT_TIMEOUT = 3; // sec
public:
    static void init() {
        // timeout [s] = (CRV + 1) / 32768;
        // crv = 32768 * timeout - 1
        NRF_WDT->CRV = 32768 * WDT_TIMEOUT - 1;
        // NRF_WDT->CONFIG = WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos;
        NRF_WDT->TASKS_START = 1;
        enable();
    }
    
    static void enable() {
        NRF_WDT->RREN = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos;
    }
    
    static void disable() {
        NRF_WDT->RREN = WDT_RREN_RR0_Disabled << WDT_RREN_RR0_Pos;
    }
    
    static void reload() {
        NRF_WDT->RR[0] = WDT_RR_RR_Reload;
    }
    
};