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

📄 common.lis

📁 AVR单片机系统开发经典实例部分源程序
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 0006           ; #include "common.h"
 0006           ; #include "fcs.h"
 0006           ; #include "at.h"
 0006           ; #include "ppp.h"
 0006           ; #include "ip.h"
 0006           ; 
 0006           ; #ifdef IncludeTCP
 0006           ; #include "tcp.h"
 0006           ; #endif
 0006           ; 
 0006           ; #ifdef IncludeICMP
 0006           ; #include "icmp.h"
 0006           ; #endif
 0006           ; 
 0006           ; #ifdef IncludeUDP
 0006           ; #include "udp.h"
 0006           ; #endif
 0006           ; 
 0006           ; #ifdef IncludeNTP
 0006           ; #include "ntp.h"
 0006           ; #endif
 0006           ; 
 0006           ; // *********************************************************************************
 0006           ; // Flash constants
 0006           ; 
 0006           ; flash char    Str3[]                                  =       "\n#####\nRebooted .....\n\n";
 0006           ; 
 0006           ; flash u16     Version                                 =       0x0028;                         // version (BCD)
 0006           ; flash char    VersionStr[]                    =       "Ver: v";
 0006           ; 
 0006           ; flash char    Title[]                                 =       "AT/PPP/ICMP/UDP/TCP by C.Moss\n";
 0006           ; flash char    Date[]                                  =       "5th Feb 2004\n";
 0006           ; 
 0006           ; flash char    HelpStr[]                               =       "\n"
 0006           ;                                                                               "  help or ? ........ guess\n"
 0006           ;                                                                               "  ipconfig ......... display ip addresses\n"
 0006           ;                                                                               "  dial ............. connect\n"
 0006           ;                                                                               "  disc ............. disconnect\n"
 0006           ;                                                                               #ifdef Debug
 0006           ;                                                                               "  debug off ........ debug messages off\n"
 0006           ;                                                                               "  debug on ......... debug messages on\n"
 0006           ;                                                                               #endif
 0006           ;                                                                               #ifdef IncludeICMP
 0006           ;                                                                               "  ping <ip> ........ ping\n"
 0006           ;                                                                               #endif
 0006           ;                                                                               #ifdef IncludeTCP
 0006           ;                                                                               "  tcp <ip>[:port] .. tcp into a server\n"
 0006           ;                                                                               "  tcp down ......... tcp disconnect\n"
 0006           ;                                                                               #endif
 0006           ;                                                                               #ifdef IncludeNTP
 0006           ;                                                                               "  ntp <ip> ......... sync clock to ntp server\n"
 0006           ;                                                                               #endif
 0006           ;                                                                               #ifndef WindowsPPP
 0006           ;                                                                               "  at<modem cmd> .... gets sent to modem\n"
 0006           ;                                                                               #endif
 0006           ;                                                                               "  reboot ........... reboot!\n";
 0006           ; 
 0006           ; #ifdef Debug
 0006           ; flash char    DebugMessagesStr1[]             =       "\n*** Debug Msgs: ";
 0006           ; flash char    DebugMessagesStr2[]             =       "off\n";
 0006           ; flash char    DebugMessagesStr3[]             =       "on\n";
 0006           ; #endif
 0006           ; 
 0006           ; flash char    RebootingStr[]                  =       "\nRebooting ..\n";
 0006           ; 
 0006           ; #ifdef Debug
 0006           ; flash char    Str4[]                                  =       "\nButton\n";
 0006           ; #endif
 0006           ; 
 0006           ; // *********************************************************************************
 0006           ; // EEPROM locations - 4096 bytes
 0006           ; //
 0006           ; // every entry must have it's own crc.
 0006           ; // This means we don't loose the whole lot due to a single byte corruption - which would be
 0006           ; // the case if we just crc error checked the entire eeprom in one go.
 0006           ; 
 0006           ; #ifdef CPU_ATmega128
 0006           ; 
 0006           ; #define Unit_ID_Len                   32
 0006           ; #define MaxPhoneNumLen                32
 0006           ; 
 0006           ; #pragma data:eeprom
 0006           ; 
 0006           ; char                  Unit_ID[Unit_ID_Len]                    = {""};                                                                                         // Unit ID
 0006           ; u16                           Unit_ID_crc                                             = 0xffff;
 0006           ; 
 0006           ; T_IP_Addr             ServerIP1                                               = {0, 0, 0, 0};                                                                         // primary server ip
 0006           ; u16                           ServerIP1_crc                                   = 0xffff;
 0006           ; 
 0006           ; T_IP_Addr             ServerIP2                                               = {0, 0, 0, 0};                                                                         // seconday server ip
 0006           ; u16                           ServerIP2_crc                                   = 0xffff;
 0006           ; 
 0006           ; char                  ServerPhoneNum1[MaxPhoneNumLen] = {""};                                                                                         // primary server phone number
 0006           ; u16                           ServerPhoneNum1_crc                             = 0xffff;
 0006           ; 
 0006           ; char                  ServerPhoneNum2[MaxPhoneNumLen] = {""};                                                                                         // secondary server phone number
 0006           ; u16                           ServerPhoneNum2_crc                             = 0xffff;
 0006           ; 
 0006           ; #pragma data:data
 0006           ; 
 0006           ; #endif
 0006           ; 
 0006           ; // *********************************************************************************
 0006           ; 
 0006           ; #ifdef CPU_eZ8
 0006           ; 
 0006           ; near u8                               LastResetReason = 0;
 0006           ; 
 0006           ; volatile near u8      WatchdogCounter = 0;
 0006           ; 
 0006           ; volatile near u8      Flags1 = 0;
 0006           ; volatile near u8      Flags2 = 0;
 0006           ; 
 0006           ; volatile near u8      TimerIntCounter = 0;
 0006           ; 
 0006           ; volatile near u8      button_push = 255;
 0006           ; 
 0006           ; volatile near u32     Random32;
 0006           ; 
 0006           ; near u16                      MainBufferRd_Rx = 0;
 0006           ; near s16                      MainBufferWr_Rx = -1;
 0006           ; near u16                      MainBufferWr_Tx = 0;
 0006           ; 
 0006           ; volatile near u8      UART0_RxBuffer[32];                     // UART-0 ring buffer
 0006           ; volatile near u8      UART0_RxBufferWr = 0;
 0006           ; volatile near u8      UART0_RxBufferRd = 0;
 0006           ; 
 0006           ; volatile near u8      UART1_RxBuffer[96];                     // UART-1 ring buffer
 0006           ; volatile near u8      UART1_RxBufferWr = 0;
 0006           ; volatile near u8      UART1_RxBufferRd = 0;
 0006           ; 
 0006           ; #endif
 0006           ; 
 0006           ; #ifdef CPU_ATmega128
 0006           ; 
 0006           ; u8                            LastResetReason = 0;
 0006           ; 
 0006           ; volatile u8           WatchdogCounter = 0;
 0006           ; 
 0006           ; volatile u8           Flags1 = 0;
 0006           ; volatile u8           Flags2 = 0;
 0006           ; 
 0006           ; volatile u8           TimerIntCounter = 0;
 0006           ; 
 0006           ; volatile u8           button_push = 255;
 0006           ; 
 0006           ; volatile u32  Random32;
 0006           ; 
 0006           ; u16                           MainBufferRd_Rx = 0;
 0006           ; s16                           MainBufferWr_Rx = -1;
 0006           ; u16                           MainBufferWr_Tx = 0;
 0006           ; 
 0006           ; volatile u8           UART0_RxBuffer[32];                     // UART-0 ring buffer
 0006           ; volatile u8           UART0_RxBufferWr = 0;
 0006           ; volatile u8           UART0_RxBufferRd = 0;
 0006           ; 
 0006           ; volatile u8           UART1_RxBuffer[96];                     // UART-1 ring buffer
 0006           ; volatile u8           UART1_RxBufferWr = 0;
 0006           ; volatile u8           UART1_RxBufferRd = 0;
 0006           ; 
 0006           ; #endif
 0006           ; 
 0006           ; volatile u16  ADC_Input[8];                           // this is where the ADC input values are stored
 0006           ; 
 0006           ; u8                            CommandBuffer[32];                      // console command buffer
 0006           ; u8                            ScratchPad[256];                        // general usage buffer for strings etc
 0006           ; 
 0006           ; //u8                          MainBuffer[1550];                       // must be big enough for the 1500 ppp/udp/tcp packets
 0006           ; u8                            MainBuffer[MainBufferSize];     // - sod that, we just aint got the ram
 0006           ; 
 0006           ; // *********************************************************************************
 0006           ; // macros
 0006           ; 
 0006           ; #define BRG(freq, baud) ((unsigned long)(freq) / ((unsigned long)(baud) * 16))
 0006           ; 
 0006           ; // *********************************************************************************
 0006           ; 
 0006           ; #ifdef CPU_ATmega128
 0006           ; 
 0006           ; void _StackOverflowed(char c)
 0006           ; {     // we end up here if a stack overflow occured - this replaces iccavr's routine
 0006                   .dbline 234
 0006           ; 
 0006           ;       Disable_Ints();
 0006 F894              cli
 0008                   .dbline 235
 0008           ;       Reset_WD();
 0008 A895              wdr
 000A                   .dbline 241
 000A           ; 
 000A           ; // c = 0 ... software stack overflow
 000A           ; // c = 1 ... hardware stack overflow
 000A           ; 
 000A           ;       #ifdef Debug
 000A           ;       SendDebugStr("\n\n*** Stack Overflow\n");       // doubt if this will work - the stack is messed up :(
 000A 00E0              ldi R16,<L2
 000C 10E0              ldi R17,>L2
 000E ACD4              xcall _SendDebugStr
 0010                   .dbline 244
 0010           L3:
 0010                   .dbline 244
 0010                   .dbline 244
 0010                   .dbline 244
 0010 FFCF              xjmp L3
 0012           X0:
 0012                   .dbline -2
 0012           L1:
 0012 0E940000          xcall pop_gset1
 0016                   .dbline 0 ; func end
 0016 0895              ret
 0018                   .dbsym r c 20 c
 0018                   .dbend
 0018                   .dbfunc e u16_Put _u16_Put fV
 0018           ;      savedSREG -> R20
 0018           ;              w -> R18,R19
 0018           ;          pnter -> R16,R17
                        .even
 0018           _u16_Put::
 0018 0E940000          xcall push_gset1
 001C                   .dbline -1
 001C                   .dbline 254
 001C           ;       #endif
 001C           ; 
 001C           ;       for (;;);                                               // infinate loop - let the watch dog reset us
 001C           ; }
 001C           ; 
 001C           ; #endif
 001C           ; 
 001C           ; // **************************************************************************
 001C           ; // saftly read multi-byte values from the executive that are modified by an interrupt.
 001C           ; // at the moment, I'm just disabling global ints while I read/set the value - maybe not be the best way to go about this
 001C           ; 
 001C           ; void u16_Put(volatile u16 *pnter, u16 w)
 001C           ; {
 001C                   .dbline 260
 001C           ;       #ifdef CPU_eZ8
 001C           ;       *pnter = w;                                                                     // read the value
 001C           ;       #endif
 001C           ; 
 001C           ;       #ifdef CPU_ATmega128
 001C           ;       u8 savedSREG = SREG;                                            // keep interrupt setting
 001C 4FB7              in R20,0x3f
 001E                   .dbline 261
 001E           ;       Disable_Ints();                                                         //
 001E F894              cli
 0020                   .dbline 262
 0020           ;       *pnter = w;                                                                     // set the value
 0020 F801              movw R30,R16
 0022 3183              std z+1,R19
 0024 2083              std z+0,R18
 0026                   .dbline 263
 0026           ;       SREG = savedSREG;                                                       // restore interrupt setting
 0026 4FBF              out 0x3f,R20
 0028                   .dbline -2
 0028           L7:
 0028 0E940000          xcall pop_gset1
 002C                   .dbline 0 ; func end
 002C 0895              ret
 002E                   .dbsym r savedSREG 20 c
 002E                   .dbsym r w 18 s
 002E                   .dbsym r pnter 16 ps
 002E                   .dbend
 002E                   .dbfunc e u16_Get _u16_Get fs
 002E           ;      savedSREG -> R22

⌨️ 快捷键说明

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