📄 slic_lindriver.lst
字号:
ANSI-C/cC++ Compiler for HC08 V-5.0.17, Apr 22 2003
1: //_______________________________________________________________________________
2: // Title: SLIC_LINdriver.c Copyright (c) Motorola 2003
3: //
4: // Assembler: P&E Microcomputer Systems - CASM08Z (v3.16)
5: // Compiler: Codewarrior....
6: //
7: // Revision History:
8: // Rev # Date Who Comments
9: // ------ ----------- ------ ------------------------------------------------
10: // 0.1 11-Aug-03 MR Initial release -
11: //
12: // Filename: LINQL4-C/src/SLIC_LINdriver.c
13: // Author: Matt Ruff
14: // Revision: 0.1
15: //
16: // Functions: SLIC module routines
17: //
18: // History:
19: //
20: // Description:
21: //
22: // Notes:
23: //
24: //_______________________________________________________________________________
25:
26: #include "global.h"
27: #include "MC68HC908QL4.h"
28: #include "SLIC_LINdriver.h"
29:
30: extern unsigned char temp_msg_buffer[8]; // Temporary storage of SLIC buffer contents
31: extern unsigned char LINdata;
32: extern unsigned char LINID;
33: extern unsigned char BusOff;
34: extern unsigned char LINSleep;
35:
36: //+-----------------------------------------------------------------------------+
37: //| SLIC_Init - Initializes SLIC module |
38: //| |
39: //| Configures SLIC for: |
40: //| 1. LIN or BTM mode operation |
41: //| 2. Clock Operation in MCU Wait Mode |
42: //| 3. Receive filter prescaler adjustment for data rate |
43: //| 4. Bit timing setting (BTM mode) |
44: //+-----------------------------------------------------------------------------+
45: void SLIC_Init(void)
46: {
Function: SLIC_Init
Source : D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\src\SLIC_LINdriver.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\SLIC_LINdriver.c.o -Or -Pe -WmsgSd1106
47: SLCC1_INITREQ = 0; // Clear INITREQ bit in SLIC
0000 1b00 BCLR 5,_SLCC1
0002 L2:
48: while(SLCS_INITACK==1){;;} // Wait for INITACK to clear
0002 0a00fd BRSET 5,_SLCS,L2 ;abs = 0002
49: SLCC2_SLCWCM = 0; // Wait Clock Mode
0005 1700 BCLR 3,_SLCC2
50: // 0 - SLIC clocks continue in CPU WAIT
51: // 1 - SLIC clocks stop in CPU WAIT
52: // SLCP = 0x80; // RX Filter Prescaler
53: // This is only used if a value other
54: // than the default is desired.
55: // 00 - div 1
56: // 01 - div 2
57: // 10 - div 3 (default setting)
58: // 11 - div 4
59: SLCC2_SLCE = 1; // Enable SLIC module
0007 1000 BSET 0,_SLCC2
60: }
0009 81 RTS
61:
62: //+-----------------------------------------------------------------------------+
63: //| |
64: //| SLIC_ISR - Interrupt Service Routine |
65: //| |
66: //| Main handler for SLIC interrupts |
67: //| |
68: //+-----------------------------------------------------------------------------+
69: //____________________________SLIC_ISR_____________
70: #pragma TRAP_PROC
71: void SLIC_ISR(void)
72: {
Function: SLIC_ISR
Source : D:\Data\NPI-New_Product_Development\HC908QL4-NitronLIN\AN2633-QL4_SLIC_drivers\LINQL4-C\src\SLIC_LINdriver.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\SLIC_LINdriver.c.o -Or -Pe -WmsgSd1106
0000 8b PSHH
73: unsigned char temp_SLCSV = 0;
74: char ID_found = 0; // If ID not found, set IMSG
75: char temp = PTB_PTB0;
0001 b600 LDA _PTB
76:
77: temp_SLCSV = SLCSV; // Read SLCSV value
0003 b600 LDA _SLCSV
78:
79: switch(temp_SLCSV) // switch is temporary measure
0005 a12c CMP #44
0007 2263 BHI L6C ;abs = 006c
0009 410409 CBEQA #4,L15 ;abs = 0015
000c 41101c CBEQA #16,L2B ;abs = 002b
000f a12c CMP #44
0011 2659 BNE L6C ;abs = 006c
0013 2028 BRA L3D ;abs = 003d
0015 L15:
80: {
81: case 0x00: //___________No Interrupts Pending__________________
82: break;
83:
84: case 0x04: //___________No Bus Activity________________________
85: BusOff++;
0015 450000 LDHX @BusOff
0018 7c INC ,X
86: if (BusOff == 2)
0019 c60000 LDA BusOff
001c a102 CMP #2
001e 264c BNE L6C ;abs = 006c
87: {
88: LINSleep = 1; // Set LINSleep flag
0020 a601 LDA #1
0022 c70000 STA LINSleep
89: BusOff = 0; // Reset BusOff counter
0025 4f CLRA
0026 c70000 STA BusOff
0029 2041 BRA L6C ;abs = 006c
002b L2B:
90: }
91: break;
92:
93: case 0x08: //___________TX Buffer Empty - Checksum Sent_______
94: break;
95:
96: case 0x0C: //___________TX Buffer Empty_______________________
97: break;
98:
99: case 0x10: //___________RX Buffer Full - Checksum OK__________
100:
101: //_________________________________________________________________________TEST____________
102: if(SLCID==0x97) // Test message from master
002b b600 LDA _SLCID
002d a197 CMP #-105
002f 263b BNE L6C ;abs = 006c
103: { // --------- test code....
104: temp_msg_buffer[0] = SLCD0; // Load RAM from RX buffers
0031 b600 LDA _SLCD0
0033 c70000 STA temp_msg_buffer
105: temp_msg_buffer[1] = SLCD1; // Load RAM from RX buffers
0036 b600 LDA _SLCD1
0038 c70001 STA temp_msg_buffer:1
003b 202f BRA L6C ;abs = 006c
003d L3D:
106: }
107: //_________________________________________________________________________TEST________
108: break;
109:
110: case 0x14: //___________RX Buffer Full - No errors____________
111: break;
112:
113: case 0x18: //___________Bit-Error_____________________________
114: break;
115:
116: case 0x1C: //___________RX Buffer Overrun_____________________
117: break;
118:
119: case 0x20: //___________<reserved>____________________________
120: break;
121:
122: case 0x24: //___________Checksum Error________________________
123: break;
124:
125: case 0x28: //___________Byte Framing Error____________________
126: break;
127:
128: case 0x2C: //___________ID received correctly - parity OK_____
129: // Perform ID lookup
130: //_________________________________________________________________________
131: if(SLCID==LINID) // Check ID
003d c60000 LDA LINID
0040 b100 CMP _SLCID
0042 cd0000 JSR _PUSH_CC
0045 4f CLRA
0046 cd0000 JSR _POP_CC
0049 260b BNE L56 ;abs = 0056
132: {
133: ID_found = 1; // Set ID found flag
004b 4c INCA
134: SLCD0 = LINdata; // Load TX buffers
004c ce0000 LDX LINdata
004f bf00 STX _SLCD0
135: SLCD1 = 0;
0051 3f00 CLR _SLCD1
136: SLCDLC = 0xC1; // Write DLC code to start TX - STD CHECKSUM
0053 6ec100 MOV #-63,_SLCDLC
0056 L56:
137: }
138: //_________________________________________________________________________
139: if(SLCID==0x97) // Test message from master
0056 be00 LDX _SLCID
0058 a397 CPX #-105
005a 2605 BNE L61 ;abs = 0061
140: { // --------- test code....
141: ID_found = 1; // Set ID found flag
142: SLCDLC = 0x41; // Write DLC code = RX, STANDARD CHECKSUM, 2 bytes
005c 6e4100 MOV #65,_SLCDLC
005f 2007 BRA L68 ;abs = 0068
0061 L61:
143: }
144: //_________________________________________________________________________
145:
146: if (ID_found == 0)
0061 4d TSTA
0062 2604 BNE L68 ;abs = 0068
147: {
148: #warning "ALPHA SAMPLE WORKAROUND"
149: SLCDLC = 0x00; // Alpha sample workaround - write DLC = 0 before IMSG=1;
0064 3f00 CLR _SLCDLC
150: SLCC1_IMSG = 1; // Set IMSG bit to ignore ID if not found!
0066 1200 BSET 1,_SLCC1
0068 L68:
151: }
152: ID_found = 0; // reset ID_found (should do anyway on re-entry into ISR)
153:
154: LINSleep = 0; // Clear LINSleep flag - there is bus activity
0068 4f CLRA
0069 c70000 STA LINSleep
006c L6C:
155:
156: break;
157: case 0x30: //___________ID Parity Error______________________
158: break;
159:
160: case 0x34: //___________Inconsistent-Synch-Field Error_______
161: break;
162:
163: case 0x38: //___________<reserved>___________________________
164: break;
165:
166: case 0x3C: //___________Wakeup_______________________________
167: break;
168: } //___ end switch temp_SLCSV
169:
170: SLCS_SLCF = 1; // Clear SLIC interrupt flag
006c 1000 BSET 0,_SLCS
171: } //_______________________________________________end_SLIC_ISR_______
006e 8a PULH
006f 80 RTI
172:
173:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -