📄 main.ls
字号:
3402 007b 72195011 bres _PD_DDR,#4
3405 007f 72185012 bset _PD_CR1,#4
3406 ; 35 DELAY();
3410 0083 9d nop
3415 0084 9d nop
3420 0085 9d nop
3425 0086 9d nop
3430 0087 9d nop
3432 ; 36 if(!GET_SCK)
3435 0088 c65010 ld a,_PD_IDR
3436 008b a510 bcp a,#16
3437 008d 262c jrne L3312
3438 ; 38 if((rcvBits>0) && (rcvBits<9))
3440 008f 3d00 tnz L3112_rcvBits
3441 0091 2713 jreq L5312
3443 0093 b600 ld a,L3112_rcvBits
3444 0095 a109 cp a,#9
3445 0097 240d jruge L5312
3446 ; 40 keyVal=keyVal>>1; //数据是LSB格式
3448 0099 3440 srl _keyVal
3449 ; 43 if(GET_SDA)
3451 009b c65010 ld a,_PD_IDR
3452 009e a508 bcp a,#8
3453 00a0 2704 jreq L5312
3454 ; 44 keyVal=keyVal|0x80;
3456 00a2 721e0040 bset _keyVal,#7
3457 00a6 L5312:
3458 ; 46 rcvBits++;
3460 00a6 3c00 inc L3112_rcvBits
3462 00a8 L3412:
3463 ; 47 while(!GET_SCK); //等待PS/2CLK拉高
3465 00a8 c65010 ld a,_PD_IDR
3466 00ab a510 bcp a,#16
3467 00ad 27f9 jreq L3412
3468 ; 49 if(rcvBits>10)
3470 00af b600 ld a,L3112_rcvBits
3471 00b1 a10b cp a,#11
3472 00b3 2506 jrult L3312
3473 ; 51 rcvBits=0; //接收11次表示接收完一帧数据
3475 00b5 3f00 clr L3112_rcvBits
3476 ; 52 rcvF=1; //标识有字符已经输入
3478 00b7 72100000 bset _rcvF
3479 00bb L3312:
3480 ; 55 }
3483 00bb 81 ret
3486 switch .bit
3487 0001 L1512_isUp:
3488 0001 00 dc.b 0
3489 0002 L3512_shift:
3490 0002 00 dc.b 0
3554 ; 58 u8 keyHandle(u8 val)
3554 ; 59 {
3555 switch .text
3556 00bc _keyHandle:
3558 00bc 88 push a
3559 00bd 88 push a
3560 00000001 OFST: set 1
3563 ; 63 rcvF = 0;
3565 00be 72110000 bres _rcvF
3566 ; 65 if(!isUp)
3568 btst L1512_isUp
3569 00c7 2403 jruge L22
3570 00c9 cc015a jp L3222
3571 00cc L22:
3572 ; 67 switch(val)
3574 00cc 7b02 ld a,(OFST+1,sp)
3576 ; 107 return val;
3577 00ce a012 sub a,#18
3578 00d0 271a jreq L7512
3579 00d2 a047 sub a,#71
3580 00d4 271c jreq L1612
3581 00d6 a097 sub a,#151
3582 00d8 270b jreq L5512
3583 00da L3612:
3584 ; 78 default:
3584 ; 79 if(!shift) // If shift not pressed
3586 btst L3512_shift
3587 00df 2545 jrult L1322
3588 ; 85 for(i=0;unshifted[i][0]!=val && i<59; i++);
3590 00e1 0f01 clr (OFST+0,sp)
3592 00e3 2015 jra L7322
3593 00e5 L5512:
3594 ; 69 case 0xF0 : // a relase action
3594 ; 70 isUp = 1;
3596 00e5 72100001 bset L1512_isUp
3597 ; 71 break;
3599 00e9 cc016e jra L5622
3600 00ec L7512:
3601 ; 72 case 0x12 : // Left shift
3601 ; 73 shift = 1;
3603 00ec 72100002 bset L3512_shift
3604 ; 74 break;
3606 00f0 207c jra L5622
3607 00f2 L1612:
3608 ; 75 case 0x59 : // Right shift
3608 ; 76 shift = 1;
3610 00f2 72100002 bset L3512_shift
3611 ; 77 break;
3613 00f6 2076 jra L5622
3614 00f8 L3322:
3615 ; 85 for(i=0;unshifted[i][0]!=val && i<59; i++);
3618 00f8 0c01 inc (OFST+0,sp)
3619 00fa L7322:
3622 00fa 7b01 ld a,(OFST+0,sp)
3623 00fc 5f clrw x
3624 00fd 97 ld xl,a
3625 00fe 58 sllw x
3626 00ff d60000 ld a,(_unshifted,x)
3627 0102 1102 cp a,(OFST+1,sp)
3628 0104 2706 jreq L3422
3630 0106 7b01 ld a,(OFST+0,sp)
3631 0108 a13b cp a,#59
3632 010a 25ec jrult L3322
3633 010c L3422:
3634 ; 86 if(unshifted[i][0] == val)
3636 010c 7b01 ld a,(OFST+0,sp)
3637 010e 5f clrw x
3638 010f 97 ld xl,a
3639 0110 58 sllw x
3640 0111 d60000 ld a,(_unshifted,x)
3641 0114 1102 cp a,(OFST+1,sp)
3642 0116 2656 jrne L5622
3643 ; 89 val = unshifted[i][1];
3645 0118 7b01 ld a,(OFST+0,sp)
3646 011a 5f clrw x
3647 011b 97 ld xl,a
3648 011c 58 sllw x
3649 011d d60001 ld a,(_unshifted+1,x)
3650 0120 6b02 ld (OFST+1,sp),a
3651 ; 90 return val;
3653 0122 7b02 ld a,(OFST+1,sp)
3655 0124 2030 jra L02
3656 0126 L1322:
3657 ; 101 for(i=0;shifted[i][0]!=val && i<59; i++);
3659 0126 0f01 clr (OFST+0,sp)
3661 0128 2002 jra L5522
3662 012a L1522:
3666 012a 0c01 inc (OFST+0,sp)
3667 012c L5522:
3670 012c 7b01 ld a,(OFST+0,sp)
3671 012e 5f clrw x
3672 012f 97 ld xl,a
3673 0130 58 sllw x
3674 0131 d60078 ld a,(_shifted,x)
3675 0134 1102 cp a,(OFST+1,sp)
3676 0136 2706 jreq L1622
3678 0138 7b01 ld a,(OFST+0,sp)
3679 013a a13b cp a,#59
3680 013c 25ec jrult L1522
3681 013e L1622:
3682 ; 103 if(shifted[i][0] == val)
3684 013e 7b01 ld a,(OFST+0,sp)
3685 0140 5f clrw x
3686 0141 97 ld xl,a
3687 0142 58 sllw x
3688 0143 d60078 ld a,(_shifted,x)
3689 0146 1102 cp a,(OFST+1,sp)
3690 0148 2624 jrne L5622
3691 ; 106 val = shifted[i][1];
3693 014a 7b01 ld a,(OFST+0,sp)
3694 014c 5f clrw x
3695 014d 97 ld xl,a
3696 014e 58 sllw x
3697 014f d60079 ld a,(_shifted+1,x)
3698 0152 6b02 ld (OFST+1,sp),a
3699 ; 107 return val;
3701 0154 7b02 ld a,(OFST+1,sp)
3703 0156 L02:
3705 0156 85 popw x
3706 0157 81 ret
3707 0158 L7222:
3709 0158 2014 jra L5622
3710 015a L3222:
3711 ; 115 isUp=0;
3713 015a 72110001 bres L1512_isUp
3714 ; 116 switch(val)
3716 015e 7b02 ld a,(OFST+1,sp)
3718 ; 123 break;
3719 0160 a012 sub a,#18
3720 0162 2706 jreq L5612
3721 0164 a047 sub a,#71
3722 0166 270a jreq L7612
3723 0168 2004 jra L5622
3724 016a L5612:
3725 ; 118 case 0x12 : // Left SHIFT
3725 ; 119 shift = 0;
3727 016a 72110002 bres L3512_shift
3728 ; 120 break;
3729 016e L5622:
3730 ; 126 return 0xff;
3732 016e a6ff ld a,#255
3734 0170 20e4 jra L02
3735 0172 L7612:
3736 ; 121 case 0x59 : // Right SHIFT
3736 ; 122 shift = 0;
3738 0172 72110002 bres L3512_shift
3739 ; 123 break;
3741 0176 20f6 jra L5622
3742 0178 L1722:
3743 0178 20f4 jra L5622
3845 ; 17 void SPI_Init(void)
3845 ; 18 {
3846 switch .text
3847 017a _SPI_Init:
3851 ; 19 SPI_CR1|=0x38; //波特率
3853 017a c65200 ld a,_SPI_CR1
3854 017d aa38 or a,#56
3855 017f c75200 ld _SPI_CR1,a
3856 ; 24 SPI_CR2|=0x03; //配置NSS脚为1
3858 0182 c65201 ld a,_SPI_CR2
3859 0185 aa03 or a,#3
3860 0187 c75201 ld _SPI_CR2,a
3861 ; 25 SPI_CR1|=0x04; //配置为主设备
3863 018a 72145200 bset _SPI_CR1,#2
3864 ; 26 SPI_CR1|=0x40; //开启SPI
3866 018e 721c5200 bset _SPI_CR1,#6
3867 ; 27 }
3870 0192 81 ret
3906 ; 29 void SPI_sendchar(u8 data)
3906 ; 30 {
3907 switch .text
3908 0193 _SPI_sendchar:
3912 ; 31 SPI_DR=data;
3914 0193 c75204 ld _SPI_DR,a
3916 0196 L3632:
3917 ; 32 while(!(SPI_SR & 0x02));
3919 0196 c65203 ld a,_SPI_SR
3920 0199 a502 bcp a,#2
3921 019b 27f9 jreq L3632
3922 ; 33 }
3925 019d 81 ret
3961 ; 35 u8 SPI_rechar(void)
3961 ; 36 {
3962 switch .text
3963 019e _SPI_rechar:
3965 019e 88 push a
3966 00000001 OFST: set 1
3969 ; 38 data=SPI_DR;
3971 019f c65204 ld a,_SPI_DR
3972 01a2 6b01 ld (OFST+0,sp),a
3974 01a4 L1142:
3975 ; 39 while(!(SPI_SR & 0x01));
3977 01a4 c65203 ld a,_SPI_SR
3978 01a7 a501 bcp a,#1
3979 01a9 27f9 jreq L1142
3980 ; 40 return data;
3982 01ab 7b01 ld a,(OFST+0,sp)
3985 01ad 5b01 addw sp,#1
3986 01af 81 ret
4045 ; 21 void st7920LcdInit(void)
4045 ; 22 {
4046 switch .text
4047 01b0 _st7920LcdInit:
4049 01b0 88 push a
4050 00000001 OFST: set 1
4053 ; 24 SPI_Init();
4055 01b1 adc7 call _SPI_Init
4057 ; 25 delay_ms(100);
4059 01b3 ae0064 ldw x,#100
4060 01b6 cd0000 call _delay_ms
4062 ; 26 PE_DDR|=0x20;
4064 01b9 721a5016 bset _PE_DDR,#5
4065 ; 27 PE_CR1|=0x20;
4067 01bd 721a5017 bset _PE_CR1,#5
4068 ; 28 PE_CR2|=0x20;
4070 01c1 721a5018 bset _PE_CR2,#5
4071 ; 29 sendCodeST7920(0x0c);//整体显示
4073 01c5 a60c ld a,#12
4074 01c7 ad1c call _sendCodeST7920
4076 ; 30 sendCodeST7920(0x01);//清屏
4078 01c9 a601 ld a,#1
4079 01cb ad18 call _sendCodeST7920
4081 ; 31 sendCodeST7920(0x02);
4083 01cd a602 ld a,#2
4084 01cf ad14 call _sendCodeST7920
4086 ; 32 for(i=0;i<64;i++)
4088 01d1 0f01 clr (OFST+0,sp)
4089 01d3 L1442:
4090 ; 33 lcd_buffer[i]=' ';
4092 01d3 7b01 ld a,(OFST+0,sp)
4093 01d5 5f clrw x
4094 01d6 97 ld xl,a
4095 01d7 a620 ld a,#32
4096 01d9 e700 ld (_lcd_buffer,x),a
4097 ; 32 for(i=0;i<64;i++)
4099 01db 0c01 inc (OFST+0,sp)
4102 01dd 7b01 ld a,(OFST+0,sp)
4103 01df a140 cp a,#64
4104 01e1 25f0 jrult L1442
4105 ; 35 }
4108 01e3 84 pop a
4109 01e4 81 ret
4146 ; 37 void sendCodeST7920(u8 Lcd_cmd)
4146 ; 38 {
4147 switch .text
4148 01e5 _sendCodeST7920:
4150 01e5 88 push a
4151 00000000 OFST: set 0
4154 ; 39 E_CLK
4156 01e6 721b5014 bres _PE_ODR,#5
4157 ; 40 LCD_DELAY()
4160 01ea 9d nop
4165 01eb 9d nop
4170 01ec 9d nop
4175 01ed 9d nop
4180 01ee 9d nop
4182 ; 41 E_SET
4184 01ef 721a5014 bset _PE_ODR,#5
4185 ; 42 SPI_sendchar(0xF8);
4187 01f3 a6f8 ld a,#248
4188 01f5 ad9c call _SPI_sendchar
4190 ; 43 SPI_sendchar(Lcd_cmd & 0xF0);
4192 01f7 7b01 ld a,(OFST+1,sp)
4193 01f9 a4f0 and a,#240
4194 01fb ad96 call _SPI_sendchar
4196 ; 44 SPI_sendchar(Lcd_cmd << 4);
4198 01fd 7b01 ld a,(OFST+1,sp)
4199 01ff 97 ld xl,a
4200 0200 a610 ld a,#16
4201 0202 42 mul x,a
4202 0203 9f ld a,xl
4203 0204 ad8d call _SPI_sendchar
4205 ; 45 LCD_DELAY()
4208 0206 9d nop
4213 0207 9d nop
4218 0208 9d nop
4223 0209 9d nop
4228 020a 9d nop
4230 ; 46 E_CLK
4232 020b 721b5014 bres _PE_ODR,#5
4233 ; 47 LCD_DELAY()
4236 020f 9d nop
4241 0210 9d nop
4246 0211 9d nop
4251 0212 9d nop
4256 0213 9d nop
4258 ; 48 }
4261 0214 84 pop a
4262 0215 81 ret
4299 ; 50 void sendDataST7920(u8 Lcd_data)
4299 ; 51 {
4300 switch .text
4301 0216 _sendDataST7920:
4303 0216 88 push a
4304 00000000 OFST: set 0
4307 ; 52 E_CLK
4309 0217 721b5014 bres _PE_ODR,#5
4310 ; 53 LCD_DELAY()
4313 021b 9d nop
4318 021c 9d nop
4323 021d 9d nop
4328 021e 9d nop
4333 021f 9d nop
4335 ; 54 E_SET
4337 0220 721a5014 bset _PE_ODR,#5
4338 ; 55 SPI_sendchar(0xFA);
4340 0224 a6fa ld a,#250
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -