void nrk_watchdog_enable() { LPC_WDT->WDCLKSEL = WDT_CLKSRC_PCLK; // Set CLK src to PCLK uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 LPC_WDT->WDTC = 10 * (float)clk; // 10 secs timeout... LPC_WDT->WDMOD = 0x3; WDT_Feed(); }
/********************************************************************//** * @brief Update WDT timeout value and feed * @param[in] TimeOut TimeOut value to be updated * @return None *********************************************************************/ void WDT_UpdateTimeOut ( uint32_t TimeOut) { uint32_t ClkSrc; ClkSrc = LPC_WDT->WDCLKSEL; ClkSrc &=WDT_WDCLKSEL_MASK; WDT_SetTimeOut(ClkSrc,TimeOut); WDT_Feed(); }
/*********************************************************************//** * @brief Start WDT activity with given timeout value * @param[in] TimeOut WDT reset after timeout if it is not feed * @return None **********************************************************************/ void WDT_Start(uint32_t TimeOut) { uint32_t ClkSrc; ClkSrc = LPC_WDT->WDCLKSEL; ClkSrc &=WDT_WDCLKSEL_MASK; WDT_SetTimeOut(ClkSrc,TimeOut); //enable watchdog LPC_WDT->WDMOD |= WDT_WDMOD_WDEN; WDT_Feed(); }
/** * @brief Update WDT timeout value and feed. * * @param TimeOut: TimeOut value to be updated. * @retval None */ void WDT_UpdateTimeOut ( uint32_t TimeOut) { WDT_SetTimeOut(TimeOut); WDT_Feed(); }
/** * @brief Update WDT timeout clock value and feed. * * @param TimeOutClk: TimeOut clock value to be updated. * @retval None */ void WDT_UpdateTimeOutClk ( uint32_t TimeOutClk) { WDT_SetTimeOutClk(TimeOutClk); WDT_Feed(); }
inline void nrk_watchdog_reset() { WDT_Feed(); }
/* This is your main function! You should have an infinite loop in here that * does all the important stuff your node was designed for */ int main(void) { #if defined(DOUBLE_BUFFER_EXAMPLE) #define BUFFER_SIZE 128 /* variables for double buffer example */ char buf_1[BUFFER_SIZE]; char buf_2[BUFFER_SIZE]; char *current_buf; struct UART_buffer_descriptor buf_desc_1, buf_desc_2; #endif #if defined(WAVESCULPTOR_EXAMPLE) float velocity = 2.0; // velocity in metres per second float bus_current = 1.0; // perentage of bus current max float motor_current = 1.0; #endif setup(); /* Initialise the watchdog timer. If the node crashes, it will restart automatically */ WDT_Init(); /* Initialise Scandal, registers for the config messages, timesync messages and in channels */ scandal_init(); /* Set LEDs to known states */ red_led(0); yellow_led(1); /* Initialise UART0 */ UART_Init(115200); /* Wait until UART is ready */ scandal_delay(100); /* Display welcome header over UART */ UART_printf("Welcome to the template project! This is coming out over UART0\n\r"); UART_printf("A debug LED should blink at a rate of 1HZ\n\r"); red_led(1); sc_time_t one_sec_timer = sc_get_timer(); #if defined(IN_CHANNEL_EXAMPLE) UART_printf("If you configure the in channel 0, a message should print upon receipt of such a channel message\n\r"); sc_time_t in_timer = sc_get_timer(); scandal_register_in_channel_handler(0, &in_channel_0_handler); #endif #if defined(DOUBLE_BUFFER_EXAMPLE) UART_printf("This shows an example of double buffer reading from the UART. Enter the text 'time' and press enter\n\r> "); UART_init_double_buffer(&buf_desc_1, buf_1, BUFFER_SIZE, &buf_desc_2, buf_2, BUFFER_SIZE); #endif #if defined(WAVESCULPTOR_EXAMPLE) sc_time_t ws_timer = sc_get_timer(); /* register for wavesculptor bus and temp messages */ scandal_register_ws_bus_callback(&ws_bus_handler); scandal_register_ws_temp_callback(&ws_temp_handler); #endif /* This is the main loop, go for ever! */ while (1) { /* This checks whether there are pending requests from CAN, and sends a heartbeat message. * The heartbeat message encodes some data in the first 4 bytes of the CAN message, such as * the number of errors and the version of scandal */ handle_scandal(); #if DOUBLE_BUFFER_EXAMPLE current_buf = UART_readline_double_buffer(&buf_desc_1, &buf_desc_2); /* UART_readline_double_buffer will return a pointer to the current buffer. */ if (current_buf != NULL) { if (strncmp("time", current_buf, 4) == 0) { UART_printf("The time is: %d\r\n> ", (int)sc_get_timer()); } } #endif #if defined(WAVESCULPTOR_EXAMPLE) /* Send the wavesculptor drive commands every 100ms. * To make this more 'realtime', we should be doing this with a timer interrupt */ if(sc_get_timer() >= ws_timer + 100) { scandal_send_ws_drive_command(DC_DRIVE, velocity, motor_current); scandal_send_ws_drive_command(DC_POWER, 0.0, bus_current); scandal_send_ws_id(DC_BASE, "TRIb", 4); /* Update the timer */ ws_timer = sc_get_timer(); } #endif /* Send a UART and CAN message and flash an LED every second */ if(sc_get_timer() >= one_sec_timer + 1000) { /* Send the message */ UART_printf("1 second timer %u\n\r", (unsigned int)sc_get_timer()); /* Send a channel message with a blerg value at low priority on channel 0 */ scandal_send_channel(TELEM_LOW, /* priority */ 0, /* channel num */ 0xaa /* value */ ); /* Twiddle the LEDs */ toggle_red_led(); /* Update the timer */ one_sec_timer = sc_get_timer(); } #if defined(IN_CHANNEL_EXAMPLE) /* The old way of checking for an incoming message that you've registered for. * This is a silly way to do this. A better way is to use the scandal_register_in_channel_handler * feature. Your function will get called when a new message comes in */ if(scandal_get_in_channel_rcvd_time(TEMPLATE_TEST_IN) > in_timer) { UART_printf("I received a channel message in the main loop on in_channel 0, value %u at time %d\n\r", (unsigned int)scandal_get_in_channel_value(TEMPLATE_TEST_IN), (int)scandal_get_in_channel_rcvd_time(TEMPLATE_TEST_IN) ); if(scandal_get_in_channel_value(TEMPLATE_TEST_IN) == 1) { toggle_red_led(); } else { toggle_yellow_led(); } in_timer = scandal_get_in_channel_rcvd_time(TEMPLATE_TEST_IN); } #endif /* Tickle the watchdog so we don't reset */ WDT_Feed(); } }
void qWDT_Feed(){ WDT_Feed(); }
extern "C" void vApplicationTickHook() { static unsigned portLONG ulTicksSinceLastDisplay = 0; // Called from every tick interrupt. Have enough ticks passed to make it // time to perform our health status check again? ulTicksSinceLastDisplay++; if( ulTicksSinceLastDisplay >= mainCHECK_DELAY ) { ulTicksSinceLastDisplay = 0; WDT_Feed(); #if configGENERATE_RUN_TIME_STATS == 1 unsigned long long uptime_usec = ullTaskGetSchedulerUptime(); #if 1 struct timeval tp; int t = gettimeofday(&tp, NULL); printf("timeofday = %ld seconds %ld microseconds (code %d)\n", (long)tp.tv_sec, (long)tp.tv_usec, t); #endif printf("Uptime: %u.%06u seconds\n", (unsigned int)(uptime_usec / 1000000), (unsigned int)(uptime_usec % 1000000)); int8_t *taskListBuffer = (int8_t *)malloc(40 * uxTaskGetNumberOfTasks()); if (taskListBuffer != NULL) { vTaskGetRunTimeStats((int8_t *)taskListBuffer); puts((const char *)taskListBuffer); free(taskListBuffer); } #endif // Has an error been found in any task? int allGood = 1; #if 0 if( xAreBlockingQueuesStillRunning() != pdTRUE ) { printf("ERROR - BLOCKQ\n"); allGood = 0; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { printf("ERROR - BLOCKTIM\n"); allGood = 0; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { printf("ERROR - GENQ\n"); allGood = 0; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { printf("ERROR - PEEKQ\n"); allGood = 0; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { printf("ERROR - DYNAMIC\n"); allGood = 0; } #endif if (allGood == 1) { printf("All Good.\n"); } fflush(stdout); } }