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.
WatchDog.md@1:69a4a19ae933, 2019-10-29 (annotated)
- Committer:
- Pythia
- Date:
- Tue Oct 29 12:08:02 2019 +0000
- Revision:
- 1:69a4a19ae933
- Parent:
- 0:9363a65b371b
removal of remains from larger projects
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pythia | 0:9363a65b371b | 1 | Watchdog with generalization and specialization for Freescale K64F |
Pythia | 0:9363a65b371b | 2 | Tested on the FRDM K64F from Freescale |
Pythia | 0:9363a65b371b | 3 | Can be specialized for any type of the processor as long as one watchdog kicker exists only |
Pythia | 0:9363a65b371b | 4 | |
Pythia | 0:9363a65b371b | 5 | Based on hints from https://os.mbed.com/users/manitou/code/k64f_wdog/ but reworked. |
Pythia | 0:9363a65b371b | 6 | |
Pythia | 0:9363a65b371b | 7 | Copyright (c) 2019 Waldemar Dworakowski, |
Pythia | 0:9363a65b371b | 8 | |
Pythia | 0:9363a65b371b | 9 | /*- |
Pythia | 0:9363a65b371b | 10 | * Copyright (c) 2019 Waldemar Dworakowski, |
Pythia | 0:9363a65b371b | 11 | * |
Pythia | 0:9363a65b371b | 12 | * All Rights Reserved |
Pythia | 0:9363a65b371b | 13 | * |
Pythia | 0:9363a65b371b | 14 | * Redistribution and use in source and binary forms, with or without |
Pythia | 0:9363a65b371b | 15 | * modification, are permitted provided that the following conditions are |
Pythia | 0:9363a65b371b | 16 | * met: |
Pythia | 0:9363a65b371b | 17 | * 1. Redistributions of source code must retain the above copyright notice, |
Pythia | 0:9363a65b371b | 18 | * this list of conditions and the following disclaimer. |
Pythia | 0:9363a65b371b | 19 | * 2. Redistributions in binary form must reproduce the above copyright |
Pythia | 0:9363a65b371b | 20 | * notice, this list of conditions and the following disclaimer in the |
Pythia | 0:9363a65b371b | 21 | * documentation and/or other materials provided with the distribution. |
Pythia | 0:9363a65b371b | 22 | * 3. Complete source form of any/all derivative/s and it's components must be |
Pythia | 0:9363a65b371b | 23 | * provided without any cost until last copy of the software (or derivative |
Pythia | 0:9363a65b371b | 24 | * of) exists. |
Pythia | 0:9363a65b371b | 25 | * 4. Any derivative must use same licence. |
Pythia | 0:9363a65b371b | 26 | * |
Pythia | 0:9363a65b371b | 27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
Pythia | 0:9363a65b371b | 28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Pythia | 0:9363a65b371b | 29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Pythia | 0:9363a65b371b | 30 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
Pythia | 0:9363a65b371b | 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
Pythia | 0:9363a65b371b | 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
Pythia | 0:9363a65b371b | 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
Pythia | 0:9363a65b371b | 34 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
Pythia | 0:9363a65b371b | 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
Pythia | 0:9363a65b371b | 36 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
Pythia | 0:9363a65b371b | 37 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Pythia | 0:9363a65b371b | 38 | */ |
Pythia | 0:9363a65b371b | 39 | |
Pythia | 0:9363a65b371b | 40 | |
Pythia | 0:9363a65b371b | 41 | |
Pythia | 0:9363a65b371b | 42 | Usage: |
Pythia | 0:9363a65b371b | 43 | |
Pythia | 0:9363a65b371b | 44 | |
Pythia | 0:9363a65b371b | 45 | #include "mbed.h" |
Pythia | 0:9363a65b371b | 46 | #include "WatchDog.h" |
Pythia | 0:9363a65b371b | 47 | |
Pythia | 0:9363a65b371b | 48 | // WatchDog |
Pythia | 0:9363a65b371b | 49 | WatchDog wd; |
Pythia | 0:9363a65b371b | 50 | |
Pythia | 0:9363a65b371b | 51 | int main(void) |
Pythia | 0:9363a65b371b | 52 | { |
Pythia | 0:9363a65b371b | 53 | wd.Start(1000); // Watchdog 1000ms |
Pythia | 0:9363a65b371b | 54 | |
Pythia | 1:69a4a19ae933 | 55 | printf("\r\nON - restart %d cause %4X\n\r", wd.RestartCounter(), (int)wd.RestartCause()); |
Pythia | 0:9363a65b371b | 56 | |
Pythia | 0:9363a65b371b | 57 | while(wd.RestartCounter()<10) |
Pythia | 0:9363a65b371b | 58 | { |
Pythia | 0:9363a65b371b | 59 | ThisThread::sleep_for(200); // wait(200ms) |
Pythia | 0:9363a65b371b | 60 | wd.Kick(); // we kick the watchdog to not die if not error. On Error (or when we are not getting time from other threads) then restart. |
Pythia | 0:9363a65b371b | 61 | } |
Pythia | 0:9363a65b371b | 62 | |
Pythia | 0:9363a65b371b | 63 | wd.Stop(); |
Pythia | 0:9363a65b371b | 64 | |
Pythia | 1:69a4a19ae933 | 65 | printf("\r\nOFF! %d restarts \n\r", wd.RestartCounter()); |
Pythia | 0:9363a65b371b | 66 | |
Pythia | 0:9363a65b371b | 67 | return 0; |
Pythia | 0:9363a65b371b | 68 | } |