Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Committer:
klauss
Date:
Tue Sep 30 11:37:31 2014 +0000
Revision:
33:735fd60e96d8
Parent:
21:0bd688722e81
Child:
81:3656f00ab3db
versao 1 do protocolo de comunicao udp pra comunicao externa com a header e consequentemente, criacao do bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
klauss 17:67a6b557eda5 1 #include "mbed.h"
klauss 17:67a6b557eda5 2 #include "wdt.h"
klauss 33:735fd60e96d8 3 #include "debug.h"
klauss 17:67a6b557eda5 4
klauss 17:67a6b557eda5 5 /// Watchdog gets instantiated at the module level
klauss 17:67a6b557eda5 6 Watchdog::Watchdog() {
klauss 17:67a6b557eda5 7 wdreset = (LPC_WDT->MOD >> 2) & 1; // capture the cause of the previous reset
klauss 17:67a6b557eda5 8 }
klauss 17:67a6b557eda5 9
klauss 17:67a6b557eda5 10 /// Load timeout value in watchdog timer and enable
klauss 17:67a6b557eda5 11 void Watchdog::Configure(float s) {
klauss 17:67a6b557eda5 12 //LPC_WDT->CLKSEL = 0x1; // Set CLK src to PCLK
klauss 17:67a6b557eda5 13 uint32_t clk = 500000 / 4; // WD has a fixed /4 prescaler, and a 500khz oscillator
klauss 17:67a6b557eda5 14 LPC_WDT->TC = (uint32_t)(s * (float)clk);
klauss 17:67a6b557eda5 15 LPC_WDT->MOD = 0x3; // Enabled and Reset
klauss 33:735fd60e96d8 16 // kick();
klauss 33:735fd60e96d8 17 // debug_msg("");
klauss 17:67a6b557eda5 18 }
klauss 17:67a6b557eda5 19
klauss 17:67a6b557eda5 20 /// "Service", "kick" or "feed" the dog - reset the watchdog timer
klauss 17:67a6b557eda5 21 /// by writing this required bit pattern
klauss 17:67a6b557eda5 22 void Watchdog::kick() {
Cola 21:0bd688722e81 23 //x = NVIC_disable_IRQ();
klauss 33:735fd60e96d8 24 /*
klauss 33:735fd60e96d8 25 antes de desabilitar as irqs, eu preciso salvar o status delas
klauss 33:735fd60e96d8 26 */
klauss 33:735fd60e96d8 27 //IRQn irqn;
klauss 33:735fd60e96d8 28 //uint16_t ret = NVIC_GetActive( irqn );
klauss 33:735fd60e96d8 29 //debug_msg( "NVIC_GetActive --%i--", ret );
klauss 33:735fd60e96d8 30 //debug_msg("+");
klauss 33:735fd60e96d8 31 //__disable_irq();
klauss 33:735fd60e96d8 32 //Interrupt ID == 0 -- Exception Number 16
klauss 17:67a6b557eda5 33 LPC_WDT->FEED = 0xAA;
klauss 17:67a6b557eda5 34 LPC_WDT->FEED = 0x55;
klauss 33:735fd60e96d8 35
klauss 33:735fd60e96d8 36 //__enable_irq();
klauss 33:735fd60e96d8 37 //debug_msg(".");
klauss 33:735fd60e96d8 38 }