moved wdg to LLD
This commit is contained in:
parent
7e8e69551f
commit
9cf4f9dfc7
|
@ -156,6 +156,13 @@
|
|||
#define HAL_USE_USB FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the WDG subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_WDG TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ADC driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -10,6 +10,21 @@
|
|||
#define LED_EXT 14
|
||||
|
||||
|
||||
bool watchdog_started = false;
|
||||
|
||||
void watchdog_callback(void) {
|
||||
palTogglePad(IOPORT1, LED2);
|
||||
palTogglePad(IOPORT1, LED3);
|
||||
palTogglePad(IOPORT1, LED4);
|
||||
}
|
||||
|
||||
WDGConfig WDG_config = {
|
||||
.pause_on_sleep = 0,
|
||||
.pause_on_halt = 0,
|
||||
.timeout_ms = 5000,
|
||||
.callback = watchdog_callback,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Command Random
|
||||
|
@ -49,10 +64,31 @@ static void cmd_random(BaseSequentialStream *chp, int argc, char *argv[]) {
|
|||
|
||||
|
||||
|
||||
|
||||
static void cmd_watchdog(BaseSequentialStream *chp, int argc, char *argv[]) {
|
||||
if ((argc == 0) || (strcmp(argv[0], "start"))) {
|
||||
chprintf(chp, "Usage: watchdog start\r\n");
|
||||
return;
|
||||
}
|
||||
chprintf(chp,
|
||||
"Watchdog started\r\n"
|
||||
"You need to push BTN1 every 5 seconds\r\n");
|
||||
|
||||
watchdog_started = true;
|
||||
wdgStart(&WDGD1, &WDG_config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static THD_WORKING_AREA(shell_wa, 1024);
|
||||
|
||||
static const ShellCommand commands[] = {
|
||||
{"random", cmd_random},
|
||||
{"random", cmd_random },
|
||||
{"watchdog", cmd_watchdog },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -73,6 +109,10 @@ static SerialConfig serial_config = {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static THD_WORKING_AREA(waThread1, 64);
|
||||
static THD_FUNCTION(Thread1, arg) {
|
||||
|
||||
|
@ -135,11 +175,13 @@ int main(void)
|
|||
test_execute((BaseSequentialStream *)&SD1);
|
||||
|
||||
while (true) {
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
if (watchdog_started &&
|
||||
(palReadPad(IOPORT1, BTN1) == 0)) {
|
||||
palTogglePad(IOPORT1, LED1);
|
||||
wdgReset(&WDGD1);
|
||||
}
|
||||
chThdSleepMilliseconds(250);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -46,4 +46,7 @@
|
|||
#define NRF5_RNG_USE_RNG0 TRUE
|
||||
|
||||
|
||||
#define WDG_USE_TIMEOUT_CALLBACK TRUE
|
||||
|
||||
|
||||
#endif /* _MCUCONF_H_ */
|
||||
|
|
|
@ -29,7 +29,7 @@ ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
|
|||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c
|
||||
endif
|
||||
ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),)
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c
|
||||
endif
|
||||
ifneq ($(findstring HAL_USE_RNG TRUE,$(HALCONF)),)
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
|
||||
|
@ -52,7 +52,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
|
|||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_i2c_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_adc_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_gpt_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_wdg_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_pwm_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_qei_lld.c
|
||||
|
|
|
@ -12,6 +12,9 @@ endif
|
|||
ifneq ($(findstring HAL_USE_SERIAL TRUE,$(HALCONF)),)
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c
|
||||
endif
|
||||
ifneq ($(findstring HAL_USE_WDG TRUE,$(HALCONF)),)
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c
|
||||
endif
|
||||
ifneq ($(findstring HAL_USE_RNG TRUE,$(HALCONF)),)
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
|
||||
endif
|
||||
|
@ -21,6 +24,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
|
|||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_pal_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_serial_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_st_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_wdg_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/hal_rng_lld.c
|
||||
endif
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@ int main(void) {
|
|||
palSetPad(IOPORT1, LED1);
|
||||
|
||||
WDGConfig WDG_config = {
|
||||
.flags.pause_on_sleep = 0,
|
||||
.flags.pause_on_halt = 0,
|
||||
.timeout_ms = 5000,
|
||||
.callback = timeout_callback
|
||||
.pause_on_sleep = 0,
|
||||
.pause_on_halt = 0,
|
||||
.timeout_ms = 5000,
|
||||
.callback = timeout_callback
|
||||
};
|
||||
|
||||
wdgStart(&WDGD1, &WDG_config);
|
||||
|
|
Loading…
Reference in New Issue