High Altitude Recovery Payload
HARP: High Altitude Recovery Payload
Information
Version 0.1: RC design

By connecting the second xbee to a computer using a terminal command and supplying the characters L, R, C, F the light patterns change on the mbed.
watchdog.cpp@1:21a6da67311c, 2012-07-23 (annotated)
- Committer:
- tylerjw
- Date:
- Mon Jul 23 19:24:02 2012 +0000
- Revision:
- 1:21a6da67311c
- Parent:
- 0:043ed5bb10f2
MIT license notice
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tylerjw | 1:21a6da67311c | 1 | /* Copyright (c) 2012 Tyler Weaver, MIT License |
| tylerjw | 1:21a6da67311c | 2 | * |
| tylerjw | 1:21a6da67311c | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| tylerjw | 1:21a6da67311c | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
| tylerjw | 1:21a6da67311c | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
| tylerjw | 1:21a6da67311c | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
| tylerjw | 1:21a6da67311c | 7 | * furnished to do so, subject to the following conditions: |
| tylerjw | 1:21a6da67311c | 8 | * |
| tylerjw | 1:21a6da67311c | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
| tylerjw | 1:21a6da67311c | 10 | * substantial portions of the Software. |
| tylerjw | 1:21a6da67311c | 11 | * |
| tylerjw | 1:21a6da67311c | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| tylerjw | 1:21a6da67311c | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| tylerjw | 1:21a6da67311c | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| tylerjw | 1:21a6da67311c | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| tylerjw | 1:21a6da67311c | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| tylerjw | 1:21a6da67311c | 17 | */ |
| tylerjw | 1:21a6da67311c | 18 | |
| tylerjw | 0:043ed5bb10f2 | 19 | #include "mbed.h" |
| tylerjw | 0:043ed5bb10f2 | 20 | #include "watchdog.h" |
| tylerjw | 0:043ed5bb10f2 | 21 | |
| tylerjw | 0:043ed5bb10f2 | 22 | // Simon's Watchdog code from |
| tylerjw | 0:043ed5bb10f2 | 23 | // http://mbed.org/forum/mbed/topic/508/ |
| tylerjw | 0:043ed5bb10f2 | 24 | |
| tylerjw | 0:043ed5bb10f2 | 25 | // Load timeout value in watchdog timer and enable |
| tylerjw | 0:043ed5bb10f2 | 26 | void Watchdog::kick(float s) { |
| tylerjw | 0:043ed5bb10f2 | 27 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
| tylerjw | 0:043ed5bb10f2 | 28 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
| tylerjw | 0:043ed5bb10f2 | 29 | LPC_WDT->WDTC = s * (float)clk; |
| tylerjw | 0:043ed5bb10f2 | 30 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
| tylerjw | 0:043ed5bb10f2 | 31 | kick(); |
| tylerjw | 0:043ed5bb10f2 | 32 | } |
| tylerjw | 0:043ed5bb10f2 | 33 | // "kick" or "feed" the dog - reset the watchdog timer |
| tylerjw | 0:043ed5bb10f2 | 34 | // by writing this required bit pattern |
| tylerjw | 0:043ed5bb10f2 | 35 | void Watchdog::kick() { |
| tylerjw | 0:043ed5bb10f2 | 36 | LPC_WDT->WDFEED = 0xAA; |
| tylerjw | 0:043ed5bb10f2 | 37 | LPC_WDT->WDFEED = 0x55; |
| tylerjw | 0:043ed5bb10f2 | 38 | } |

