void sv_task(void * param) { uint32_t now, last = time_now(); while (1) { /* Clear watchdog timer */ wdt_clear(); /* Check timeouts */ if (xSemaphoreTake(sv_sem, 1 * configTICK_RATE_HZ) == pdPASS) { sv_task_t * t = sv_head; while (t) { now = time_now(); t->timer += now - last; if (t->timer >= t->timeout) { printf("Supervisor timeout for %s - Rebooting system!\r\n", t->name); if (cpu_set_reset_cause) cpu_set_reset_cause(CPU_RESET_SUPERVISOR); cpu_reset(); } t = t->next; } xSemaphoreGive(sv_sem); } /* Sleep quarter of interval */ last = time_now(); vTaskDelay((interval * configTICK_RATE_HZ / 4) / 1000); } }
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName ) { printf("STACK OVERFLOW!\r\n"); printf("In task %p name: %s\r\n", pxTask, pcTaskName); volatile unsigned int i = 0xFFFF; while(i--); if (cpu_set_reset_cause) cpu_set_reset_cause(CPU_RESET_STACK_OVERFLOW); cpu_reset(); }
int csp_sys_reboot(void) { extern void __attribute__((weak)) cpu_set_reset_cause(unsigned int); if (cpu_set_reset_cause) cpu_set_reset_cause(1); extern void __attribute__((weak)) cpu_reset(void); if (cpu_reset) { cpu_reset(); while (1); } csp_log_error("Failed to reboot"); return CSP_ERR_INVAL; }