-
Notifications
You must be signed in to change notification settings - Fork 2
Oscar Software Framework Manual Support Module
scs edited this page Jul 13, 2012
·
2 revisions
Go to Table of Contents.
This is a module where support functions being too small for an own module are placed.
It contains functionality to interface with the watchdog and to measure performance with the built-in cycles register.
On the host, the watchdog methods do nothing and the functions to query the cycle count use the low-resolution ANSI C clock() function instead.
- Linux Watchdog Timer driver and therefore the hardware watchdog.
None.
Following code segment demonstrates the usage of the sup module. For the sake of simplicity, error checking as well as framework creation and destruction are neglected.
OscSupWdtInit(); /* (1) */ while(1) { /* main loop */ OscSupWdtKeepAlive(); /* (2) */ start = OscSupCycGet(); /* (3) */ usleep(100000); end = OscSupCycGet(); musecs = OscSupCycToMicroSecs(end - start); /* (4) */ OscLog(INFO, "%s:\tstart: %u\tend: %u\tdiff: %u\tmuSecs: %u\n", __func__, start, end, end - start, musecs); } OscSupWdtClose(); /* (5) */
- Initialize the watchdog. Starting from this moment, the watchdog needs to be kept alive periodically or it will hardware-reset the board after one minute. The only way to stop this is to explicitly close the watchdog.
- Keep the watchdog alive in the main loop to prevent a reset.
- Measure the duration of a certain operation by measuring the cycle count before and after. The returned value wraps after ~8 seconds.
- Convert the duration from cycles to a platform-independent unit, i.e. microseconds.
- Explicitly close the watchdog before exiting.