Mike Moore
/
RTOS_HW_04
RTOS homework 4
Revision 24:fe4e288bbca3, committed 2013-09-13
- Comitter:
- gatedClock
- Date:
- Fri Sep 13 04:06:04 2013 +0000
- Parent:
- 23:99a13f79cdad
- Child:
- 25:fe4425b11e3c
- Commit message:
- watchdog class and its instance compiles.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Sep 13 04:03:41 2013 +0000 +++ b/main.cpp Fri Sep 13 04:06:04 2013 +0000 @@ -80,6 +80,8 @@ Ticker tickerLCD; // display ticker. Timeout timeoutDutyCycle; // LED duty cycle delay. Timeout timeoutMetronome; + + //-------prototypes-----------------------------//------------------------------ void initialization(); // initialize settings. void lcd_display(); // display on LCD. @@ -94,6 +96,27 @@ void ISR_left_falling(); // bounce protection. void ISR_center(); // set to 60BPM. void turn_off_metronome(); // turn off blinker. + + + +class Watchdog { +public: +// Load timeout value in watchdog timer and enable + void kick(float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 + LPC_WDT->WDTC = s * (float)clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + kick(); + } +// "kick" or "feed" the dog - reset the watchdog timer +// by writing this required bit pattern + void kick() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } +}; + Watchdog wdt; // add a wachdog timer. //==============================================//============================== int main(void) {