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

📄 slave.lst

📁 汽车电子上现在最火热的总线之一LIN总线的单片机实现。
💻 LST
📖 第 1 页 / 共 2 页
字号:
ANSI-C/cC++ Compiler for HC08 V-5.0.17, Apr 22 2003

    1:  
    2:  /***********************************************************
    3:  Demo software for QL4 LINKit
    4:  
    5:  Application Code:  Steve McAslan 
    6:  SLIC driver Code:  Matt Ruff
    7:  
    8:   **********************************************************/
    9:  
   10:  #include <hidef.h>
   11:  #include <startup.h>
   12:  #include "MC68HC908QL4.h"
   13:  #include "global.h"
   14:  
   15:  #define debounce 1                                
   16:  #define modecount 145                              
   17:  
   18:  // --- Use only one of the two following define statements --
   19:  #define QL4LINKit					// Use this define for the QL4 LINkit Board
   20:  //#define QL4EVB						// Use this define for the QL4 EVB Board
   21:  
   22:  static unsigned char temp_msg_buffer[8];	// Temporary storage of SLIC buffer contents;
   23:  unsigned char LINdata;
   24:  unsigned char LINID;
   25:  unsigned char BusOff;
   26:  extern unsigned char LINSleep;
   27:  
   28:  unsigned char data = 1;
   29:  unsigned char ID = 0;
   30:  unsigned char key_last;
   31:  unsigned char count;
   32:  unsigned char mode;
   33:  
   34:  int keycount;
   35:  
   36:  // Function Prototypes
   37:  void Read_button (unsigned char);
   38:  void LED_display (void);
   39:  void init_hardware(void);
   40:  void Check_LIN_Sleep(void);
   41:  extern void SLIC_Init(void);
   42:  
   43:  
   44:  void LIN_message (unsigned char data, unsigned char ID)
   45:  	{

Function: LIN_message
Source  : D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\slave.c
Options : -Cc -DCW08 -Env"GENPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\cmd;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\src;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\src;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\inc;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\HC08;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -EnvOBJPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -EnvTEXTPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -F2 -Lasm=%n.lst -N -ObjN=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\LINQL4-C_Data\LIN08QL4_slave\ObjectCode\slave.c.o -Or -Pe -WmsgSd1106

   46:      LINdata = data;
  0000 c70000           STA   LINdata
   47:      switch (ID)
  0003 a303             CPX   #3
  0005 2215             BHI   L1C ;abs = 001c
  0007 4f               CLRA  
  0008 cd0000           JSR   _Jump_Table_Header_Offset
  000b 04               DC.B  4
  000c 0f               DC.B  L1C
  000d 0e               DC.B  L1C
  000e 02               DC.B  L11
  000f 05               DC.B  L15
  0010 08               DC.B  L19
  0011          L11:    
   48:      	{
   49:          case 0 : LINID = 0x11;  break;        
   50:          case 1 : LINID = 0x92;  break;
  0011 a692             LDA   #-110
  0013 2009             BRA   L1E ;abs = 001e
  0015          L15:    
   51:          case 2 : LINID = 0xD3;  break;
  0015 a6d3             LDA   #-45
  0017 2005             BRA   L1E ;abs = 001e
  0019          L19:    
   52:          case 3 : LINID = 0x50;  break;
  0019 a650             LDA   #80
  001b 65               SKIP2 L1E ;abs = 001e
  001c          L1C:    
   53:          default: LINID = 0x11;  break;
  001c a611             LDA   #17
  001e          L1E:    
  001e c70000           STA   LINID
   54:      	}
   55:  	}//_________end LIN_message________
  0021 81               RTS   
   56:  
   57:  void main(void)
   58:  	{ 

Function: main
Source  : D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\slave.c
Options : -Cc -DCW08 -Env"GENPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\cmd;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\src;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\src;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\inc;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\HC08;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -EnvOBJPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -EnvTEXTPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -F2 -Lasm=%n.lst -N -ObjN=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\LINQL4-C_Data\LIN08QL4_slave\ObjectCode\slave.c.o -Or -Pe -WmsgSd1106

   59:  	CONFIG1 = 0x09;             /* disable COP             */
  0000 6e0900           MOV   #9,_CONFIG1
   60:  	CONFIG2 = 0x00;             /* default (int. osc.)     */
  0003 3f00             CLR   _CONFIG2
   61:  	TSC = 0x00;                 /* Start timer */
  0005 3f00             CLR   _TSC
   62:  	BusOff = 0;
  0007 4f               CLRA  
  0008 c70000           STA   BusOff
   63:  
   64:  	init_hardware();
  000b cd0000           JSR   init_hardware
   65:  	SLIC_Init();					
  000e cd0000           JSR   SLIC_Init
   66:  
   67:  	SLCC1_SLCIE = 1;			// Enable SLIC Interrupt Flag
  0011 1000             BSET  0,_SLCC1
   68:  	EnableInterrupts;
  0013 9a               CLI   
   69:  
   70:  	#ifdef QL4LINKit			// Initialize IO pins for LED display and button reads
   71:  	PTB_PTB0 = 1;			// D8 -- LED outputs
  0014 1000             BSET  0,_PTB
   72:  	PTB_PTB1 = 0;			// D7
  0016 1300             BCLR  1,_PTB
   73:  	PTB_PTB2 = 0;   		// D6
  0018 1500             BCLR  2,_PTB
   74:  	PTB_PTB6 = 0;			// D5
  001a 1d00             BCLR  6,_PTB
   75:  	DDRB_DDRB0 = 1;			// D8 -- Set pins as outputs
  001c 1000             BSET  0,_DDRB
   76:  	DDRB_DDRB1 = 1;			// D7
  001e 1200             BSET  1,_DDRB
   77:  	DDRB_DDRB2 = 1;			// D6
  0020 1400             BSET  2,_DDRB
   78:  	DDRB_DDRB6 = 1;			// D5
  0022 1c00             BSET  6,_DDRB
   79:  
   80:  	PTB_PTB7 = 1;			// Enable 33399 physical layer device
  0024 1e00             BSET  7,_PTB
   81:  	DDRB_DDRB7 = 1;			// EN pin on MC33399
  0026 1e00             BSET  7,_DDRB
  0028          L28:    
   82:  	#endif
   83:  
   84:  	#ifdef QL4EVB				// Initialize IO pins for LED display and button reads
   85:  	PTB_PTB0 = 0;			// D1 - LED Inverse logic -- LED outputs
   86:  	PTB_PTB1 = 0;			// NC
   87:  	PTB_PTB2 = 0;   		// NC
   88:  	PTB_PTB6 = 0;			// NC
   89:  	DDRB_DDRB0 = 1;			// D1 -- Set pins as outputs
   90:  	DDRB_DDRB1 = 1;			// NC
   91:  	DDRB_DDRB2 = 1;			// NC
   92:  	DDRB_DDRB6 = 1;			// NC
   93:  
   94:  	PTB_PTB7 = 1;			// Enable MC33661 eLIN physical layer device
   95:  	DDRB_DDRB7 = 1;			// EN pin on MC33661
   96:  							// Make sure jumper 'LIN_EN' is on pins 1 & 2 for SW control
   97:  	#endif
   98:              
   99:  	while(1)
  100:     		{
  101:          COPCTL = 0;  					// clear the COP counter
  0028 4f               CLRA  
  0029 c70000           STA   _COPCTL
  102:          if (TSC & 0x80)                 // is overflow flag set?
  002c 0f0024           BRCLR 7,_TSC,L53 ;abs = 0053
  103:          	{
  104:              TSC &= ~(0x80);             // yes, clear it           
  002f 1f00             BCLR  7,_TSC
  105:              count++;                    // used for LED flashing      
  0031 450000           LDHX  @count
  0034 7c               INC   ,X
  106:  
  107:              if ((PTA & 0x20) == 0x20)	// toggle tick output      
  0035 0b0003           BRCLR 5,_PTA,L3B ;abs = 003b
  108:              	{
  109:                  PTA &= ~(0x20);
  0038 1b00             BCLR  5,_PTA
  110:              	}
  003a 65               SKIP2 L3D ;abs = 003d
  003b          L3B:    
  111:              else
  112:             		{
  113:                  PTA |= 0x20;
  003b 1a00             BSET  5,_PTA
  003d          L3D:    
  114:              	}
  115:  			#ifdef QL4LINKit						// Initialize button for LINkit 
  116:  	        Read_button (PTA_PTA1);         		// read button on PTA1
  003d b600             LDA   _PTA
  003f a402             AND   #2
  0041 44               LSRA  
  0042 cd0000           JSR   Read_button
  117:  			#endif
  118:  			#ifdef QL4EVB							// Initialize button for EVB
  119:  	        Read_button (PTA_PTA3);         		// read button on PTA3
  120:  			#endif
  121:  
  122:              LED_display ();  	                      // update LEDs on PTB0-2,6
  0045 cd0000           JSR   LED_display
  123:              LIN_message (data,ID);                    // update LIN response msg.
  0048 c60000           LDA   data
  004b ce0000           LDX   ID
  004e ad00             BSR   LIN_message
  124:              Check_LIN_Sleep();						  // Check to see if LINSleep is set
  0050 cd0000           JSR   Check_LIN_Sleep
  0053          L53:    
  0053 20d3             BRA   L28 ;abs = 0028
  125:         		}						// end if(TSC &0x08)
  126:      	}						// end while(1)
  127:  	}						// end main()
  128:  
  129:  
  130:  /******************************************************************************
  131:  *                                                                             *
  132:  *    Function name: LED_display                                               *
  133:  *    Originator:    P. Topping                                                *
  134:  *    Date:          4th September 2003                                        *
  135:  *    Function:      According to mode, the LEDs display the 4-bit data field  *
  136:  *                   or the flashing ID (0:19, 1:1A, 2:1B, 3:18).              *
  137:  *                   The LEDs are switched separately so that the compiler     *
  138:  *                   uses only BSETs and BCLRs thus avoiding an STA to port B  *
  139:  *                   which would be incompatible with the LIN drivers.         * 
  140:  *                                                                             *
  141:  ******************************************************************************/
  142:  void LED_display (void)
  143:  	{

Function: LED_display
Source  : D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\slave.c
Options : -Cc -DCW08 -Env"GENPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\cmd;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\src;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\src;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\inc;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\HC08;D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin;C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW08_V3.0\lib\HC08c\INCLUDE" -EnvOBJPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -EnvTEXTPATH=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\bin -F2 -Lasm=%n.lst -N -ObjN=D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\sample\LINQL4-C_Data\LIN08QL4_slave\ObjectCode\slave.c.o -Or -Pe -WmsgSd1106

  144:  	unsigned char LEDs;
  145:   
  146:      if (mode)
  0000 c60000           LDA   mode
  0003 271a             BEQ   L1F ;abs = 001f
  147:      	{
  148:          if (count & 0x04)
  0005 c60000           LDA   count
  0008 a504             BIT   #4
  000a 2710             BEQ   L1C ;abs = 001c
  149:          	{
  150:              LEDs = 1 << (ID+3);                   // ID mode LED display
  000c c60000           LDA   ID
  000f ab03             ADD   #3
  0011 97               TAX   
  0012 a601             LDA   #1
  0014 5d               TSTX  
  0015 270e             BEQ   L25 ;abs = 0025
  0017          L17:    
  0017 48               LSLA  
  0018 5bfd             DBNZX L17 ;abs = 0017
  151:         		}
  001a 2009             BRA   L25 ;abs = 0025
  001c          L1C:    
  152:          else
  153:          	{
  154:              LEDs = 0;                             // ID mode flash, LEDs off
  001c 4f               CLRA  
  001d 200d             BRA   L2C ;abs = 002c
  001f          L1F:    
  155:         		}
  156:      	}
  157:      else                                          // normal mode so
  158:      	{
  159:          LEDs = data << 3;                         // drive LEDs with data
  001f c60000           LDA   data
  0022 48               LSLA  
  0023 48               LSLA  
  0024 48               LSLA  
  0025          L25:    
  160:      	}

⌨️ 快捷键说明

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