mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
update
This commit is contained in:
parent
34d3652711
commit
39f77eb92b
1844 changed files with 899433 additions and 7 deletions
10
USDK/example_sources/watchdog/readme.txt
Normal file
10
USDK/example_sources/watchdog/readme.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
Example Description
|
||||
|
||||
This example describes how to use watchdog api.
|
||||
|
||||
Requirement Components: None
|
||||
|
||||
In this example, watchdog is setup to 5s timeout.
|
||||
Watchdog won't bark if we refresh it before timeout.
|
||||
The timer is also reloaded after refresh.
|
||||
Otherwise it will restart system in default or call callback function if registered.
|
61
USDK/example_sources/watchdog/src/main.c
Normal file
61
USDK/example_sources/watchdog/src/main.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "diag.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "wdt_api.h"
|
||||
|
||||
#define RUN_CALLBACK_IF_WATCHDOG_BARKS (0)
|
||||
|
||||
void dummy_task() {
|
||||
for (int i=0; i<50000000; i++)
|
||||
asm(" nop");
|
||||
}
|
||||
|
||||
void small_task() {
|
||||
printf("\r\ndoing small task...\r\n");
|
||||
dummy_task();
|
||||
printf("refresh watchdog\r\n\r\n");
|
||||
watchdog_refresh();
|
||||
}
|
||||
|
||||
void big_task() {
|
||||
printf("\r\ndoing big task...\r\n");
|
||||
for (int i=0; i<10; i++) {
|
||||
DiagPrintf("doing dummy task %d\r\n", i);
|
||||
dummy_task();
|
||||
}
|
||||
printf("refresh watchdog\r\n\r\n");
|
||||
watchdog_refresh();
|
||||
}
|
||||
|
||||
void my_watchdog_irq_handler(uint32_t id) {
|
||||
printf("watchdog barks!\r\n");
|
||||
watchdog_stop();
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
||||
watchdog_init(5000); // setup 5s watchdog
|
||||
|
||||
#if RUN_CALLBACK_IF_WATCHDOG_BARKS
|
||||
watchdog_irq_init(my_watchdog_irq_handler, 0);
|
||||
#else
|
||||
// system would restart when watchdog barks
|
||||
#endif
|
||||
|
||||
watchdog_start();
|
||||
|
||||
small_task();
|
||||
big_task();
|
||||
|
||||
while(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue