voltando a versao de n aberturas e fechamentos de sockets data 19/09
Dependencies: EthernetInterface NTPClient mbed-rtos mbed EALib
Fork of header_main_publish by
wdt.cpp@17:67a6b557eda5, 2014-09-19 (annotated)
- Committer:
- klauss
- Date:
- Fri Sep 19 16:40:17 2014 +0000
- Revision:
- 17:67a6b557eda5
versao em teste de wdt, filesystem, callme
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 17:67a6b557eda5 | 1 | #include "mbed.h" |
klauss | 17:67a6b557eda5 | 2 | #include "wdt.h" |
klauss | 17:67a6b557eda5 | 3 | |
klauss | 17:67a6b557eda5 | 4 | /// Watchdog gets instantiated at the module level |
klauss | 17:67a6b557eda5 | 5 | Watchdog::Watchdog() { |
klauss | 17:67a6b557eda5 | 6 | wdreset = (LPC_WDT->MOD >> 2) & 1; // capture the cause of the previous reset |
klauss | 17:67a6b557eda5 | 7 | } |
klauss | 17:67a6b557eda5 | 8 | |
klauss | 17:67a6b557eda5 | 9 | /// Load timeout value in watchdog timer and enable |
klauss | 17:67a6b557eda5 | 10 | void Watchdog::Configure(float s) { |
klauss | 17:67a6b557eda5 | 11 | //LPC_WDT->CLKSEL = 0x1; // Set CLK src to PCLK |
klauss | 17:67a6b557eda5 | 12 | uint32_t clk = 500000 / 4; // WD has a fixed /4 prescaler, and a 500khz oscillator |
klauss | 17:67a6b557eda5 | 13 | LPC_WDT->TC = (uint32_t)(s * (float)clk); |
klauss | 17:67a6b557eda5 | 14 | LPC_WDT->MOD = 0x3; // Enabled and Reset |
klauss | 17:67a6b557eda5 | 15 | kick(); |
klauss | 17:67a6b557eda5 | 16 | } |
klauss | 17:67a6b557eda5 | 17 | |
klauss | 17:67a6b557eda5 | 18 | /// "Service", "kick" or "feed" the dog - reset the watchdog timer |
klauss | 17:67a6b557eda5 | 19 | /// by writing this required bit pattern |
klauss | 17:67a6b557eda5 | 20 | void Watchdog::kick() { |
klauss | 17:67a6b557eda5 | 21 | LPC_WDT->FEED = 0xAA; |
klauss | 17:67a6b557eda5 | 22 | LPC_WDT->FEED = 0x55; |
klauss | 17:67a6b557eda5 | 23 | } |
klauss | 17:67a6b557eda5 | 24 |