implement watchdog
This commit is contained in:
@ -30,6 +30,10 @@ LED* l8() {
|
||||
return &theFactory.l8_;
|
||||
}
|
||||
|
||||
WATCHDOG* WDcontroller(){
|
||||
return &theFactory.WDcontroller_;
|
||||
}
|
||||
|
||||
|
||||
//initialize all objects
|
||||
void Factory_init() {
|
||||
@ -54,6 +58,13 @@ void Factory_init() {
|
||||
CAN_init();
|
||||
CAN_setSender(1);
|
||||
LED_off(l1());
|
||||
|
||||
// TODO init EPROM interface
|
||||
|
||||
// TODO init watchdog with EPROM CST
|
||||
WATCHDOG_init(WDcontroller());
|
||||
CAR_CST.CONTROL_ALIVE_TIME = 10;
|
||||
WATCHDOG_setTime(WDcontroller(), CAR_CST.CONTROL_ALIVE_TIME);
|
||||
}
|
||||
|
||||
void foo(uint8_t a, uint8_t b, uint32_t c){
|
||||
@ -69,9 +80,12 @@ void foo(uint8_t a, uint8_t b, uint32_t c){
|
||||
void Factory_build() {
|
||||
ECAN_SetRXBnInterruptHandler(CAN_newMsg);
|
||||
CAN_onReceiveCan(foo);
|
||||
|
||||
WATCHDOG_onAlive(WDcontroller(), CM_controller_alive, NULL);
|
||||
}
|
||||
|
||||
//start all state machines
|
||||
void Factory_start() {
|
||||
CAN_startBehaviour();
|
||||
WATCHDOG_startBehaviour(WDcontroller());
|
||||
}
|
||||
|
@ -12,9 +12,13 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../car.h"
|
||||
#include "../can_message.h"
|
||||
#include "../../board/led/led.h"
|
||||
#include "../../board/button/button.h"
|
||||
#include "../../middleware/alive_checker.h"
|
||||
#include "../../middleware/can_interface.h"
|
||||
#include "../../middleware/watchdog.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
@ -26,6 +30,8 @@ typedef struct {
|
||||
LED l6_;
|
||||
LED l7_;
|
||||
LED l8_;
|
||||
|
||||
WATCHDOG WDcontroller_;
|
||||
|
||||
} Factory;
|
||||
|
||||
@ -44,5 +50,7 @@ LED* l6();
|
||||
LED* l7();
|
||||
LED* l8();
|
||||
|
||||
WATCHDOG* WDcontroller();
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user