📄 lincmpsl.inc
字号:
$IF NOT (__LINCMP_INC)
$SET (__LINCMP_INC)
;Set these values to modify your System
OSC_FREQ EQU 11059200 ;Oscillatorfreq in Hz
LINBAUDRATE EQU 19200 ;Baudrate in bit/s
COREMODE EQU 6 ;CPU in 6 or 12 clock-mode
LIN_TIMEOUT EQU 25000 ;Timeout in Tbit
LIN_TIME_WAKEUP EQU 128 ;Timeout after Wakeup in Tbit
LIN_TIME_3WAKEUP EQU 15000 ;Timeout after 3 Wakeup in Tbit
;second Part DO NOT EDIT !!!!!
;!!!! NOT AT ALL !!!!!!!!!!!!!
;!!!! NOT AT LEAST YOU ARE PRETTY SURE WHAT YOU ARE DOING !!!!!!!!!
OSC_CORE EQU (OSC_FREQ/COREMODE)
TICKSPERBIT EQU (OSC_CORE/LINBAUDRATE)
TICKSPERBITH EQU (TICKSPERBIT/256)
TICKSPERBITL EQU (TICKSPERBIT-(TICKSPERBITH*256))
BREAKTIME EQU (65535-((14*TICKSPERBIT)/10)+60)
BREAKTIMEH EQU (BREAKTIME/256)
BREAKTIMEL EQU (BREAKTIME-(BREAKTIMEH*256))
;Time-Out Detection Definitions and Constants
extern code InitBreakDetect
extern data BreakTimeOut
;Time-Out Detection Definitions and Constants
;Timeouttime is 25000 Tbit
_LIN_TIMEOUT_HH EQU ((LIN_TIMEOUT*TICKSPERBIT)/(256*65536))
_LIN_TIMEOUT_HL EQU (((LIN_TIMEOUT*TICKSPERBIT)/65536)-(_LIN_TIMEOUT_HH*256))
_LIN_TIMEOUT_LH EQU 255-(((LIN_TIMEOUT*TICKSPERBIT)/256)-(_LIN_TIMEOUT_HH*65536)-(_LIN_TIMEOUT_HL*256))
_LIN_TIMEOUT_LL EQU 255-((LIN_TIMEOUT*TICKSPERBIT)-(_LIN_TIMEOUT_HH*256*65536)-(_LIN_TIMEOUT_HL*65536)-((255-_LIN_TIMEOUT_LH)*256))
_LIN_WAKELONG_HH EQU ((LIN_TIME_3WAKEUP*TICKSPERBIT)/(256*65536))
_LIN_WAKELONG_HL EQU (((LIN_TIME_3WAKEUP*TICKSPERBIT)/65536)-(_LIN_WAKELONG_HH*256))
_LIN_WAKELONG_LH EQU 255-(((LIN_TIME_3WAKEUP*TICKSPERBIT)/256)-(_LIN_WAKELONG_HH*65536)-(_LIN_WAKELONG_HL*256))
_LIN_WAKELONG_LL EQU 255-((LIN_TIME_3WAKEUP*TICKSPERBIT)-(_LIN_WAKELONG_HH*256*65536)-(_LIN_WAKELONG_HL*65536)-((255-_LIN_WAKELONG_LH)*256))
_LIN_WAKESHORT_HH EQU ((LIN_TIME_WAKEUP*TICKSPERBIT)/(256*65536))
_LIN_WAKESHORT_HL EQU (((LIN_TIME_WAKEUP*TICKSPERBIT)/65536)-(_LIN_WAKESHORT_HH*256))
_LIN_WAKESHORT_LH EQU 255-(((LIN_TIME_WAKEUP*TICKSPERBIT)/256)-(_LIN_WAKESHORT_HH*65536)-(_LIN_WAKESHORT_HL*256))
_LIN_WAKESHORT_LL EQU 255-((LIN_TIME_WAKEUP*TICKSPERBIT)-(_LIN_WAKESHORT_HH*256*65536)-(_LIN_WAKESHORT_HL*65536)-((255-_LIN_WAKESHORT_LH)*256))
extern code InitTimeOuts, ResetTimeOut, SendWakeup, SettoSleep
;Lin Protocol Definitions and Constanst
BAUDRATERELOADVAL EQU 256-(TICKSPERBIT/16)
LIN_WAIT_BREAK EQU 0
LIN_BREAK_DETECT EQU 1
LIN_SYNCED EQU 2
LIN_ID_OK EQU 4
;modify _FLAGS_ADR to move the LinFLags inside the bit-adressable memory
_FLAGS_ADR EQU 20H
extern code LinServiceRoutine;
extern code LinSettoSleep;
extern code LinWakeup;
extern code LinUartInt;
LinState DATA (_FLAGS_ADR)
BreakFlag BIT LinState.0
LinSynced BIT LinState.1
LinIDreceived BIT LinState.2
LinRxData BIT LinState.3
LinTxData BIT LinState.4
LinDataRdy BIT LinState.5
LinFrameOk BIT LinState.6
LinSleeps BIT LinState.7
LinError DATA (_FLAGS_ADR+1)
ParityError BIT LinError.0
ValidationError BIT LinError.1
ChecksumError BIT LinError.2
;LastFrameError BIT LinError.3
LinWakeitup BIT LinError.7
_Parity DATA (_FLAGS_ADR+2)
Par0 BIT _Parity.2
Par1 BIT _Parity.3
calcPar0 BIT _Parity.6
calcPar1 BIT _Parity.7
extern data LinState
extern data LinData
extern data LinID
extern code InitLinMac
$ENDIF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -