?? sub_apply_menu_choice.s
字號:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: sub_apply_menu_choice.s,v $
; Revision 1.3 2005/04/04 23:39:13 VasukiH
; Updated comments in header
;
; Revision 1.2 2005/04/04 23:14:51 VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.1.1.1 2003/08/23 00:38:32 VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool Version
; --------------------------------------------------------------------------
; MPLAB IDE 7.0
; MPLAB C30 Toolsuite 1.30
; dsPICDEM(TM) Processor Board 1.10
; --------------------------------------------------------------------------
;
; File Notes:
;
;
;END_HEADER
.include "common.inc"
.include "p30fxxxx.inc"
.global BypassCtrl, ScreenSelection, CursorChanged
.section .ndata, data, near
.align 2
ScreenSelection:.hword 0x0000 ;Variable that tracks the selected Menu Screen
BypassCtrl: .hword 0x0000 ;In the most typical scenario, command and data
;bytes sent to the LCD Controller are interleaved
;In some cases, when consecutive data bytes need
;to be sent to the LCD controller, this flag is set
;to enable a decision block in the SPI2 ISR
CursorChanged: .hword 0xFFFF ;Flag that tracks whether the cursor in the DTMF
;screen needs to be changed from the current position
;or not.
.global _sub_apply_menu_choice
.section .text
_sub_apply_menu_choice:
push.d w0 ;Save w0, w1, w2 and w3
push.d w2
mov ScreenSelection, w0 ;Load w0 with current Menu Screen selection
mov SwitchPress, w1 ;Load w1 with the value of last switch pressed
cp w0, #0 ;Is Current Screen = 0 (Power-up screen)?
bra nz, CheckScreen1 ;If not then check Screen = 1
;Else,
btss w1, #1 ;In Screen 0 (Power-up Screen),
bra exit_routine ;only Switch S1 may be pressed.
;For any other switch, exit routine
mov #1, w2 ;For S1, change current screen to 1=Main Menu
mov w2, ScreenSelection
bra exit_routine
CheckScreen1:
cp w0, #1 ;Is current screen = 1 (Main Menu)?
bra nz, CheckScreen2 ;If not check Screen 2
btsc w1, #1 ;Else, check which switch was pressed
bra exit_routine ;If S1 was pressed in Screen1, then exit routine
btsc w1, #2 ;If S2 was pressed in Screen1, then set
bra SetScreen2 ;screen selection to 2 (Data Acquisition display)
btsc w1, #3 ;If S3 was pressed in Screen1, then set
bra SetScreen3 ;screen selection to 3 (DSP display)
btsc w1, #4 ;If S4 was pressed in Screen1, then set
bra SetScreen4 ;screen selection to 4 (DTMF display)
bra exit_routine
SetScreen2:
bclr SwitchPress, #2
mov #2, w2
mov w2, ScreenSelection
bra exit_routine
SetScreen3:
bclr SwitchPress, #3
mov #3, w2
mov w2, ScreenSelection
bra exit_routine
SetScreen4:
bclr SwitchPress, #4
mov #4, w2
mov w2, ScreenSelection
bra exit_routine
CheckScreen2:
cp w0, #2 ;Is current Screen selection = 2 (Data Acq.)?
bra nz, CheckScreen3 ;If not then check Screen = 3
btsc w1, #1 ;Else check the switch pressed.
bra DA_SetScreen1 ;If S1 was pressed in Screen 2, then set
;screen selection to Main Menu (Screen 1)
bra exit_routine ;Else exit routine
DA_SetScreen1:
mov #1, w2
mov w2, ScreenSelection
bra exit_routine
CheckScreen3:
cp w0, #3 ;Is current screen selection = 3 (DSP Display)?
bra nz, CheckScreen5 ;Else check screen 5 (DTMF with cursor enabled
;and positioned)
;NOTE: Screen=4 is a special DTMF screen without
;any cursor. Once Screen4 is displayed fully, the
;screen selection automatically changes to 5 and
;positions a cursor under the digits 0-9 on the
;DTMF screen. So User can never make any choices
;on screen 4
btsc w1, #1 ;If screen=3 then check switches
bra DSP_SetScreen1 ;If S1 was pressed set screen selection to 1 (Main
;Menu)
btsc w1, #2 ;If S2 was pressed, then change Filter Type
bra DSP_SetFilterType ;Three choices are cycled - FIR, IIR and No Filtering
bra exit_routine
DSP_SetScreen1:
mov #1, w2
mov w2, ScreenSelection
bra exit_routine
DSP_SetFilterType:
mov FilterType, w0
cp w0, #0
bra nz, CurFltTypeFir
CurFltTypeIir:
inc FilterType
mov #ANxInputSignal, w1
mov w1, ANxInputSignalPtr
bclr SwitchPress, #2
bra exit_routine
CurFltTypeFir:
cp w0, #1
bra nz, CurFltTypeNone
inc FilterType
mov #FilteredOutput, w1
mov w1, ANxInputSignalPtr
bclr SwitchPress, #2
bra exit_routine
CurFltTypeNone:
cp w0, #2
bra nz, exit_routine
clr FilterType
mov #ANxInputSignal, w1
mov w1, ANxInputSignalPtr
bclr SwitchPress, #2
bra exit_routine
CheckScreen5:
cp w0, #5 ;Is screen selection = 5 (DTMF with cursor)?
bra nz, exit_routine ;If not then exit routine.
btsc w1, #1 ;If yes, then examine Switch pressed
bra DTMF_SetScreen1 ;S1 will return to screen 1 (main menu)
btsc w1, #2
bra DTMF_IncCursor ;S2 will increment a cursor
btsc w1, #3
bra DTMF_SelectTone ;S3 will select the tone where cursor is
;positioned for playing
btsc w1, #4 ;S4 will initate playing a sequence of 10 digits
bra DTMF_PlaySeq
bra exit_routine
DTMF_SetScreen1:
mov #0x0001, w2
mov w2, ScreenSelection ;S1 always goes to Main Menu
mov #0, w2
mov w2, LcdCharCnt
mov.b #0x0A, w0
mov.b WREG, CursorPos
bclr SPI2STAT, #SPIROV ;Clear overflow flag
clr CtrlOrData
bset LATG, #LATG9 ;Deselect Slave LCD controller
bclr LATG, #LATG9 ;Select Slave LCD controller
mov.b SPI2BUF, WREG
mov.b #0x80, w0
mov.b WREG, SPI2BUF
wait_until_tx:
btss SPI2STAT, #SPIRBF
bra wait_until_tx
bra exit_routine
DTMF_IncCursor:
bclr SwitchPress, #2
inc.b CursorPos
mov.b CursorPos, WREG
cp.b w0, #0x13
bra le, NoCursorRollover
mov.b #0x0A, w0
NoCursorRollover:
mov.b WREG, CursorPos
setm CursorChanged
bra exit_routine
DTMF_SelectTone:
bclr SwitchPress, #3
btsc DCIUnavailable, #1 ;Is the DCI available for use?
bra exit_routine
mov CursorPos, w2
mov #DTMF_disp, w3
mov.b [w2+w3], w0 ;Offset into character array where
rcall _sub_dci_kickoff ;Digits are stored.
bra exit_routine
DTMF_PlaySeq:
bclr SwitchPress, #4
btsc DCIUnavailable, #1 ;Is the DCI available for use?
bra exit_routine
cp0 PlayRecSequence
bra nz, exit_routine
setm PlayRecSequence ;Set a flag indicating that a recorded
mov #DtmfSeq, w0 ;sequence will be played.
mov w0, DtmfSeqPtr
exit_routine:
pop.d w2 ;Restore w0, w1, w2 and w3
pop.d w0
return
.end ;EOF
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -