📄 readswitch.s
字号:
.module ReadSwitch.c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\LCU904~1\固件程序\ReadSwitch.c
.area bss(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\LCU904~1\固件程序\ReadSwitch.c
L3:
.blkb 2
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\LCU904~1\固件程序\ReadSwitch.c
.dbfunc e ReadHC165Switch _ReadHC165Switch fV
.dbstruct 0 3 ReadHC165Switch
.dbfield 0 Device_Address c
.dbfield 1 HC165Switch A[2:2]c
.dbend
.dbsym s Read_buffer L3 pc
; Readwitch -> R16,R17
; i -> R18
; j -> R20
; ret -> R16
.even
_ReadHC165Switch::
st -y,R20
.dbline -1
.dbline 22
;
; #include"include.h"
;
; #define CLK 7
; #define SH_LD 5
;
;
; #define SER_SL_HI() DDRB |= (1<<SH_LD)
; #define SER_SL_LO() DDRB &= ~(1<<SH_LD) //SH/LD 接PB5
;
; #define SER_CK_HI() DDRB |= (1<<CLK)
; #define SER_CK_LO() DDRB &= ~(1<<CLK) //SCK 接 PB7
;
; #define CLK_EN_HI() DDRB |= (1<<4)
; #define CLK_EN_LO() DDRB &= (1<<4)
;
; #define HC165Switch_Port() (PINB&(1<<6)) //输入 QH 接PB6
;
; //------------------------------------------------------------------------------
; //读AVR控制器地址码和扩展口的按键
; void ReadHC165Switch(void)
; {
.dbline 25
; static unsigned char *Read_buffer;
; struct ReadHC165Switch *Readwitch;
; unsigned char i,j,ret = 0xff;
ldi R16,255
.dbline 26
; Read_buffer = Read74HC165Switch;
ldi R24,<_Read74HC165Switch
ldi R25,>_Read74HC165Switch
sts L3+1,R25
sts L3,R24
.dbline 27
; CLK_EN_LO();
in R24,0x17
andi R24,16
out 0x17,R24
.dbline 29
; //数据锁存,在shift/load输入一脉冲
; SER_CK_LO();
cbi 0x17,7
.dbline 30
; SER_SL_HI();
sbi 0x17,5
.dbline 31
; asm("nop");
nop
.dbline 32
; SER_SL_LO();
cbi 0x17,5
.dbline 33
; asm("nop");
nop
.dbline 34
; SER_SL_HI();
sbi 0x17,5
.dbline 35
; asm("nop");
nop
.dbline 36
; asm("nop");
nop
.dbline 38
; //读数据
; for(i=0;i<sizeof(struct ReadHC165Switch);i++)
clr R18
xjmp L7
L4:
.dbline 39
; {
.dbline 40
; for(j=0;j<8;j++)
clr R20
xjmp L11
L8:
.dbline 41
; {
.dbline 42
; SER_CK_HI();
sbi 0x17,7
.dbline 43
; if(HC165Switch_Port()==0)
sbic 0x16,6
rjmp L12
X0:
.dbline 44
; {
.dbline 45
; ret <<= 1;
lsl R16
.dbline 46
; ret &= ~0x01;
andi R16,254
.dbline 47
; }
xjmp L13
L12:
.dbline 49
; else
; {
.dbline 50
; ret <<= 1;
lsl R16
.dbline 51
; ret |= 0x01;
ori R16,1
.dbline 52
; }
L13:
.dbline 53
; asm("nop");
nop
.dbline 54
; asm("nop");
nop
.dbline 55
; SER_CK_LO();
cbi 0x17,7
.dbline 56
; asm("nop");
nop
.dbline 57
; asm("nop");
nop
.dbline 58
; }
L9:
.dbline 40
inc R20
L11:
.dbline 40
cpi R20,8
brlo L8
X1:
.dbline 59
; *Read_buffer++ = ret;
lds R30,L3
lds R31,L3+1
st Z+,R16
sts L3+1,R31
sts L3,R30
.dbline 60
; }
L5:
.dbline 38
inc R18
L7:
.dbline 38
cpi R18,3
brlo L4
X2:
.dbline 61
; Readwitch = (struct ReadHC165Switch *)Read74HC165Switch;
ldi R16,<_Read74HC165Switch
ldi R17,>_Read74HC165Switch
.dbline -2
L2:
.dbline 0 ; func end
ld R20,y+
ret
.dbsym r Readwitch 16 pS[ReadHC165Switch]
.dbsym r i 18 c
.dbsym r j 20 c
.dbsym r ret 16 c
.dbend
.dbfunc e ReadSwitch _ReadSwitch fV
; i -> R16
.even
_ReadSwitch::
.dbline -1
.dbline 66
; }
; //------------------------------------------------------------------------------
; //扫描按键 PA,PC端口
; void ReadSwitch(void)
; {
.dbline 68
; unsigned char i;
; ReadSwitchPINA = 0;
clr R2
sts _ReadSwitchPINA,R2
.dbline 69
; ReadSwitchPINC = 0;
sts _ReadSwitchPINC,R2
.dbline 70
; for(i=0; i<40; i++);
clr R16
xjmp L18
L15:
.dbline 70
L16:
.dbline 70
inc R16
L18:
.dbline 70
cpi R16,40
brlo L15
X3:
.dbline 71
; if(!(PINA & 0x80)) ReadSwitchPINA |= 0x80;
sbic 0x19,7
rjmp L19
X4:
.dbline 71
lds R24,_ReadSwitchPINA
ori R24,128
sts _ReadSwitchPINA,R24
L19:
.dbline 72
; if(!(PINA & 0x40)) ReadSwitchPINA |= 0x40;
sbic 0x19,6
rjmp L21
X5:
.dbline 72
lds R24,_ReadSwitchPINA
ori R24,64
sts _ReadSwitchPINA,R24
L21:
.dbline 73
; if(!(PINA & 0x20)) ReadSwitchPINA |= 0x20;
sbic 0x19,5
rjmp L23
X6:
.dbline 73
lds R24,_ReadSwitchPINA
ori R24,32
sts _ReadSwitchPINA,R24
L23:
.dbline 74
; if(!(PINA & 0x10)) ReadSwitchPINA |= 0x10;
sbic 0x19,4
rjmp L25
X7:
.dbline 74
lds R24,_ReadSwitchPINA
ori R24,16
sts _ReadSwitchPINA,R24
L25:
.dbline 75
; if(!(PINA & 0x08)) ReadSwitchPINA |= 0x08;
sbic 0x19,3
rjmp L27
X8:
.dbline 75
lds R24,_ReadSwitchPINA
ori R24,8
sts _ReadSwitchPINA,R24
L27:
.dbline 76
; if(!(PINA & 0x04)) ReadSwitchPINA |= 0x04;
sbic 0x19,2
rjmp L29
X9:
.dbline 76
lds R24,_ReadSwitchPINA
ori R24,4
sts _ReadSwitchPINA,R24
L29:
.dbline 77
; if(!(PINA & 0x02)) ReadSwitchPINA |= 0x02;
sbic 0x19,1
rjmp L31
X10:
.dbline 77
lds R24,_ReadSwitchPINA
ori R24,2
sts _ReadSwitchPINA,R24
L31:
.dbline 78
; if(!(PINA & 0x01)) ReadSwitchPINA |= 0x01;
sbic 0x19,0
rjmp L33
X11:
.dbline 78
lds R24,_ReadSwitchPINA
ori R24,1
sts _ReadSwitchPINA,R24
L33:
.dbline 79
; for(i=0; i<40; i++);
clr R16
xjmp L38
L35:
.dbline 79
L36:
.dbline 79
inc R16
L38:
.dbline 79
cpi R16,40
brlo L35
X12:
.dbline 80
; if(!(PINC & 0x80)) ReadSwitchPINC |= 0x80;
sbic 0x13,7
rjmp L39
X13:
.dbline 80
lds R24,_ReadSwitchPINC
ori R24,128
sts _ReadSwitchPINC,R24
L39:
.dbline 81
; if(!(PINC & 0x40)) ReadSwitchPINC |= 0x40;
sbic 0x13,6
rjmp L41
X14:
.dbline 81
lds R24,_ReadSwitchPINC
ori R24,64
sts _ReadSwitchPINC,R24
L41:
.dbline 82
; if(!(PINC & 0x20)) ReadSwitchPINC |= 0x20;
sbic 0x13,5
rjmp L43
X15:
.dbline 82
lds R24,_ReadSwitchPINC
ori R24,32
sts _ReadSwitchPINC,R24
L43:
.dbline 83
; if(!(PINC & 0x10)) ReadSwitchPINC |= 0x10;
sbic 0x13,4
rjmp L45
X16:
.dbline 83
lds R24,_ReadSwitchPINC
ori R24,16
sts _ReadSwitchPINC,R24
L45:
.dbline 84
; if(!(PINC & 0x08)) ReadSwitchPINC |= 0x08;
sbic 0x13,3
rjmp L47
X17:
.dbline 84
lds R24,_ReadSwitchPINC
ori R24,8
sts _ReadSwitchPINC,R24
L47:
.dbline 85
; if(!(PINC & 0x04)) ReadSwitchPINC |= 0x04;
sbic 0x13,2
rjmp L49
X18:
.dbline 85
lds R24,_ReadSwitchPINC
ori R24,4
sts _ReadSwitchPINC,R24
L49:
.dbline 86
; if(!(PINC & 0x02)) ReadSwitchPINC |= 0x02;
sbic 0x13,1
rjmp L51
X19:
.dbline 86
lds R24,_ReadSwitchPINC
ori R24,2
sts _ReadSwitchPINC,R24
L51:
.dbline 87
; if(!(PINC & 0x01)) ReadSwitchPINC |= 0x01;
sbic 0x13,0
rjmp L53
X20:
.dbline 87
lds R24,_ReadSwitchPINC
ori R24,1
sts _ReadSwitchPINC,R24
L53:
.dbline -2
L14:
.dbline 0 ; func end
ret
.dbsym r i 16 c
.dbend
.dbfunc e communication_ReadSwitch _communication_ReadSwitch fV
.even
_communication_ReadSwitch::
.dbline -1
.dbline 93
;
; }
; //------------------------------------------------------------------------------
; //------------------------------------------------------------------------------
; void communication_ReadSwitch(void)
; {
.dbline -2
L55:
.dbline 0 ; func end
ret
.dbend
;
;
;
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -