Reset the board using the cpu hal instead of the watchdog hal

Also some naming changes
pull/67/head
Alex Voinea 2021-07-20 13:47:36 +03:00 committed by D.R.racer
parent 4ba6c6e679
commit 954ef2fb8d
5 changed files with 17 additions and 9 deletions

View File

@ -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

View File

@ -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");
}

View File

@ -12,6 +12,7 @@ namespace cpu {
/// CPU init routines (not really necessary for the AVR)
void Init();
void Reset();
} // namespace cpu
} // namespace hal

View File

@ -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

View File

@ -96,7 +96,7 @@ void setup() {
cpu::Init();
mt::timebase.Init();
hal::watchdog::ConfigureWatchDog(8);
watchdog::Enable(8000); //8s timeout
mg::globals.Init();
@ -293,9 +293,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);
@ -369,7 +367,7 @@ void loop() {
mui::userInput.Step();
currentCommand->Step();
hal::watchdog::ResetWatchDog();
hal::watchdog::Reset();
}
int main() {