Skip to content

Oscar Software Framework Manual Support Module

scs edited this page Jul 13, 2012 · 2 revisions

Go to Table of Contents.

Table of Contents

Support Module (sup)

Description

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.

Target Hardware Resource

  • Linux Watchdog Timer driver and therefore the hardware watchdog.

Dependencies

None.

Usage

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) */
  1. 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.
  2. Keep the watchdog alive in the main loop to prevent a reset.
  3. Measure the duration of a certain operation by measuring the cycle count before and after. The returned value wraps after ~8 seconds.
  4. Convert the duration from cycles to a platform-independent unit, i.e. microseconds.
  5. Explicitly close the watchdog before exiting.
Clone this wiki locally