📄 洗衣机.s
字号:
andi R24,253
out 0x1b,R24
.dbline 311
L185:
.dbline 311
.dbline 312
; SPI_Write_Buf((WRITE_REG + TX_ADDR), TX_ADDRESS, TX_ADR_WIDTH); // Writes TX_Address to nRF24L01
ldi R24,5
std y+0,R24
ldi R18,<_TX_ADDRESS
ldi R19,>_TX_ADDRESS
ldi R16,48
xcall _SPI_Write_Buf
.dbline 313
; SPI_Write_Buf((WRITE_REG + RX_ADDR_P0), TX_ADDRESS, TX_ADR_WIDTH); // RX_Addr0 same as TX_Adr for Auto.Ack
ldi R24,5
std y+0,R24
ldi R18,<_TX_ADDRESS
ldi R19,>_TX_ADDRESS
ldi R16,42
xcall _SPI_Write_Buf
.dbline 314
; SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // Writes data to TX payload
ldi R24,2
std y+0,R24
ldi R18,<_tx_buf
ldi R19,>_tx_buf
ldi R16,160
xcall _SPI_Write_Buf
.dbline 315
; SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // Set PWR_UP bit, enable CRC(2 bytes) & Prim:TX. MAX_RT & TX_DS enabled..
ldi R18,14
ldi R16,32
xcall _SPI_RW_Reg
.dbline 316
; delay(1);
ldi R16,1
ldi R17,0
xcall _delay
L187:
.dbline 317
; CE_1;
.dbline 317
sbi 0x1b,1
.dbline 317
L188:
.dbline 317
.dbline -2
L183:
.dbline 0 ; func end
adiw R28,1
ret
.dbend
.dbfile F:\AVR洗衣机\洗衣机主机\driver.h
.dbfunc e Port_close _Port_close fV
.even
_Port_close::
.dbline -1
.dbline 16
; #include <iom16v.h>
; #include <macros.h>
; #include <bit.h>
; #include "define.h"
; #include "LCD_Driver.h"
; #include "Sounds_and_Display.h"
; #include "key.h"
; #include "PWM.h"
; #include "24L01_Driver.h"
; #define out_o_not if(flag_start==0)break
; #define PWM_off TCCR1A=0x00;TCCR1B = 0x00;DDR_PD4=0 //stop
; #define PWM_on TCCR1A=0x23;TCCR1B = 0x1A;DDR_PD4=1 //start
; uchar data_buff[2];
;
; void Port_close(void)
; {
.dbline 17
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 18
; DDRA = 0x00;
out 0x1a,R2
.dbline 19
; PORTB = 0x00;
out 0x18,R2
.dbline 20
; DDRB = 0x00;
out 0x17,R2
.dbline 21
; PORTC = 0x00;
out 0x15,R2
.dbline 22
; DDRC = 0x00;
out 0x14,R2
.dbline 23
; PORTD = 0x00;
out 0x12,R2
.dbline 24
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L190:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 28
; }
;
; void timer0_init(void)
; {
.dbline 29
; TCNT0 = 0x06; //set count
ldi R24,6
out 0x32,R24
.dbline 30
; TIMSK|=BIT(0);
in R24,0x39
ori R24,1
out 0x39,R24
.dbline 31
; SREG|=BIT(7);
bset 7
.dbline -2
L191:
.dbline 0 ; func end
ret
.dbend
.dbfunc e set_watlev _set_watlev fV
.even
_set_watlev::
st -y,R20
st -y,R21
sbiw R28,2
.dbline -1
.dbline 35
; }
;
; void set_watlev()//水位高3中2低1
; {
.dbline 36
; cls;
ldi R24,1
std y+0,R24
clr R18
clr R16
xcall _W_1byte
.dbline 37
; Delay(2);
ldi R16,2
ldi R17,0
xcall _Delay
.dbline 38
; Char_Set_XY(0,1,"水位设置:");
ldi R24,<L193
ldi R25,>L193
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
xcall _Char_Set_XY
.dbline 39
; switch(wat_lv)
lds R20,_wat_lv
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L201
X44:
cpi R20,2
ldi R30,0
cpc R21,R30
breq L199
X45:
cpi R20,3
ldi R30,0
cpc R21,R30
breq L197
X46:
xjmp L195
L197:
.dbline 41
; {
; case 3:Char_Set_XY(5,1,"高");break;
ldi R24,<L198
ldi R25,>L198
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 41
xjmp L195
L199:
.dbline 42
; case 2:Char_Set_XY(5,1,"中");break;
ldi R24,<L200
ldi R25,>L200
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 42
xjmp L195
L201:
.dbline 43
; case 1:Char_Set_XY(5,1,"低");break;
ldi R24,<L202
ldi R25,>L202
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 43
.dbline 44
; default:break;
L195:
.dbline 46
; }
; set_buff=0;
clr R2
sts _set_buff,R2
xjmp L204
L203:
.dbline 48
; while(nn==1&&flag_start==0)//水位设置标志位为1
; {
.dbline 49
; set_buff=key2_scan();
xcall _key2_scan
sts _set_buff,R16
.dbline 50
; wat_lv+=set_buff;
lds R3,_wat_lv
add R3,R16
sts _wat_lv,R3
.dbline 52
;
; if(BBBuffer==1)
lds R24,_BBBuffer
cpi R24,1
breq X55
xjmp L206
X55:
X47:
.dbline 53
; {
.dbline 54
; if(wat_lv>=4)//判断溢出
mov R24,R3
cpi R24,4
brlo L208
X48:
.dbline 55
; wat_lv=1;
ldi R24,1
sts _wat_lv,R24
L208:
.dbline 56
; if(wat_lv<=0)
ldi R24,0
lds R2,_wat_lv
cp R24,R2
brlo L210
X49:
.dbline 57
; wat_lv=3;
ldi R24,3
sts _wat_lv,R24
L210:
.dbline 58
; switch(wat_lv)
lds R20,_wat_lv
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L217
X50:
cpi R20,2
ldi R30,0
cpc R21,R30
breq L216
X51:
cpi R20,3
ldi R30,0
cpc R21,R30
breq L215
X52:
xjmp L213
L215:
.dbline 60
; {
; case 3:Char_Set_XY(5,1,"高");break;
ldi R24,<L198
ldi R25,>L198
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 60
xjmp L213
L216:
.dbline 61
; case 2:Char_Set_XY(5,1,"中");break;
ldi R24,<L200
ldi R25,>L200
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 61
xjmp L213
L217:
.dbline 62
; case 1:Char_Set_XY(5,1,"低");break;
ldi R24,<L202
ldi R25,>L202
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 62
.dbline 63
; default:break;
L213:
.dbline 65
; }
; BBBuffer=0;
clr R2
sts _BBBuffer,R2
.dbline 66
; data_buff[0]='w';
ldi R24,119
sts _data_buff,R24
.dbline 67
; data_buff[1]=wat_lv;
lds R2,_wat_lv
sts _data_buff+1,R2
.dbline 68
; Putstr(data_buff);
ldi R16,<_data_buff
ldi R17,>_data_buff
xcall _Putstr
.dbline 69
; }
L206:
.dbline 70
; key_scan();//扫描设置键盘
xcall _key_scan
.dbline 71
; }
L204:
.dbline 47
lds R24,_nn
cpi R24,1
brne L219
X53:
lds R2,_flag_start
tst R2
brne X56
xjmp L203
X56:
X54:
L219:
.dbline -2
L192:
.dbline 0 ; func end
adiw R28,2
ld R21,y+
ld R20,y+
ret
.dbend
.dbfunc e set_health _set_health fV
.even
_set_health::
st -y,R20
st -y,R21
sbiw R28,2
.dbline -1
.dbline 78
;
;
;
; }
;
; void set_health()//洗衣强度
; {
.dbline 80
;
; cls;//清屏
ldi R24,1
std y+0,R24
clr R18
clr R16
xcall _W_1byte
.dbline 81
; Delay(2);
ldi R16,2
ldi R17,0
xcall _Delay
.dbline 82
; Char_Set_XY(0,1,"洗衣强度:");
ldi R24,<L221
ldi R25,>L221
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
xcall _Char_Set_XY
.dbline 83
; Delay(1);
ldi R16,1
ldi R17,0
xcall _Delay
.dbline 84
; switch (health)
lds R20,_health
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L227
X57:
cpi R20,2
ldi R30,0
cpc R21,R30
breq L225
X58:
xjmp L223
L225:
.dbline 86
; {
; case 2:Char_Set_XY(5,1,"强");break;
ldi R24,<L226
ldi R25,>L226
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 86
xjmp L223
L227:
.dbline 87
; case 1:Char_Set_XY(5,1,"弱");break;
ldi R24,<L228
ldi R25,>L228
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 87
.dbline 88
; default:break;
L223:
.dbline 90
; }
; set_buff=0;
clr R2
sts _set_buff,R2
xjmp L230
L229:
.dbline 92
; while(nn==2&&flag_start==0)//洗衣强度标志位为2
; {
.dbline 93
; speed=health;
lds R2,_health
sts _speed,R2
.dbline 94
; set_buff=key2_scan();
xcall _key2_scan
sts _set_buff,R16
.dbline 95
; health+=set_buff;
lds R3,_health
add R3,R16
sts _health,R3
.dbline 96
; if(BBBuffer==1)
lds R24,_BBBuffer
cpi R24,1
brne L232
X59:
.dbline 97
; {
.dbline 98
; if(health>=3)//判断溢出
mov R24,R3
cpi R24,3
brlo L234
X60:
.dbline 99
; health=1;
ldi R24,1
sts _health,R24
L234:
.dbline 100
; if(health<=0)
ldi R24,0
lds R2,_health
cp R24,R2
brlo L236
X61:
.dbline 101
; health=2;
ldi R24,2
sts _health,R24
L236:
.dbline 102
; switch (health)
lds R20,_health
clr R21
cpi R20,1
ldi R30,0
cpc R21,R30
breq L242
X62:
cpi R20,2
ldi R30,0
cpc R21,R30
breq L241
X63:
xjmp L239
L241:
.dbline 104
; {
; case 2:Char_Set_XY(5,1,"强");break;
ldi R24,<L226
ldi R25,>L226
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 104
xjmp L239
L242:
.dbline 105
; case 1:Char_Set_XY(5,1,"弱");break;
ldi R24,<L228
ldi R25,>L228
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,5
xcall _Char_Set_XY
.dbline 105
.dbline 106
; default:break;
L239:
.dbline 108
; }
; BBBuffer=0;
clr R2
sts _BBBuffer,R2
.dbline 109
; data_buff[0]='h';
ldi R24,104
sts _data_buff,R24
.dbline 110
; data_buff[1]=health;
lds R2,_health
sts _data_buff+1,R2
.dbline 111
; Putstr(data_buff);
ldi R16,<_data_buff
ldi R17,>_data_buff
xcall _Putstr
.dbline 112
; }
L232:
.dbline 113
; key_scan();//扫描设置键盘
xcall _key_scan
.dbline 115
;
; }
L230:
.dbline 91
lds R24,_nn
cpi R24,2
brne L244
X64:
lds R2,_flag_start
tst R2
brne X66
xjmp L229
X66:
X65:
L244:
.dbline -2
L220:
.dbline 0 ; func end
adiw R28,2
ld R21,y+
ld R20,y+
ret
.dbend
.dbfunc e set_cycle _set_cycle fV
.even
_set_cycle::
sbiw R28,2
.dbline -1
.dbline 120
;
; }
;
; void set_cycle()//电动机循环次数
; {
.dbline 121
; cls;//清屏
ldi R24,1
std y+0,R24
clr R18
clr R16
xcall _W_1byte
.dbline 122
; Delay(2);
ldi R16,2
ldi R17,0
xcall _Delay
.dbline 123
; Char_Set_XY(0,1,"循环次数 次");
ldi R24,<L246
ldi R25,>L246
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
xcall _Char_Set_XY
.dbline 124
; Delay(1);
ldi R16,1
ldi R17,0
xcall _Delay
.dbline 125
; Char_Set_XY(4,1,":");
ldi R24,<L247
ldi R25,>L247
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,4
xcall _Char_Set_XY
.dbline 126
; W_1byte(0,1,0x30+cycle);
lds R24,_cycle
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
clr R16
xcall _W_1byte
.dbline 128
;
; set_buff=0;
clr R2
sts _set_buff,R2
xjmp L249
L248:
.dbline 130
; while(nn==3&&flag_start==0)//电动机循环设置标志位为3
; {
.dbline 132
; // display(cycle);
; set_buff=key2_scan();
xcall _key2_scan
sts _set_buff,R16
.dbline 133
; cycle+=set_buff;
lds R3,_cycle
add R3,R16
sts _cycle,R3
.dbline 134
; if(BBBuffer==1)
lds R24,_BBBuffer
cpi R24,1
brne L251
X67:
.dbline 135
; {
.dbline 136
; if(cycle>=10)//判断溢出
mov R24,R3
cpi R24,10
brlo L253
X68:
.dbline 137
; cycle=1;
ldi R24,1
sts _cycle,R24
L253:
.dbline 138
; if(cycle<=0)
ldi R24,0
lds R2,_cycle
cp R24,R2
brlo L255
X69:
.dbline 139
; cycle=9;
ldi R24,9
sts _cycle,R24
L255:
.dbline 140
; Char_Set_XY(4,1,":");
ldi R24,<L247
ldi R25,>L247
std y+1,R25
std y+0,R24
ldi R18,1
ldi R16,4
xcall _Char_Set_XY
.dbline 141
; W_1byte(0,1,0x30+cycle);//显示数字
lds R24,_cycle
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
clr R16
xcall _W_1byte
.dbline 142
; BBBuffer=0;
clr R2
sts _BBBuffer,R2
.dbline 143
; data_buff[0]='c';//发数据
ldi R24,99
sts _data_buff,R24
.dbline 144
; data_buff[1]=cycle;
lds R2,_cycle
sts _data_buff+1,R2
.dbline 145
; Putstr(data_buff);
ldi R16,<_data_buff
ldi R17,>_data_buff
xcall _Putstr
.dbline 146
; }
L251:
.dbline 147
; key_scan();//扫描设置键盘
xcall _key_scan
.dbline 149
;
; }
L249:
.dbline 129
lds R24,_nn
cpi R24,3
brne L258
X70:
lds R2,_flag_start
tst R2
brne X72
xjmp L248
X72:
X71:
L258:
.dbline -2
L245:
.dbline 0 ; func end
adiw R28,2
ret
.dbend
.dbfunc e set_replay _set_replay fV
.even
_set_replay::
sbiw R28,2
.dbline -1
.dbline 156
;
;
; }
;
;
; void set_replay()//洗衣加排水重复次数
; {
.dbline 157
; cls;//清屏
ldi R24,1
std y+0,R24
clr R18
clr R16
xcall _W_1byte
.dbline 158
; Delay(2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -