⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timers.lst

📁 cs8900 c51应用
💻 LST
字号:
C51 COMPILER V7.06   TIMERS                                                                11/26/2004 11:32:44 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE TIMERS
OBJECT MODULE PLACED IN .\8052-obj\timers.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\timers.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(D:\Work\op
                    -entcp\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\timers.lst) PREPRINT(.
                    -\8052-lst\timers.i) OBJECT(.\8052-obj\timers.obj)

stmt level    source

   1          /*
   2           *Copyright (c) 2000-2002 Viola Systems Ltd.
   3           *All rights reserved.
   4           *
   5           *Redistribution and use in source and binary forms, with or without 
   6           *modification, are permitted provided that the following conditions 
   7           *are met:
   8           *
   9           *1. Redistributions of source code must retain the above copyright 
  10           *notice, this list of conditions and the following disclaimer.
  11           *
  12           *2. Redistributions in binary form must reproduce the above copyright 
  13           *notice, this list of conditions and the following disclaimer in the 
  14           *documentation and/or other materials provided with the distribution.
  15           *
  16           *3. The end-user documentation included with the redistribution, if 
  17           *any, must include the following acknowledgment:
  18           *      "This product includes software developed by Viola 
  19           *      Systems (http://www.violasystems.com/)."
  20           *
  21           *Alternately, this acknowledgment may appear in the software itself, 
  22           *if and wherever such third-party acknowledgments normally appear.
  23           *
  24           *4. The names "OpenTCP" and "Viola Systems" must not be used to 
  25           *endorse or promote products derived from this software without prior 
  26           *written permission. For written permission, please contact 
  27           *opentcp@opentcp.org.
  28           *
  29           *5. Products derived from this software may not be called "OpenTCP", 
  30           *nor may "OpenTCP" appear in their name, without prior written 
  31           *permission of the Viola Systems Ltd.
  32           *
  33           *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
  34           *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  35           *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  36           *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
  37           *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  38           *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  39           *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  40           *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  41           *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
  42           *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
  43           *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44           *====================================================================
  45           *
  46           *OpenTCP is the unified open source TCP/IP stack available on a series 
  47           *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
  48           *
  49           *For more information on how to network-enable your devices, or how to 
  50           *obtain commercial technical support for OpenTCP, please see 
  51           *<http://www.violasystems.com/>.
  52           */
  53          
C51 COMPILER V7.06   TIMERS                                                                11/26/2004 11:32:44 PAGE 2   

  54          /** \file timers.c
  55           *      \brief OpenTCP timers functions
  56           *      \author 
  57           *              \li Jari Lahti (jari.lahti@violasystems.com)
  58           *              \li Vladan Jovanovic (vladan.jovanovic@violasystems.com)
  59           *      \version 1.0
  60           *      \date 18.7.2001
  61           *      \bug
  62           *      \warning 
  63           *              \li Several modules are depending on decrement_timers function
  64           *              beeing invoked on every 10ms for correct (on time) operation. This
  65           *              should get fixed in the future.
  66           *              \li If no free timers are found when application wants one,
  67           *              current implementation simply resets the microcontroller 
  68           *              assuming that something is wrong.
  69           *      \todo
  70           *  
  71           *      OpenTCP implementation of a timer pool used by all applications. 
  72           */
  73          
  74          #include <inet/debug.h>
*** WARNING C318 IN LINE 74 OF ..\timers.c: can't open file 'inet/debug.h'
  75          #include <inet/datatypes.h>
*** WARNING C318 IN LINE 75 OF ..\timers.c: can't open file 'inet/datatypes.h'
  76          #include <inet/timers.h>
*** WARNING C318 IN LINE 76 OF ..\timers.c: can't open file 'inet/timers.h'
  77          #include <inet/system.h>
*** WARNING C318 IN LINE 77 OF ..\timers.c: can't open file 'inet/system.h'
  78          
  79          /** \brief Timer pool used to keep information about available timers
  80           *      
  81           *  This timer pool is extensively used by most of the modules of the 
  82           *      OpenTCP project. All timers that are used are allocated from this
  83           *      pool. Maximum number of timers that can be used at any given time
  84           *      is defined by the #NUMTIMERS define.
  85           */
  86          struct
  87          {
  88                  UINT32 value;
*** ERROR C141 IN LINE 88 OF ..\TIMERS.C: syntax error near 'UINT32'
*** ERROR C129 IN LINE 88 OF ..\TIMERS.C: missing ';' before 'value'
  89                  UINT8 free;
  90          } timer_pool[NUMTIMERS];
  91          
  92          /** \brief Initialize timer pool
  93           *      \ingroup core_initializer
  94           *      \author 
  95           *              \li Jari Lahti (jari.lahti@violasystems.com)
  96           *      \date 18.07.2001
  97           *      \warning
  98           *              \li This function <b>must</b> be invoked at startup before
  99           *              any other timer function is used.
 100           *
 101           *      This function resets all timer counter to zero and initializes all 
 102           *      timers to available (free) state.
 103           *
 104           */
 105          void timer_pool_init (void)
 106          {
 107                  UINT8 i;
 108          
 109                  for( i=0; i < NUMTIMERS; i++) {
C51 COMPILER V7.06   TIMERS                                                                11/26/2004 11:32:44 PAGE 3   

 110                          timer_pool[i].value = 0;
 111                          timer_pool[i].free = TRUE;
 112                          
 113                  }
 114                          
 115          
 116          }
 117          
 118          
 119          /** \brief Obtain a timer from timer pool
 120           *      \author 
 121           *              \li Jari Lahti (jari.lahti@violasystems.com)
 122           *      \date 18.07.2001
 123           *      \return Handle to a free timer
 124           *      \warning
 125           *              \li Timers are considered to be critical resources, so if there is 
 126           *              no available timer and get_timer is invoked, system will reset.
 127           *
 128           *      Invoke this function to obtain a free timer (it's handle that is) from
 129           *      the timer pool.
 130           */
 131          UINT8 get_timer (void)
 132          {
 133                  
 134                  UINT8 i;
 135                  UINT8 first_match;
 136                  
 137                  
 138                  for( i=0; i < NUMTIMERS; i++) {
 139                          if( timer_pool[i].free == TRUE ) {
 140                                  /* We found a free timer! */
 141                                  /* Mark is reserved               */
 142                                  
 143                                  timer_pool[i].free = FALSE;
 144                                  first_match = i;
 145                                  return first_match;             /* Return Handle        */
 146                          }
 147                  
 148                  }
 149                  
 150                  /* Error Check  */
 151                  
 152                  TMR_DEBUGOUT("No Timers, Resetting..\n\r");
 153                  RESET_SYSTEM();
 154                  
 155          
 156          }
 157          
 158          
 159          /** \brief Release timer back to free timer pool
 160           *      \author 
 161           *              \li Jari Lahti (jari.lahti@violasystems.com)
 162           *      \date 18.07.2001
 163           *      \param nbr handle to timer beeing released
 164           *
 165           *      This function releases the timer who's handle is supplied as parameter.
 166           *      Use this when timer is not needed any more and other applications might
 167           *      use it.
 168           */
 169          void free_timer (UINT8 nbr)
 170          {
 171                  /* Make a simple check */
C51 COMPILER V7.06   TIMERS                                                                11/26/2004 11:32:44 PAGE 4   

 172                  
 173                  if( nbr > (NUMTIMERS-1) ) 
 174                          return; 
 175          
 176                  timer_pool[nbr].free = TRUE;
 177          
 178          }
 179          
 180          
 181          /** \brief Initialize timer to a given time-out value
 182           *      \author 
 183           *              \li Jari Lahti (jari.lahti@violasystems.com)
 184           *      \date 18.07.2001
 185           *      \param nbr handle of timer who's value we're setting
 186           *      \param tout time-out value to set for this timer
 187           *
 188           *      Invoke this function to set timeout value for a timer with
 189           *      a given handle.
 190           *
 191           *      #TIMERTIC defines how quickly the timers' values are decremented so is
 192           *      it to initialize timers to correct timeouts.
 193           */
 194          void init_timer ( UINT8 nbr, UINT32 tout )
 195          {
 196                  /* Make a simple check */
 197                  
 198                  UINT32 val;
 199                  
 200                  if( nbr > (NUMTIMERS-1) ) 
 201                          return; 
 202          
 203                  if( timer_pool[nbr].free == TRUE ) 
 204                          return;
 205                          
 206                  /* All OK                               */
 207                  
 208                  val = tout;
 209                  
 210                  OS_EnterCritical();
 211                  
 212                  /* Normalize seconds to timer tics      */
 213                  
 214                  timer_pool[nbr].value = val;
 215          
 216                  OS_ExitCritical();
 217          
 218          } 
 219          
 220          /** \brief Return the value of a given timer
 221           *      \author 
 222           *              \li Jari Lahti (jari.lahti@violasystems.com)
 223           *      \date 18.07.2001
 224           *      \param nbr timer handle who's value is to be returned
 225           *      \return timer value
 226           *      \warning 
 227           *              \li Interrupts are not disabled when fetching the value, therefore
 228           *              returned value possibly has an error component +/- #TIMERTIC.
 229           *
 230           *      Function simply returns timer value of a given timer. No checks are
 231           *      made in order to make the function as fast as possible.
 232           */
 233          UINT32 check_timer (UINT8 nbr)
C51 COMPILER V7.06   TIMERS                                                                11/26/2004 11:32:44 PAGE 5   

 234          {
 235          
 236                  return timer_pool[nbr].value;
 237          
 238          }
 239          
 240          
 241          /** \brief Decrement all timers' values by one
 242           *      \author 
 243           *              \li Vladan Jovanovic (vladan.jovanovic@violasystems.com)
 244           *      \date 18.07.2001
 245           *
 246           *      Invoke this function from timer interrupt to decrement timer counter values
 247           */
 248          void decrement_timers (void)
 249          {
 250                  UINT8 i;
 251          
 252                  /* Go Through Timers */
 253                  
 254                  for( i=0; i<NUMTIMERS; i++ ) {
 255                          if( (timer_pool[i].free == FALSE) && (timer_pool[i].value != 0))
 256                                  timer_pool[i].value --;
 257                  }
 258          }

C51 COMPILATION COMPLETE.  4 WARNING(S),  2 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -