Reset the board using the cpu hal instead of the watchdog hal
Also some naming changespull/67/head^2
parent
3b46c35595
commit
56eee8dcfb
|
|
@ -1,4 +1,6 @@
|
|||
#include "../cpu.h"
|
||||
#include <avr/interrupt.h>
|
||||
#include "../watchdog.h"
|
||||
|
||||
namespace hal {
|
||||
namespace cpu {
|
||||
|
|
@ -6,5 +8,12 @@ namespace cpu {
|
|||
void Init() {
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
cli();
|
||||
watchdog::Enable(0); //minimum amount of watchdog
|
||||
for (;;)
|
||||
; //endless loop while waiting for the watchdog to reset
|
||||
}
|
||||
|
||||
} // namespace CPU
|
||||
} // namespace hal
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
namespace hal {
|
||||
namespace watchdog {
|
||||
|
||||
void ConfigureWatchDog(uint16_t period) {
|
||||
void Enable(uint16_t period) {
|
||||
// @@TODO
|
||||
}
|
||||
|
||||
void ResetWatchDog() {
|
||||
void Reset() {
|
||||
asm("wdr");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace cpu {
|
|||
|
||||
/// CPU init routines (not really necessary for the AVR)
|
||||
void Init();
|
||||
void Reset();
|
||||
|
||||
} // namespace cpu
|
||||
} // namespace hal
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ namespace hal {
|
|||
namespace watchdog {
|
||||
|
||||
/// watchdog interface
|
||||
void ConfigureWatchDog(uint16_t period);
|
||||
void ResetWatchDog();
|
||||
void Enable(uint16_t period);
|
||||
void Reset();
|
||||
|
||||
} // namespace watchdog
|
||||
} // namespace hal
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void setup() {
|
|||
|
||||
mt::timebase.Init();
|
||||
|
||||
hal::watchdog::ConfigureWatchDog(8);
|
||||
watchdog::Enable(8000); //8s timeout
|
||||
|
||||
mg::globals.Init();
|
||||
|
||||
|
|
@ -294,9 +294,7 @@ void ProcessRequestMsg(const mp::RequestMsg &rq) {
|
|||
break;
|
||||
case mp::RequestMsgCodes::Reset:
|
||||
// immediately reset the board - there is no response in this case
|
||||
hal::watchdog::ConfigureWatchDog(1); // set the watchdog to the lowest possible timeout
|
||||
for (;;)
|
||||
; // cycle indefinitely (i.e. let the watchdog reset the CPU)
|
||||
hal::cpu::Reset();
|
||||
break;
|
||||
case mp::RequestMsgCodes::Version:
|
||||
ReportVersion(rq);
|
||||
|
|
@ -370,7 +368,7 @@ void loop() {
|
|||
mui::userInput.Step();
|
||||
currentCommand->Step();
|
||||
|
||||
hal::watchdog::ResetWatchDog();
|
||||
hal::watchdog::Reset();
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue