📄 bbu_keypad.s
字号:
;*******************************************************************************
;
; COPYRIGHT (C) 2006 Marvell International Ltd. All Rights Reserved.
;
; The information in this file is furnished for informational use only,
; is subject to change without notice, and should not be construed as
; a commitment by Marvell. Marvell assumes no responsibility or liability
; for any errors or inaccuracies that may appear in this software or any
; documenation that may be provided in association with this software.
;
;*******************************************************************************
;
; bbu_Keypad.s
;
;
INCLUDE xlli_PXA3xx_defs.inc
INCLUDE xlli_Platform_defs.inc
INCLUDE bbu_Monahans_defs.inc
INCLUDE bbu_Littleton_defs.inc
EXTERN xlli_MFPR_offset_table
EXTERN BBU_MFPR_setup ; Set up MFPR routine
EXTERN BBU_putchr ; Output a character
EXTERN BBU_putstr ; Output a string
EXTERN BBU_TXempty ; Wait for UART xmit to be empty
EXTERN BBU_crlf ; output a <cr><lf> pair to the UART
EXTERN BBU_getchr ; Get a character from the user's keyboard
EXTERN BBU_puthexd ; Output hex double word value
EXTERN BBU_msWait ; wait (in ms) routine
EXTERN BBU_BG_COLOR ; Sets LCD BackGround color
EXTERN BBU_TX_COLOR ; Sets LCD text color
EXTERN BBU_LCD_put7x11str ; Outputs a 7x11 font size character string
EXTERN BBU_LCD_put11x16str ; Outputs a 11x16 font size character string
EXTERN BBU_LCD_put16x20str ; Outputs a 16x20 font size character string
EXTERN BBU_LCD_scroll_up ; LCD scroll routine
EXTERN BBU_LCD_FRAME ; Select LCD frame buffer
EXTERN ISR_KEYPAD_KP ; KEYPAD data saved by ISR
EXTERN ISR_KEYPAD_SW ; KEYPAD scroll wheel data saved by ISR
EXTERN bbu_cmd_status ; BBU command status word
EXTERN BBU_ibuf ; BBU input bufer
EXTERN bbu_stat_data ; Location of BBU status word
GLOBAL BBU_Keypad_init ; Init the keypad
GLOBAL BBU_Keypad_test ; Keypad tests
GLOBAL BBU_KEYPAD_getchr ; Fetch the keypad status
GLOBAL BBU_KEYPAD_Enable_Int ; Enable keypad interrupts
GLOBAL BBU_KEYPAD_INPUT ; Process data from keypad interrupt
GLOBAL BBU_KEYPAD_putstr ; Outputs a string to the LCD (for use with keypad commands)
;
; KEYPAD REGISTERS base address and register offsets from the base address
;
bbu_KPC_offset EQU (0x00) ; Keypad Interface Control Register
bbu_KPDK_offset EQU (0x08) ; Keypad Interface Direct Key Register
bbu_KPREC_offset EQU (0x10) ; Keypad Interface Rotary Encoder Count Register
bbu_KPMK_offset EQU (0x18) ; Keypad Interface Matrix Key Register
bbu_KPAS_offset EQU (0x20) ; Keypad Interface Automatic Scan Register
bbu_KPASMKP0_offset EQU (0x28) ; Keypad Interface Automatic Scan Multiple Key Press Register 0
bbu_KPASMKP1_offset EQU (0x30) ; Keypad Interface Automatic Scan Multiple Key Press Register 1
bbu_KPASMKP2_offset EQU (0x38) ; Keypad Interface Automatic Scan Multiple Key Press Register 2
bbu_KPASMKP3_offset EQU (0x40) ; Keypad Interface Automatic Scan Multiple Key Press Register 3
bbu_KPKD1_offset EQU (0x48) ; Keypad Interface Key Debounce Interval Register
;
; KEYPAD related bit settings
;
bbu_KPC_ASACT EQU (1 << 29) ; Automatic Scan on Activity bit
bbu_KPC_MKRN EQU (7 << 26) ; Number of Keypad Rows - 1
bbu_KPC_MKCN EQU (7 << 23) ; Number of Keypad Columns - 1
bbu_KPC_MI EQU (1 << 22) ; Matrix interupt bit
bbu_KPC_IMKP EQU (1 << 21) ; Ignore Multiple Keypad Press bit
bbu_KPC_MS7 EQU (1 << 20) ; Matrix Scan Line 7
bbu_KPC_MS6 EQU (1 << 19) ; Matrix Scan Line 6
bbu_KPC_MS5 EQU (1 << 18) ; Matrix Scan Line 5
bbu_KPC_MS4 EQU (1 << 17) ; Matrix Scan Line 4
bbu_KPC_MS3 EQU (1 << 16) ; Matrix Scan Line 3
bbu_KPC_MS2 EQU (1 << 15) ; Matrix Scan Line 2
bbu_KPC_MS1 EQU (1 << 14) ; Matrix Scan Line 1
bbu_KPC_MS0 EQU (1 << 13) ; Matrix Scan Line 0
bbu_KPC_ME EQU (1 << 12) ; Matrix Keypad Enable bit
bbu_KPC_MIE EQU (1 << 11) ; Matrix Keypad Interrupt Enable bit
bbu_KPC_DKN EQU (2 << 6) ; Number of direct keypad inputs -1
bbu_KPC_DI EQU (1 << 5) ; Direct keypad interrupt bit
bbu_KPC_REE0 EQU (1 << 2) ; Rotary encoder 0 enable bit
bbu_KPC_DE EQU (1 << 1) ; Direct Keypad Enable bit
bbu_KPREC_Count0 EQU (0x7F) ; starting value for rotary encoder
bbu_KPKDI EQU (4) ; Keypad debouce time in mS (needs to be low for encoder to work)
AREA |text|,CODE,READONLY
;*********************************************************************************
;
; *******************
; * *
; * BBU_Keypad_init * Subroutine
; * *
; *******************
;
; This subroutine initalizes the keypad for use.
;
; PARAMETER PASSING:
;
; No parameters required
;
;
BBU_Keypad_init FUNCTION
;
; Enable Keypad Clock
;
stmfd sp!, {r0-r4, lr} ; Save used registers and link on stack
ldr r1, =xlli_CLKREGS_PHYSICAL_BASE ; Base address of clock unit
ldr r2, [r1, #xlli_D0CKEN_A_offset] ; Get current setting of clock enable register
orr r2, r2, #0x4000 ; Set bit 14 (Keypad Controller Clock Enable)
str r2, [r1, #xlli_D0CKEN_A_offset] ; Write the register back
;
; MFPR registers have been previously set up by the xlli_MFPR_table file
;
; Assemble the final value for the Keypad Interface Control Register (KPC) from values set
; in the program include file(s). (While this method takes more code than just plugging in the
; final value, it does give the code a little more structure and ease of changing parameters.)
;
ldr r1, =bbu_KEYPAD_PHYSICAL_BASE ; Get keypad registers base address
;
; Set up the Keypad Control Register
;
ldr r2, =(bbu_KPC_ASACT | bbu_KPC_MKRN | bbu_KPC_MKCN | bbu_KPC_ME \
| bbu_KPC_DKN | bbu_KPC_REE0 | bbu_KPC_DE \
| bbu_KPC_MS0 | bbu_KPC_MS1 | bbu_KPC_MS2 | bbu_KPC_MS3 \
| bbu_KPC_MS4 | bbu_KPC_MS5 )
str r2, [r1, #bbu_KPC_offset] ; Load Keypad Interface Control Register
;
; Set up keypad debounce time
;
mov r2, #bbu_KPKDI ; Get default debounce time from include file
str r2, [r1, #bbu_KPKD1_offset] ; Load debounce time into register
ldr r3, =bbu_KPREC_Count0 ; Get intal value for rotary encoder
str r3, [r1, #bbu_KPREC_offset] ; Update rotary encoder data
ldmfd sp!, {r0-r4, pc} ; Restore used registers and return to caller
ENDFUNC
;*********************************************************************************
;
; *******************
; * *
; * BBU_Keypad_test * Subroutine
; * *
; *******************
;
; This subroutine initalizes the keypad for use based on values in the include file(s)
;
; PARAMETER PASSING:
;
; No parameters required
;
BBU_Keypad_test FUNCTION
;
stmfd sp!, {r0-r12, lr} ; Save used registers and link on stack
;
; Disable any keypad interrupts that may have been set
;
mov r0, #0 ; Clear parameter
bl BBU_KEYPAD_Enable_Int ; Disable keypad interrupts
ldr r0, =BBU_KEYP_MSG1 ; Keypad Test message message
bl BBU_putstr ; Output message
mov r7, #0 ; Clear r7 (# input count)
;
; Wait for 0.07 sec with no input before accepting another input
;
542 mov r0, #70 ; Set up for 70 mS delay
bl BBU_msWait ; delay
bl bbu_Keypad_getchro ; Fetch data from the keypad
;
; An interrupt came in - Don't bother to dump the register contents if
; a key was released. This would be indicated by bits 7:0 all being set
; in the KPAS register (r4)
;
and r11, r4, #0xFF ; Look at bits 7:0
cmp r11, #0XFF ; are all the bits set?
moveq r9, #0XFF ; Yes - store 0xFF in r9
beq %F549 ; Yes - don't dump the values
and r10, r4, #0xFF ; Fetch bits 7:0
cmp r10, r9 ; Same key pressed as last time?
beq %F549 ; Yes - don't dump the value
and r9, r4, #0xFF ; Just save bits 7:0 in r9 for later use
;
; Check status word to see if BBU should do a register dump or decode the key
;
ldr r1, =bbu_stat_data ; Get address where system status data stored
ldr r2, [r1] ; Get system status word
ands r2, r2, #BBU_STAT_KEYR ; Test BBU Keypad Regester dump bit
bne %F548 ; It's set - do a register dump
;
; See if a multiple key press came in - inform user if one was detected
;
and r3, r4, #0xFF000000 ; Get upper byte of returned data
cmp r3, #0x08000000 ; Multiple key stroke?
bne %F545 ; No - skip over the following
ldr r0, =BBU_KEYP_MSG23 ; Multiple key message
bl BBU_putstr ; Output message
b %F549
;
; This code decodes the key pressed and displays the character on the
; terminal emulator.
;
545 ldr r1, =KEY_D ; Address of Key Data lookup table
and r3, r4, #0xFF ; Get value in bits 7:0
543 ldrb r5, [r1] ; get keyboard match entry
cmp r3, r5 ; Check for a match in table
bne %F544 ; No match
ldrb r0, [r1, #1] ; Match - get byte
cmp r0, #20 ; Compare byte value to 20
bls %F546 ; Special key
bl BBU_putchr ; Send character to user
b %F549 ; wait for another keystroke
544 add r1, r1, #2 ; Point to next table entry
ldrb r5, [r1] ; get byte
cmp r5, #0xFF ; end of list?
bne %B543 ; No
b %F549
;
; Special function key strokes
;
546 cmp r0, #1 ; Special function #1 <SOFT1>?
ldreq r0, =BBU_KEYP_SPK1 ;
cmp r0, #2 ; Special function #2 <SOFT2>?
ldreq r0, =BBU_KEYP_SPK2 ;
cmp r0, #5 ; Special function #3 <SEND>?
ldreq r0, =BBU_KEYP_SPK3 ;
cmp r0, #6 ; Special function #4 <END>?
ldreq r0, =BBU_KEYP_SPK4 ;
cmp r0, #3 ; Special function #5 <HOME>?
ldreq r0, =BBU_KEYP_SPK5 ;
cmp r0, #4 ; Special function #6 <BACK>?
ldreq r0, =BBU_KEYP_SPK6 ;
cmp r0, #7 ; Special function #7 <VOL_UP>?
ldreq r0, =BBU_KEYP_SPK7 ;
cmp r0, #8 ; Special function #8 <VOL_DN>?
ldreq r0, =BBU_KEYP_SPK8 ;
cmp r0, #9 ; Special function #8 <UP>?
ldreq r0, =BBU_KEYP_SPK9 ;
cmp r0, #10 ; Special function #9 <DOWN>?
ldreq r0, =BBU_KEYP_SPK10 ;
cmp r0, #11 ; Special function #10 <LEFT>?
ldreq r0, =BBU_KEYP_SPK11 ;
cmp r0, #12 ; Special function #11 <RIGHT>?
ldreq r0, =BBU_KEYP_SPK12 ;
cmp r0, #13 ; Special function #12 <OK>?
ldreq r0, =BBU_KEYP_SPK13 ;
bl BBU_putstr ; Output message
b %F549
;
; Keypad register dump goes here
;
548 ldr r0, =BBU_KEYP_MSG5 ; Keypad Test message
bl BBU_putstr ; Output message
mov r0, r4 ; Move data to R3
bl BBU_puthexd ; Output hex value of data
bl BBU_crlf ; output <CR><LF> pair
ldr r0, =BBU_KEYP_MSG6 ; Keypad Test message
bl BBU_putstr ; Output message
mov r0, r5 ; Move data to R3
bl BBU_puthexd ; Output hex value of data
bl BBU_crlf ; output <CR><LF> pair
ldr r0, =BBU_KEYP_MSG7 ; Keypad Test message
bl BBU_putstr ; Output message
mov r0, r6 ; Move data to R3
bl BBU_puthexd ; Output hex value of data
bl BBU_crlf ; output <CR><LF> pair
ldr r0, =BBU_KEYP_MSG8 ; Keypad Test message
bl BBU_putstr ; Output message
mov r0, r7 ; Move data to R3
bl BBU_puthexd ; Output hex value of data
bl BBU_crlf ; output <CR><LF> pair
ldr r0, =BBU_KEYP_MSG9 ; Keypad Test message
bl BBU_putstr ; Output message
mov r0, r8 ; Move data to R3
bl BBU_puthexd ; Output hex value of data
bl BBU_crlf ; output <CR><LF> pair
ldr r0, =BBU_KEYP_MSG10 ; Keypad Test message message
bl BBU_putstr ; Output message
mov r0, r12 ; Move data to R0
bl BBU_puthexd ; Output hex value of data
ldr r0, =BBU_KEYP_MSG11 ; Scroll wheel Test message
bl BBU_putstr ; Output message
;
; See if there was a key press
;
549 bl BBU_TXempty ; Required for IrDA interface
bl BBU_getchr
cmp r0, #0 ; Did a character come in?
beq %B542 ; If not, Go back to 1st read
bic r4, r0, #0x20 ; Convert any lower case byte to upper case in r4
cmp r4, #'R' ; Was a R entered?
bne %F103 ; No - skip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -