📄 utilities.asm
字号:
;*******************************************************************************************************
;* *
;* ********** *
;* ************ *
;* *** *** *
;* *** +++ *** *
;* *** + + *** *
;* *** + Utilities module *
;* *** + + *** *
;* *** +++ *** *
;* *** *** *
;* ************ *
;* ********** *
;* *
;*******************************************************************************************************
;* Various setup and run-time utility functions. *
;*******************************************************************************************************
;* Compiler: Keil A51 *
;* Target platform: 8051F005 *
;*******************************************************************************************************
;* Revision history: *
;* Initial release, HKI, 01.08.2004 *
;******************************************************************************************************/
NAME UTILITIES
#include <ASMinclude.h>
?PR?setRegs?UTILITIES SEGMENT CODE
?PR?clearMem?UTILITIES SEGMENT CODE?PR?setISRvector?UTILITIES SEGMENT CODE
?PR?audioOutClearAhead?UTILITIES SEGMENT CODE
PUBLIC setRegs
PUBLIC clearMem
PUBLIC setISRvector
PUBLIC audioOutClearAhead
;******************************************************************************************************
;* Functions *
;******************************************************************************************************
RSEG ?PR?setRegs?UTILITIESsetRegs:
; Set page and offsets for master and slave device
JB M_MASTER, SLAVE1
; Radio master
ORL systemFlagsPtr, #0x01
MOV audioInWriteLowB, #0x02 ; DPTR, inCodecISR() start page and offset
MOV audioInWritePage, #0x04
SETB RS0 ; Register bank 1
CLR RS1
MOV audioInReadLowB, #0x00 ; packetise() start addresses
MOV audioInReadPage, #0x04
MOV txBufferWritePage, #0x00
MOV txBufferWritePage, #0x03
MOV seqNo, #0xFF
CLR RS0 ; Register bank 2
SETB RS1
MOV txBufferReadLowB, #0x01 ; writeFIFO() start address (first write address is 0x00)
MOV txBufferReadPage, #0x03
;test, Register bank 3
SETB RS0
MOV R2, #0x04
MOV R0, #0x00
CLR RS0
CLR RS1
RET
SLAVE1:
; Radio slave
MOV audioOutReadLowB, #0x00 ; DPTR, outCodecISR()
MOV audioOutReadPage, #0x05
SETB RS0 ; Register bank 1
CLR RS1
MOV audioOutWriteLowB, #0x00 ; packetise() start addresses
MOV audioOutWritePage, #0x04
MOV rxBufferReadLowB, #0x00
MOV rxBufferReadPage, #0x03
MOV seqNo, #0x00
CLR RS0 ; Register bank 2
SETB RS1
MOV rxBufferWriteLowB, #0x01 ; readFIFO() start addresses
MOV rxBufferWritePage, #0x03 ; Pre-decremented pointer (first low byte write address is 0x00)
CLR RS1
RET
;*******************************************************************************************************
RSEG ?PR?clearMem?UTILITIES
clearMem:
CLR RS0
CLR RS1
CLR A
CLR C
MOV DPH, #0x08
MOV DPL, #0x00
X_DATA_CLEAR_NEXT:
MOVX @DPTR, A
DJNZ DPL, X_DATA_CLEAR_NEXT
DJNZ DPH, X_DATA_CLEAR_NEXT
RET
;*******************************************************************************************************
RSEG ?PR?setISRvector?UTILITIES
setISRvector:
; Set the ISR vector address for INT0.
; This could also be solved by a jump instruction inside codec ISR, but at the cost of speed.
; Note: Write back is not supported, so changing the jumper from Slave to
; Master will not work without rewriting the FLASH.
ORL PSCTL, #0x01 ; Enable FLASH write
MOV FLACL, #0x70 ; In case the code is above the default access limit
MOV FLSCL, #0x09 ; Set memory timer prescaler
MOV DPH, #0x00 ; The location of the vector (low byte of address)
MOV DPL, #0x05
JB M_MASTER, SLAVE2 ; Radio master (outCodecISR)
MOV A, #0x80
MOVX @DPTR, A ; Problem: cannot set a bit in FLASH without erasing the entire 512 byte block
ANL PSCTL, #0xFE
RET
SLAVE2: ; Radio slave (inCodecISR)
MOV A, #0x00
MOVX @DPTR, A
ANL PSCTL, #0xFE ; Disable FLASH write
RET
;*******************************************************************************************************
RSEG ?PR?audioOutClearAhead?UTILITIES
audioOutClearAhead:
PUSH PSW
PUSH ACC
MOV A, R0
PUSH ACC
PUSH PAGEREG
MOV PAGEREG, audioOutWritePage
INC PAGEREG ; Make sure we stay within the 1024 byte buffer
ORL PAGEREG, #0x04
ANL PAGEREG, #0x07
MOV audioOutWritePage, PAGEREG
MOV R0, #0x00
AUDIOOUT_CLEAR_NEXT:
CLR A
MOVX @R0, A
DJNZ R0, AUDIOOUT_CLEAR_NEXT
POP PAGEREG
POP ACC
MOV R0, ACC
POP ACC
POP PSW
RET
;*******************************************************************************************************
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -