Merge branch 'wd'
This commit is contained in:
@@ -66,6 +66,7 @@ PCD_HandleTypeDef hpcd_USB_FS;
|
||||
/* init function */
|
||||
void MX_USB_DEVICE_Init(void)
|
||||
{
|
||||
dbg("USB device init ...");
|
||||
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
|
||||
|
||||
/* USER CODE END USB_DEVICE_Init_PreTreatment */
|
||||
|
||||
+12
@@ -43,6 +43,18 @@ void GEX_PreInit(void)
|
||||
dbg("\r\n\033[37;1m*** GEX "GEX_VERSION" on "GEX_PLATFORM" ***\033[m");
|
||||
dbg("Build "__DATE__" "__TIME__);
|
||||
|
||||
PRINTF("Reset cause:");
|
||||
if (LL_RCC_IsActiveFlag_LPWRRST()) PRINTF(" LPWR");
|
||||
if (LL_RCC_IsActiveFlag_WWDGRST()) PRINTF(" WWDG");
|
||||
if (LL_RCC_IsActiveFlag_IWDGRST()) PRINTF(" IWDG");
|
||||
if (LL_RCC_IsActiveFlag_SFTRST()) PRINTF(" SFT");
|
||||
if (LL_RCC_IsActiveFlag_PORRST()) PRINTF(" POR");
|
||||
if (LL_RCC_IsActiveFlag_PINRST()) PRINTF(" PIN");
|
||||
if (LL_RCC_IsActiveFlag_OBLRST()) PRINTF(" OBL");
|
||||
if (LL_RCC_IsActiveFlag_V18PWRRST()) PRINTF(" V18PWR");
|
||||
PUTNL();
|
||||
LL_RCC_ClearResetFlags();
|
||||
|
||||
plat_init();
|
||||
|
||||
MX_USB_DEVICE_Init();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "debug_uart.h"
|
||||
#include "irq_dispatcher.h"
|
||||
#include "timebase.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
void plat_init(void)
|
||||
{
|
||||
@@ -39,4 +40,6 @@ void plat_init(void)
|
||||
settings_load(); // XXX maybe this should be moved to the main task
|
||||
|
||||
comm_init();
|
||||
|
||||
wd_init();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/27.
|
||||
//
|
||||
|
||||
#include "platform.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
static volatile uint16_t suspend_depth = 0;
|
||||
static volatile bool restart_pending = false;
|
||||
|
||||
void wd_init(void)
|
||||
{
|
||||
dbg("IWDG init, time 2s");
|
||||
|
||||
LL_IWDG_Enable(IWDG);
|
||||
LL_IWDG_EnableWriteAccess(IWDG);
|
||||
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_32); // 0.8 ms
|
||||
LL_IWDG_SetReloadCounter(IWDG, 2500); // 2s. max 4095
|
||||
while (!LL_IWDG_IsReady(IWDG));
|
||||
|
||||
// reload
|
||||
LL_IWDG_ReloadCounter(IWDG);
|
||||
}
|
||||
|
||||
void wd_suspend(void)
|
||||
{
|
||||
vPortEnterCritical();
|
||||
if (suspend_depth < 0xFFFF) {
|
||||
suspend_depth++;
|
||||
}
|
||||
vPortExitCritical();
|
||||
}
|
||||
|
||||
void wd_resume(void)
|
||||
{
|
||||
vPortEnterCritical();
|
||||
if (suspend_depth > 0) {
|
||||
suspend_depth--;
|
||||
|
||||
if (suspend_depth == 0 && restart_pending) {
|
||||
restart_pending = false;
|
||||
LL_IWDG_ReloadCounter(IWDG);
|
||||
}
|
||||
}
|
||||
vPortExitCritical();
|
||||
}
|
||||
|
||||
void wd_restart(void)
|
||||
{
|
||||
vPortEnterCritical();
|
||||
if (suspend_depth == 0) {
|
||||
LL_IWDG_ReloadCounter(IWDG);
|
||||
} else {
|
||||
restart_pending = true;
|
||||
}
|
||||
vPortExitCritical();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/27.
|
||||
//
|
||||
|
||||
#ifndef GEX_F072_WATCHDOG_H
|
||||
#define GEX_F072_WATCHDOG_H
|
||||
|
||||
/**
|
||||
* Initialize the application watchdog
|
||||
*/
|
||||
void wd_init(void);
|
||||
|
||||
/**
|
||||
* Suspend watchdog restarts until resumed
|
||||
* (used in other tasks to prevent the main task clearing the wd if the other task is locked up)
|
||||
*
|
||||
* The suspend/resume calls can be stacked.
|
||||
*/
|
||||
void wd_suspend(void);
|
||||
|
||||
/**
|
||||
* Resume restarts
|
||||
*/
|
||||
void wd_resume(void);
|
||||
|
||||
/**
|
||||
* Restart the wd. If restarts are suspended, postpone the restart until resumed
|
||||
* and then restart immediately.
|
||||
*/
|
||||
void wd_restart(void);
|
||||
|
||||
#endif //GEX_F072_WATCHDOG_H
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "platform.h"
|
||||
#include "platform/lock_jumper.h"
|
||||
#include "platform/watchdog.h"
|
||||
#include "status_led.h"
|
||||
#include "utils/stacksmon.h"
|
||||
#include "vfs/vfs_manager.h"
|
||||
@@ -45,6 +46,8 @@ void TaskMain(void const * argument)
|
||||
|
||||
cnt++;
|
||||
Indicator_Heartbeat();
|
||||
|
||||
wd_restart();
|
||||
}
|
||||
|
||||
// if no message and it just timed out, go wait some more...
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "platform.h"
|
||||
#include "platform/watchdog.h"
|
||||
#include "comm/messages.h"
|
||||
#include "task_msg.h"
|
||||
|
||||
@@ -85,7 +86,9 @@ void TaskMsgJob(const void *argument)
|
||||
#if CDC_LOOPBACK_TEST
|
||||
TF_WriteImpl(comm, slot.msg.data, slot.msg.len);
|
||||
#else
|
||||
wd_suspend();
|
||||
TF_Accept(comm, slot.msg.data, slot.msg.len);
|
||||
wd_resume();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ static uint32_t read_file_pinout_txt(uint32_t sector_offset, uint8_t *data, uint
|
||||
|
||||
void vfs_user_build_filesystem(void)
|
||||
{
|
||||
dbg("Rebuilding VFS...");
|
||||
vfs_printf("Rebuilding VFS...");
|
||||
|
||||
// Setup the filesystem based on target parameters
|
||||
vfs_init(daplink_drive_name, 0/*unused "disk size"*/);
|
||||
|
||||
Reference in New Issue
Block a user