Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

gtimer.cc

Go to the documentation of this file.
00001 /************************************************************************************/
00002 /*                                                                                  */
00003 /* IDENTIFICATION                                                                   */
00004 /*                                                                                  */
00005 /*    Unit name:  Global_timer.c                                                    */
00006 /*    Author(s):  Tom Wheatley                                                      */
00007 /*    Version:    A.01                                                              */
00008 /*    Date:        3/17/ 1993                                                       */
00009 /*    Language:   C                                                                 */
00010 /*    System:     Gnu Sun4 -> 68k cross-compiler                                    */
00011 /*                                                                                  */
00012 /*                                                                                  */
00013 /* PURPOSE OF UNIT                                                                  */
00014 /*                                                                                  */
00015 /*    This program is a collection of timing utilities for the Global_timer, a      */
00016 /*    custom 32-bit timer with usec resolution available on most RCS systems.       */
00017 /*    This code can only be run on a VxWorks board.                                 */
00018 /*                                                                                  */
00019 
00020 // Converted to C++ MN 11-22-95
00021 // Convert to milliseconds by dividing by 1000
00022 // e.g. total_time = (get_Global_elapsed_time( prev_time))/1000  --total_time in msec
00023 //  1-Dec-1995 Will Shackleford add global_timer_config() function
00024 
00025 /************************************************************************************/
00026 
00027 #include "vxWorks.h"
00028 #include "stdioLib.h"
00029 #include "gtimer.hh"
00030 
00031 #define MAX_GLOBAL_TIME 0x7FFFFFFF
00032 
00033 typedef unsigned short *SCOPE_PTR;
00034 typedef int *TIMER_BD_PTR;
00035 
00036 extern "C"
00037 {
00038   int rd_Global_Clock (TIMER_BD_PTR);
00039 }
00040 
00041 #if 0                           // Don't store addresses here.
00042 static SCOPE_PTR p0 = (SCOPE_PTR) 0x00C00000;
00043 static SCOPE_PTR p1 = (SCOPE_PTR) 0x00C00002;
00044 static SCOPE_PTR p2 = (SCOPE_PTR) 0x00C00004;
00045 static SCOPE_PTR p3 = (SCOPE_PTR) 0x00C00006;
00046 static SCOPE_PTR p4 = (SCOPE_PTR) 0x00C00008;
00047 static SCOPE_PTR p5 = (SCOPE_PTR) 0x00C0000A;
00048 static SCOPE_PTR p6 = (SCOPE_PTR) 0x00C0000C;
00049 static SCOPE_PTR p7 = (SCOPE_PTR) 0x00C0000E;
00050 static TIMER_BD_PTR hkv3d_loc = (TIMER_BD_PTR) 0x00C00010;
00051 #else
00052 static SCOPE_PTR p0 = NULL;
00053 static SCOPE_PTR p1 = NULL;
00054 static SCOPE_PTR p2 = NULL;
00055 static SCOPE_PTR p3 = NULL;
00056 static SCOPE_PTR p4 = NULL;
00057 static SCOPE_PTR p5 = NULL;
00058 static SCOPE_PTR p6 = NULL;
00059 static SCOPE_PTR p7 = NULL;
00060 static TIMER_BD_PTR hkv3d_loc = NULL;
00061 #endif
00062 
00063 short scope_prev_value[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; /* use for toggling scope values */
00064 
00065 // This is the global variable that etime checks to see whether it should call
00066 // get_Global_time();
00067 int global_timer_available = 0;
00068 
00069 int
00070 global_timer_config (unsigned long timer_address)
00071 {
00072   unsigned long base_address;
00073   global_timer_available = 0;
00074   if (timer_address <= 0x10)
00075     {
00076       return (0);
00077     }
00078   base_address = timer_address - 0x10;
00079   p0 = (SCOPE_PTR) (base_address + 0x0);
00080   p1 = (SCOPE_PTR) (base_address + 0x2);
00081   p2 = (SCOPE_PTR) (base_address + 0x4);
00082   p3 = (SCOPE_PTR) (base_address + 0x6);
00083   p4 = (SCOPE_PTR) (base_address + 0x8);
00084   p5 = (SCOPE_PTR) (base_address + 0xA);
00085   p6 = (SCOPE_PTR) (base_address + 0xC);
00086   p7 = (SCOPE_PTR) (base_address + 0xE);
00087   hkv3d_loc = (TIMER_BD_PTR) (timer_address);
00088   global_timer_available = 1;
00089   return (1);
00090 }
00091 
00092 int
00093 get_Global_time ()
00094 {
00095 
00096   int current_glob_time;
00097 
00098   current_glob_time = rd_Global_Clock (hkv3d_loc);
00099   return (current_glob_time);
00100 }
00101 
00102 #if 0
00103 
00104 void
00105 ScopePort (int port_num, short value)
00106 {
00107   switch (port_num)
00108     {
00109 
00110     case 0:
00111       wr_Scope_Port (p0, value);
00112       break;
00113     case 1:
00114       wr_Scope_Port (p1, value);
00115       break;
00116     case 2:
00117       wr_Scope_Port (p2, value);
00118       break;
00119     case 3:
00120       wr_Scope_Port (p3, value);
00121       break;
00122     case 4:
00123       wr_Scope_Port (p4, value);
00124       break;
00125     case 5:
00126       wr_Scope_Port (p5, value);
00127       break;
00128     case 6:
00129       wr_Scope_Port (p6, value);
00130       break;
00131     case 7:
00132       wr_Scope_Port (p7, value);
00133       break;
00134     default:
00135       break;
00136     }
00137   scope_prev_value[port_num] = value;
00138 
00139 }
00140 
00141 void
00142 ToggleScopePort (int port_num)
00143 {
00144 
00145   short new_val;
00146 
00147   new_val = !scope_prev_value[port_num];
00148   switch (port_num)
00149     {
00150 
00151     case 0:
00152       wr_Scope_Port (p0, new_val);
00153       break;
00154     case 1:
00155       wr_Scope_Port (p1, new_val);
00156       break;
00157     case 2:
00158       wr_Scope_Port (p2, new_val);
00159       break;
00160     case 3:
00161       wr_Scope_Port (p3, new_val);
00162       break;
00163     case 4:
00164       wr_Scope_Port (p4, new_val);
00165       break;
00166     case 5:
00167       wr_Scope_Port (p5, new_val);
00168       break;
00169     case 6:
00170       wr_Scope_Port (p6, new_val);
00171       break;
00172     case 7:
00173       wr_Scope_Port (p7, new_val);
00174       break;
00175     default:
00176       break;
00177     }
00178   scope_prev_value[port_num] = new_val;
00179 }
00180 
00181 #endif

Generated on Sun Dec 2 15:56:49 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001