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

📄 smartclock.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.17   SMARTCLOCK                                                            03/26/2009 14:31:59 PAGE 1   


C51 COMPILER V8.17, COMPILATION OF MODULE SMARTCLOCK
OBJECT MODULE PLACED IN .\out-files\smaRTClock.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE smaRTC\smaRTClock.c LARGE BROWSE INCDIR(.\smaRTC;.\SMBus) DEBUG OBJECTEXTEN
                    -D PRINT(.\list-files\smaRTClock.lst) TABS(2) OBJECT(.\out-files\smaRTClock.obj)

line level    source

   1          
   2          #include "..\header files\includes.H"
   3          #include "smaRTClock.h"  
   4          
   5          //-----------------------------------------------------------------------------
   6          // Global Constants and Variables
   7          //-----------------------------------------------------------------------------
   8          
   9          #define SYSCLK         24500000        // SYSCLK frequency in Hz
  10          
  11          #define BAUDRATE         115200        // Baud rate of UART in bps
  12          
  13          #define RTCCLK            32768        // SmaRTClock frequency in Hz
  14          
  15          #define RTC_DAY      2831155200        // Number of RTC counts in a day
  16          #define RTC_HOUR      117964800        // Number of RTC counts in an hour
  17          #define RTC_MINUTE      1966080        // Number of RTC counts in a minute
  18          #define RTC_SECOND        32768        // Number of RTC counts in a second
  19          #define RTC_HUNDRETH        328        // Number of RTC counts in a hundreth
  20                                                 // of a second (rounded up)
  21          
  22          #define SUSPEND            0x40        // Value to write to PMU0CF to place
  23                                                 // the device in Suspend mode
  24          
  25          #define SLEEP              0x80        // Value to write to PMU0CF to place
  26                                                 // the device in Sleep Mode
  27          
  28          #define POWER_MODE      SUSPEND        // Select between Suspend and Sleep  mode.                          
             -           
  29          
  30          #define SWITCH_PRESSED        0        // Macros to determine switch state
  31          #define SWITCH_NOT_PRESSED    1
  32          
  33          #define FIVE_MS    5*(SYSCLK/12/1000)  // 5 ms delay constant
  34          #define US_DELAY   (SYSCLK/12/1000)/10 // 500 us delay constant
  35          
  36          // Used in debounce section of code
  37          #define DEBOUNCE_INTERVAL  10          // Debounce interval in milliseconds
  38          #define T3_DEBOUNCE_TICKS  DEBOUNCE_INTERVAL*(SYSCLK/12/1000)
  39          
  40          
  41                                                          
  42          
  43          //------------------------------------------------------------------------------- 
  44          
  45          
  46          
  47          DATE_INFO event1;   // This will keep the runnnig date information                                       
  48          
  49          
  50          
  51          void Init_DateINFO(void)
  52          {
  53   1         // Initialize DATE_INFO struct
C51 COMPILER V8.17   SMARTCLOCK                                                            03/26/2009 14:31:59 PAGE 2   

  54   1         event1.seconds = SECOND_INIT;
  55   1         event1.minutes = MINUTE_INIT;
  56   1         event1.hours   = HOUR_INIT;
  57   1         event1.days    = DAY_INIT;
  58   1         event1.years   = (2000+YEAR_INIT);
  59   1      
  60   1      }
  61          
  62          //-----------------------------------------------------------------------------
  63          // Leap_Year
  64          //----------------------------------------------------------------------------- 
  65          // Return Value : '1' if a leap year, '0' if not a leap year
  66          // Parameters   : U16 year - the current year in the counter  
  67          //-----------------------------------------------------------------------------
  68          
  69          U8 Leap_Year (U16 year)
  70          {
  71   1         if ((((year%4)==0) && ((year%100)!=0)) || ((year%400)==0))
  72   1         {
  73   2            return 1;
  74   2         }
  75   1         else
  76   1         {
  77   2            return 0;
  78   2         }
  79   1      }
  80          
  81          //-----------------------------------------------------------------------------
  82          // Compute_Month
  83          //-----------------------------------------------------------------------------
  84          // Return Value : none
  85          // Parameters   : 1) U16* month - pointer to month number variable (1-12)
  86          //                2) U16* days - pointer to number of days  variable (1-31)
  87          //                3) U16 total - total number of days to compute
  88          //                   month and days from
  89          //                4) U16 total - current year (in 20xx format)  
  90          //-----------------------------------------------------------------------------
  91          
  92          void Compute_Month (U16* month, U16* days, U16 total, U16 year)
  93          {
  94   1         if (total < 32)                     // First month does not depend on
  95   1         {                                   // leap year
  96   2            (*month) = 1;                    // January
  97   2            (*days) = total;
  98   2         }
  99   1         else if (Leap_Year(year))
 100   1         {
 101   2            // Calculate month based on leap year
 102   2            if (total < 61)
 103   2            {
 104   3               (*month) = 2;                 // February
 105   3               (*days) = total-31;
 106   3            }
 107   2            else if (total < 92)
 108   2            {
 109   3               (*month) = 3;                 // March
 110   3               (*days) = total-60;
 111   3            }
 112   2            else if (total < 122)
 113   2            {
 114   3               (*month) = 4;                 // April
 115   3               (*days) = total - 91;
C51 COMPILER V8.17   SMARTCLOCK                                                            03/26/2009 14:31:59 PAGE 3   

 116   3            }
 117   2            else if (total < 153)
 118   2            {
 119   3               (*month) = 5;                 // May
 120   3               (*days) = total - 121;
 121   3            }
 122   2            else if (total < 183)
 123   2            {
 124   3               (*month) = 6;                 // June
 125   3               (*days) = total-152;
 126   3            }
 127   2            else if (total < 214)
 128   2            {
 129   3               (*month) = 7;                 // July
 130   3               (*days) = total - 182;
 131   3            }
 132   2            else if (total < 245)
 133   2            {
 134   3               (*month) = 8;                 // August
 135   3               (*days) = total - 213;
 136   3            }
 137   2            else if (total < 275)
 138   2            {
 139   3               (*month) = 9;                 // September
 140   3               (*days) = total - 244;
 141   3            }
 142   2            else if (total < 306)
 143   2            {
 144   3               (*month) = 10;                // October
 145   3               (*days) = total-274;
 146   3            }
 147   2            else if (total < 336)
 148   2            {
 149   3               (*month) = 11;                // November
 150   3               (*days) = total - 305;
 151   3            }
 152   2            else
 153   2            {
 154   3               (*month) = 12;                // December
 155   3               (*days) = total - 335;
 156   3            }
 157   2      
 158   2         }

⌨️ 快捷键说明

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