Add watchdog implementation + use it in main()

pull/67/head^2
D.R.racer 2021-07-20 07:16:59 +02:00 committed by Alex Voinea
parent 82a9eaae43
commit 324ced6807
4 changed files with 22 additions and 1 deletions

View File

@ -8,4 +8,5 @@ target_sources(
tmc2130.cpp
adc.cpp
avr/spi.cpp
avr/watchdog.cpp
)

15
src/hal/avr/watchdog.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "../watchdog.h"
namespace hal {
namespace watchdog {
void ConfigureWatchDog(uint16_t period) {
// @@TODO
}
void ResetWatchDog() {
asm("wdr");
}
} // namespace watchdog
} // namespace hal

View File

@ -1,4 +1,5 @@
#pragma once
#include <stdint.h>
namespace hal {

View File

@ -4,6 +4,7 @@
#include "hal/shr16.h"
#include "hal/spi.h"
#include "hal/usart.h"
#include "hal/watchdog.h"
#include "pins.h"
#include <avr/interrupt.h>
@ -96,6 +97,8 @@ void setup() {
mt::timebase.Init();
hal::watchdog::ConfigureWatchDog(8);
mg::globals.Init();
// watchdog init
@ -363,7 +366,8 @@ void loop() {
ms::selector.Step();
mui::userInput.Step();
currentCommand->Step();
// add a watchdog reset
hal::watchdog::ResetWatchDog();
}
int main() {