📄 main.ls
字号:
3675 018f 97 ld xl,a
3676 0190 a60a ld a,#10
3677 0192 cd0000 call c_smodx
3679 0195 1f01 ldw (OFST-1,sp),x
3680 0197 7b03 ld a,(OFST+1,sp)
3681 0199 5f clrw x
3682 019a 97 ld xl,a
3683 019b a60a ld a,#10
3684 019d cd0000 call c_sdivx
3686 01a0 58 sllw x
3687 01a1 58 sllw x
3688 01a2 58 sllw x
3689 01a3 58 sllw x
3690 01a4 72fb01 addw x,(OFST-1,sp)
3691 01a7 01 rrwa x,a
3692 01a8 6b03 ld (OFST+1,sp),a
3693 01aa 02 rlwa x,a
3694 ; 95 minute=changeIntToHex(minute);
3696 01ab 7b04 ld a,(OFST+2,sp)
3697 01ad 5f clrw x
3698 01ae 97 ld xl,a
3699 01af a60a ld a,#10
3700 01b1 cd0000 call c_smodx
3702 01b4 1f01 ldw (OFST-1,sp),x
3703 01b6 7b04 ld a,(OFST+2,sp)
3704 01b8 5f clrw x
3705 01b9 97 ld xl,a
3706 01ba a60a ld a,#10
3707 01bc cd0000 call c_sdivx
3709 01bf 58 sllw x
3710 01c0 58 sllw x
3711 01c1 58 sllw x
3712 01c2 58 sllw x
3713 01c3 72fb01 addw x,(OFST-1,sp)
3714 01c6 01 rrwa x,a
3715 01c7 6b04 ld (OFST+2,sp),a
3716 01c9 02 rlwa x,a
3717 ; 96 second=changeIntToHex(second);
3719 01ca 7b07 ld a,(OFST+5,sp)
3720 01cc 5f clrw x
3721 01cd 97 ld xl,a
3722 01ce a60a ld a,#10
3723 01d0 cd0000 call c_smodx
3725 01d3 1f01 ldw (OFST-1,sp),x
3726 01d5 7b07 ld a,(OFST+5,sp)
3727 01d7 5f clrw x
3728 01d8 97 ld xl,a
3729 01d9 a60a ld a,#10
3730 01db cd0000 call c_sdivx
3732 01de 58 sllw x
3733 01df 58 sllw x
3734 01e0 58 sllw x
3735 01e1 58 sllw x
3736 01e2 72fb01 addw x,(OFST-1,sp)
3737 01e5 01 rrwa x,a
3738 01e6 6b07 ld (OFST+5,sp),a
3739 01e8 02 rlwa x,a
3740 ; 98 WriteAByte(HOUR_DATA_BUF,hour);
3742 01e9 7b03 ld a,(OFST+1,sp)
3743 01eb 97 ld xl,a
3744 01ec a604 ld a,#4
3745 01ee 95 ld xh,a
3746 01ef cd00c8 call _WriteAByte
3748 ; 99 WriteAByte(MINUTE_DATA_BUF,minute);
3750 01f2 7b04 ld a,(OFST+2,sp)
3751 01f4 97 ld xl,a
3752 01f5 a603 ld a,#3
3753 01f7 95 ld xh,a
3754 01f8 cd00c8 call _WriteAByte
3756 ; 100 WriteAByte(SECOND_DATA_BUF,second);
3758 01fb 7b07 ld a,(OFST+5,sp)
3759 01fd 97 ld xl,a
3760 01fe a602 ld a,#2
3761 0200 95 ld xh,a
3762 0201 cd00c8 call _WriteAByte
3764 ; 101 }
3767 0204 5b04 addw sp,#4
3768 0206 81 ret
3823 ; 103 void PCF8563_init(u8 hour,u8 mintue,u8 second)
3823 ; 104 {
3824 switch .text
3825 0207 _PCF8563_init:
3827 0207 89 pushw x
3828 00000000 OFST: set 0
3831 ; 105 I2C_Init();
3833 0208 cd004c call _I2C_Init
3835 ; 106 WriteAByte(CTRL_BUF1,0x00); //basic setting
3837 020b 5f clrw x
3838 020c 4f clr a
3839 020d 95 ld xh,a
3840 020e cd00c8 call _WriteAByte
3842 ; 107 WriteAByte(CTRL_BUF2,0x00);
3844 0211 5f clrw x
3845 0212 a601 ld a,#1
3846 0214 95 ld xh,a
3847 0215 cd00c8 call _WriteAByte
3849 ; 108 PCF8563_setTime(hour,mintue,second);
3851 0218 7b05 ld a,(OFST+5,sp)
3852 021a 88 push a
3853 021b 7b03 ld a,(OFST+3,sp)
3854 021d 97 ld xl,a
3855 021e 7b02 ld a,(OFST+2,sp)
3856 0220 95 ld xh,a
3857 0221 cd018a call _PCF8563_setTime
3859 0224 84 pop a
3860 ; 112 }
3863 0225 85 popw x
3864 0226 81 ret
3906 ; 17 void SPI_Init(void)
3906 ; 18 {
3907 switch .text
3908 0227 _SPI_Init:
3912 ; 19 SPI_CR1|=0x38; //波特率
3914 0227 c65200 ld a,_SPI_CR1
3915 022a aa38 or a,#56
3916 022c c75200 ld _SPI_CR1,a
3917 ; 24 SPI_CR2|=0x03; //配置NSS脚为1
3919 022f c65201 ld a,_SPI_CR2
3920 0232 aa03 or a,#3
3921 0234 c75201 ld _SPI_CR2,a
3922 ; 25 SPI_CR1|=0x04; //配置为主设备
3924 0237 72145200 bset _SPI_CR1,#2
3925 ; 26 SPI_CR1|=0x40; //开启SPI
3927 023b 721c5200 bset _SPI_CR1,#6
3928 ; 27 }
3931 023f 81 ret
3967 ; 29 void SPI_sendchar(u8 data)
3967 ; 30 {
3968 switch .text
3969 0240 _SPI_sendchar:
3973 ; 31 SPI_DR=data;
3975 0240 c75204 ld _SPI_DR,a
3977 0243 L5542:
3978 ; 32 while(!(SPI_SR & 0x02));
3980 0243 c65203 ld a,_SPI_SR
3981 0246 a502 bcp a,#2
3982 0248 27f9 jreq L5542
3983 ; 33 }
3986 024a 81 ret
4022 ; 35 u8 SPI_rechar(void)
4022 ; 36 {
4023 switch .text
4024 024b _SPI_rechar:
4026 024b 88 push a
4027 00000001 OFST: set 1
4030 ; 38 data=SPI_DR;
4032 024c c65204 ld a,_SPI_DR
4033 024f 6b01 ld (OFST+0,sp),a
4035 0251 L3052:
4036 ; 39 while(!(SPI_SR & 0x01));
4038 0251 c65203 ld a,_SPI_SR
4039 0254 a501 bcp a,#1
4040 0256 27f9 jreq L3052
4041 ; 40 return data;
4043 0258 7b01 ld a,(OFST+0,sp)
4046 025a 5b01 addw sp,#1
4047 025c 81 ret
4106 ; 21 void st7920LcdInit(void)
4106 ; 22 {
4107 switch .text
4108 025d _st7920LcdInit:
4110 025d 88 push a
4111 00000001 OFST: set 1
4114 ; 24 SPI_Init();
4116 025e adc7 call _SPI_Init
4118 ; 25 delay_ms(100);
4120 0260 ae0064 ldw x,#100
4121 0263 cd0000 call _delay_ms
4123 ; 26 PE_DDR|=0x20;
4125 0266 721a5016 bset _PE_DDR,#5
4126 ; 27 PE_CR1|=0x20;
4128 026a 721a5017 bset _PE_CR1,#5
4129 ; 28 PE_CR2|=0x20;
4131 026e 721a5018 bset _PE_CR2,#5
4132 ; 29 sendCodeST7920(0x0c);//整体显示
4134 0272 a60c ld a,#12
4135 0274 ad1c call _sendCodeST7920
4137 ; 30 sendCodeST7920(0x01);//清屏
4139 0276 a601 ld a,#1
4140 0278 ad18 call _sendCodeST7920
4142 ; 31 sendCodeST7920(0x02);
4144 027a a602 ld a,#2
4145 027c ad14 call _sendCodeST7920
4147 ; 32 for(i=0;i<64;i++)
4149 027e 0f01 clr (OFST+0,sp)
4150 0280 L3352:
4151 ; 33 lcd_buffer[i]=' ';
4153 0280 7b01 ld a,(OFST+0,sp)
4154 0282 5f clrw x
4155 0283 97 ld xl,a
4156 0284 a620 ld a,#32
4157 0286 e700 ld (_lcd_buffer,x),a
4158 ; 32 for(i=0;i<64;i++)
4160 0288 0c01 inc (OFST+0,sp)
4163 028a 7b01 ld a,(OFST+0,sp)
4164 028c a140 cp a,#64
4165 028e 25f0 jrult L3352
4166 ; 35 }
4169 0290 84 pop a
4170 0291 81 ret
4207 ; 37 void sendCodeST7920(u8 Lcd_cmd)
4207 ; 38 {
4208 switch .text
4209 0292 _sendCodeST7920:
4211 0292 88 push a
4212 00000000 OFST: set 0
4215 ; 39 E_CLK
4217 0293 721b5014 bres _PE_ODR,#5
4218 ; 40 LCD_DELAY()
4221 0297 9d nop
4226 0298 9d nop
4231 0299 9d nop
4236 029a 9d nop
4241 029b 9d nop
4243 ; 41 E_SET
4245 029c 721a5014 bset _PE_ODR,#5
4246 ; 42 SPI_sendchar(0xF8);
4248 02a0 a6f8 ld a,#248
4249 02a2 ad9c call _SPI_sendchar
4251 ; 43 SPI_sendchar(Lcd_cmd & 0xF0);
4253 02a4 7b01 ld a,(OFST+1,sp)
4254 02a6 a4f0 and a,#240
4255 02a8 ad96 call _SPI_sendchar
4257 ; 44 SPI_sendchar(Lcd_cmd << 4);
4259 02aa 7b01 ld a,(OFST+1,sp)
4260 02ac 97 ld xl,a
4261 02ad a610 ld a,#16
4262 02af 42 mul x,a
4263 02b0 9f ld a,xl
4264 02b1 ad8d call _SPI_sendchar
4266 ; 45 LCD_DELAY()
4269 02b3 9d nop
4274 02b4 9d nop
4279 02b5 9d nop
4284 02b6 9d nop
4289 02b7 9d nop
4291 ; 46 E_CLK
4293 02b8 721b5014 bres _PE_ODR,#5
4294 ; 47 LCD_DELAY()
4297 02bc 9d nop
4302 02bd 9d nop
4307 02be 9d nop
4312 02bf 9d nop
4317 02c0 9d nop
4319 ; 48 }
4322 02c1 84 pop a
4323 02c2 81 ret
4360 ; 50 void sendDataST7920(u8 Lcd_data)
4360 ; 51 {
4361 switch .text
4362 02c3 _sendDataST7920:
4364 02c3 88 push a
4365 00000000 OFST: set 0
4368 ; 52 E_CLK
4370 02c4 721b5014 bres _PE_ODR,#5
4371 ; 53 LCD_DELAY()
4374 02c8 9d nop
4379 02c9 9d nop
4384 02ca 9d nop
4389 02cb 9d nop
4394 02cc 9d nop
4396 ; 54 E_SET
4398 02cd 721a5014 bset _PE_ODR,#5
4399 ; 55 SPI_sendchar(0xFA);
4401 02d1 a6fa ld a,#250
4402 02d3 cd0240 call _SPI_sendchar
4404 ; 56 SPI_sendchar(Lcd_data & 0xF0);
4406 02d6 7b01 ld a,(OFST+1,sp)
4407 02d8 a4f0 and a,#240
4408 02da cd0240 call _SPI_sendchar
4410 ; 57 SPI_sendchar(Lcd_data << 4);
4412 02dd 7b01 ld a,(OFST+1,sp)
4413 02df 97 ld xl,a
4414 02e0 a610 ld a,#16
4415 02e2 42 mul x,a
4416 02e3 9f ld a,xl
4417 02e4 cd0240 call _SPI_sendchar
4419 ; 58 LCD_DELAY()
4422 02e7 9d nop
4427 02e8 9d nop
4432 02e9 9d nop
4437 02ea 9d nop
4442 02eb 9d nop
4444 ; 59 E_CLK
4446 02ec 721b5014 bres _PE_ODR,#5
4447 ; 60 LCD_DELAY()
4450 02f0 9d nop
4455 02f1 9d nop
4460 02f2 9d nop
4465 02f3 9d nop
4470 02f4 9d nop
4472 ; 61 }
4475 02f5 84 pop a
4476 02f6 81 ret
4522 ; 63 void refreshLCD(const u8 *lcd_stack)
4522 ; 64 {
4523 switch .text
4524 02f7 _refreshLCD:
4526 02f7 89 pushw x
4527 02f8 88 push a
4528 00000001 OFST: set 1
4531 ; 66 sendCodeST7920(0x02); //地址归位
4533 02f9 a602 ld a,#2
4534 02fb ad95 call _sendCodeST7920
4536 ; 67 for(addr=0;addr<16;addr++)
4538 02fd 0f01 clr (OFST+0,sp)
4539 02ff L7162:
4540 ; 69 sendDataST7920(*(lcd_stack + addr));
4542 02ff 7b02 ld a,(OFST+1,sp)
4543 0301 97 ld xl,a
4544 0302 7b03 ld a,(OFST+2,sp)
4545 0304 1b01 add a,(OFST+0,sp)
4546 0306 2401 jrnc L45
4547 0308 5c incw x
4548 0309 L45:
4549 0309 02 rlwa x,a
4550 030a f6 ld a,(x)
4551 030b adb6 call _sendDataST7920
4553 ; 67 for(addr=0;addr<16;addr++)
4555 030d 0c01 inc (OFST+0,sp)
4558 030f 7b01 ld a,(OFST+0,sp)
4559 0311 a110 cp a,#16
4560 0313 25ea jrult L7162
4561 ; 71 for(addr=32;addr<48;addr++)
4563 0315 a620 ld a,#32
4564 0317 6b01 ld (OFST+0,sp),a
4565 0319 L5262:
4566 ; 73 sendDataST7920(*(lcd_stack + addr));
4568 0319 7b02 ld a,(OFST+1,sp)
4569 031b 97 ld xl,a
4570 031c 7b03 ld a,(OFST+2,sp)
4571 031e 1b01 add a,(OFST+0,sp)
4572 0320 2401 jrnc L65
4573 0322 5c incw x
4574 0323 L65:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -