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

📄 guitimer.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
字号:
C51 COMPILER V8.05a   GUITIMER                                                             04/11/2008 14:18:58 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE GUITIMER
OBJECT MODULE PLACED IN guitimer.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\guitimer.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND 
                    -PRINT(.\guitimer.lst) OBJECT(guitimer.obj)

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/GUI
   4          *                        Universal graphic software for embedded applications
   5          *
   6          *                       (c) Copyright 2002, Micrium Inc., Weston, FL
   7          *                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
   8          *
   9          *              礐/GUI is protected by international copyright laws. Knowledge of the
  10          *              source code may not be used to write a similar product. This file may
  11          *              only be used in accordance with a license and should not be redistributed
  12          *              in any way. We appreciate your understanding and fairness.
  13          *
  14          ----------------------------------------------------------------------
  15          File        : GUITimer.c
  16          Purpose     : Supplies timers for new emWin GSC
  17          ----------------------------------------------------------------------
  18          ---------------------------END-OF-HEADER------------------------------
  19          */
  20          
  21          
  22          #include <stddef.h>           /* needed for definition of NULL */
  23          #include "gui\Core\GUI_Protected.h"
  24          
  25          
  26          /*
  27            *****************************************************************
  28            *                                                               *
  29            *              Config defaults                                  *
  30            *                                                               *
  31            *****************************************************************
  32          */
  33          
  34          /*
  35                *************************************************************
  36                *                                                           *
  37                *                 Object definition                         *
  38                *                                                           *
  39                *************************************************************
  40          
  41          */
  42          typedef struct {
  43            GUI_TIMER_CALLBACK* cb;
  44            GUI_TIMER_Handle hNext;
  45            int Flags;
  46                  U32 Context;
  47                  GUI_TIMER_TIME t0;
  48                  GUI_TIMER_TIME Period;
  49          } GUI_TIMER_Obj;
  50          
  51          /*
  52            *****************************************************************
  53            *                                                               *
  54            *              Static data                                      *
C51 COMPILER V8.05a   GUITIMER                                                             04/11/2008 14:18:58 PAGE 2   

  55            *                                                               *
  56            *****************************************************************
  57          */
  58          
  59          GUI_TIMER_Handle hFirstTimer;
  60          
  61          
  62          /*
  63            ********************************************************************
  64            *                                                                  *
  65            *                 Macros for internal use                          *
  66            *                                                                  *
  67            ********************************************************************
  68          */
  69          
  70          #define GUI_TIMER_H2P(h) (GUI_TIMER_Obj*)GUI_ALLOC_H2P(h)
  71          
  72          /*
  73            ********************************************************************
  74            *                                                                  *
  75            *                    Static routines                               *
  76            *                                                                  *
  77            ********************************************************************
  78          */
  79          
  80          
  81          static void Unlink(GUI_TIMER_Handle hTimer) {
  82   1        GUI_TIMER_Obj* pTimer = GUI_TIMER_H2P(hTimer);
  83   1        GUI_TIMER_Handle hi;
  84   1        GUI_TIMER_Obj*   pi;
  85   1      /* Check if it is the first element */
  86   1        if (hFirstTimer == hTimer) {
  87   2          hFirstTimer = pTimer->hNext;
  88   2          return;
  89   2              }
  90   1        hi = hFirstTimer;
  91   1      /* Try to find it in the list ... */
  92   1        while(hi) {
  93   2          /* GUI_ASSERT(hi<1000,0); */
  94   2          pi = GUI_TIMER_H2P(hi);
  95   2          if (pi->hNext == hTimer) {
  96   3            pi->hNext = pTimer->hNext;
  97   3            break;
  98   3                      }        
  99   2          hi = pi->hNext;
 100   2        }  
 101   1      }
 102          
 103          /*********************************************************************
 104             Link new Timer
 105                   ==============
 106          
 107                  This routine inserts the new timer (referenced by its handle) into
 108                  the linked list. The linked list is sorted according to timestamps.
 109                  The first element is the timer which expires first.
 110          */
 111          void Link(GUI_TIMER_Handle hNew) {
 112   1        GUI_TIMER_Obj*   pNew        = GUI_TIMER_H2P(hNew);
 113   1        GUI_TIMER_Obj*   pTimer;
 114   1        GUI_TIMER_Obj*   pNext;
 115   1        GUI_TIMER_Handle hNext;
 116   1        if (hFirstTimer ==0) { /* List is empty, make it the only element */
C51 COMPILER V8.05a   GUITIMER                                                             04/11/2008 14:18:58 PAGE 3   

 117   2          hFirstTimer = hNew;
 118   2                pNew->hNext = 0;
 119   2        } else {
 120   2          GUI_TIMER_Obj* pFirstTimer      = GUI_TIMER_H2P(hFirstTimer);
 121   2      /* Check if we have to make it the first element */
 122   2          if ((pNew->t0 - pFirstTimer->t0) <=0) {
 123   3            pNew->hNext = hFirstTimer;
 124   3            hFirstTimer = hNew;
 125   3                              return;
 126   3                      } else {
 127   3            GUI_TIMER_Handle hTimer = hFirstTimer;
 128   3      /* Put it into the list */
 129   3            do {
 130   4              pTimer       = GUI_TIMER_H2P(hTimer);
 131   4              hNext        = pTimer->hNext;
 132   4              if (hNext ==0)
 133   4                                              goto Append;
 134   4              pNext      = GUI_TIMER_H2P(hNext);
 135   4                                      if ((pNew->t0 - pNext->t0) <=0) {
 136   5                pNew->hNext  = hNext;
 137   5                pTimer->hNext= hNew;
 138   5                return;
 139   5                                      }
 140   4                              } while(1);
 141   3      /* Put it at the end of the list */
 142   3      Append:
 143   3            pNew->hNext  = hNext;
 144   3            pTimer->hNext= hNew;
 145   3            return;
 146   3                      }
 147   2        }
 148   1      }
 149          
 150          /*
 151            ********************************************************************
 152            *
 153            *        Static routines:  Exec
 154            *
 155            ********************************************************************
 156          */
 157          
 158          
 159          int GUI_TIMER_Exec(void) {
 160   1        int r = 0;
 161   1        GUI_TIMER_TIME t = GUI_GetTime();
 162   1        GUI_LOCK(); {
 163   2          while (hFirstTimer) {
 164   3              GUI_TIMER_Obj* pTimer = GUI_TIMER_H2P(hFirstTimer);
 165   3            if ((pTimer->t0-t) <=0) {
 166   4              GUI_TIMER_MESSAGE tm;
 167   4              tm.Time = t;
 168   4                                      tm.Context = pTimer->Context;
 169   4              hFirstTimer = pTimer->hNext;
 170   4                                      pTimer->cb(&tm);
 171   4              r = 1;
 172   4                              } else
 173   3                                break;
 174   3          }
 175   2          /*
 176   2                      GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
 177   2          pObj->t0 = Time;
 178   2          */
C51 COMPILER V8.05a   GUITIMER                                                             04/11/2008 14:18:58 PAGE 4   

 179   2        } GUI_UNLOCK(); 
 180   1        return r;
 181   1      }
 182          
 183          
 184          /*
 185            ********************************************************************
 186            *                                                                  *
 187            *        Exported routines:  Create                                *
 188            *                                                                  *
 189            ********************************************************************
 190          */
 191          
 192          GUI_TIMER_Handle GUI_TIMER_Create      (    GUI_TIMER_CALLBACK* cb,
 193                                              int Time,
 194                                              U32 Context,
 195                                              int Flags) {
 196   1        GUI_TIMER_Handle hObj;
 197   1        GUI_TIMER_Obj* pObj;
 198   1        GUI_LOCK();
 199   1        GUI_USE_PARA(Flags);
 200   1        GUI_USE_PARA(Time);
 201   1        GUI_pfTimerExec = GUI_TIMER_Exec;
 202   1              {
 203   2          /* Alloc memory for obj */
 204   2          hObj = GUI_ALLOC_ALLOC(sizeof(GUI_TIMER_Obj));
 205   2          pObj = GUI_TIMER_H2P(hObj);
 206   2          /* init member variables */
 207   2          pObj->cb = cb;
 208   2                      pObj->Context = Context;
 209   2          /* Link it */
 210   2                      Link(hObj);
 211   2              } GUI_UNLOCK();
 212   1        return hObj;
 213   1      }
 214          
 215          
 216          
 217          /*
 218            ********************************************************************
 219            *                                                                  *
 220            *        Exported routines:  Delete                                *
 221            *                                                                  *
 222            ********************************************************************
 223          */
 224          
 225          void GUI_TIMER_Delete(GUI_TIMER_Handle hObj) {
 226   1      /* Unlink Timer */
 227   1        GUI_LOCK();
 228   1          Unlink(hObj);
 229   1          GUI_ALLOC_FREE(hObj);
 230   1        GUI_UNLOCK();
 231   1      }
 232          
 233          /*
 234            ********************************************************************
 235            *                                                                  *
 236            *        Exported routines:  Various methods                       *
 237            *                                                                  *
 238            ********************************************************************
 239          */
 240          void GUI_TIMER_SetPeriod(GUI_TIMER_Handle hObj, GUI_TIMER_TIME Period) {
C51 COMPILER V8.05a   GUITIMER                                                             04/11/2008 14:18:58 PAGE 5   

 241   1        GUI_LOCK(); {
 242   2          GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
 243   2          pObj->Period = Period;
 244   2        } GUI_UNLOCK(); 
 245   1      }
 246          
 247          void GUI_TIMER_SetTime(GUI_TIMER_Handle hObj, GUI_TIMER_TIME Time) {
 248   1        GUI_LOCK(); {
 249   2              GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
 250   2          pObj->t0 = Time;
 251   2        } GUI_UNLOCK(); 
 252   1      }
 253          
 254          void GUI_TIMER_SetDelay(GUI_TIMER_Handle hObj, GUI_TIMER_TIME Delay) {
 255   1        GUI_LOCK(); {
 256   2              GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
 257   2          pObj->t0 = Delay;
 258   2                      Unlink(hObj);
 259   2                      Link(hObj);
 260   2        } GUI_UNLOCK(); 
 261   1      }
 262          
 263          void GUI_TIMER_Restart(GUI_TIMER_Handle hObj) {
 264   1        GUI_LOCK(); {
 265   2              GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
 266   2          pObj->t0 = GUI_GetTime() +pObj->Period;
 267   2                      Unlink(hObj);
 268   2                      Link(hObj);
 269   2        } GUI_UNLOCK(); 
 270   1      }
 271          
 272          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1110    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      2      77
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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