📄 main.s
字号:
sbci R17,255
xcall _M41T0_SendInfo
; }
L114:
ldi R18,8
movw R16,R28
subi R16,198 ; offset = 58
sbci R17,255
xcall _M41T0_ReadInfo
ldd R2,y+58
std y+28,R2
L81:
xjmp L80
X1:
L79:
adiw R28,63
adiw R28,10 ; offset = 73
.dbline 0 ; func end
ret
.area vector(rom, abs)
.org 4
jmp _int0_isr
.area text(rom, con, rel)
.even
_int0_isr::
st -y,R24
in R24,0x3f
st -y,R24
;
; //读取M41T0时间
; M41T0_ReadInfo(M41T0Data, 8);
; CurrTimeInfo[0] = M41T0Data[0];
; }
; }
;
; /**********************************************************************
; functionName:void int0_isr(void)
; description:外部键盘中断0函数
; **********************************************************************/
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
; cKeyRiseEvent = 1;
ldi R24,1
sts _cKeyRiseEvent,R24
L116:
ld R24,y+
out 0x3f,R24
ld R24,y+
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 72
jmp _int2_isr
.area text(rom, con, rel)
.even
_int2_isr::
; }
;
; /**********************************************************************
; functionName:void int2_isr(void)
; description:外部中断2函数
; **********************************************************************/
; #pragma interrupt_handler int2_isr:19
; void int2_isr(void)
; {}
L117:
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 36
jmp _timer0_ovf_isr
.area text(rom, con, rel)
.even
_timer0_ovf_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
;
; /**********************************************************************
; functionName:void timer0_ovf_isr(void)
; description:定时器0溢出中断,20mSec
; **********************************************************************/
; #pragma interrupt_handler timer0_ovf_isr:10
; void timer0_ovf_isr(void)
; {
; TCNT0 = 0x71; //溢出时,重新加载新值
ldi R24,113
out 0x32,R24
;
; if (gTmr0OvrCount)
lds R2,_gTmr0OvrCount
lds R3,_gTmr0OvrCount+1
tst R2
brne X6
tst R3
breq L119
X6:
; gTmr0OvrCount --;
lds R24,_gTmr0OvrCount
lds R25,_gTmr0OvrCount+1
sbiw R24,1
sts _gTmr0OvrCount+1,R25
sts _gTmr0OvrCount,R24
L119:
L118:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 76
jmp _timer0_comp_isr
.area text(rom, con, rel)
.even
_timer0_comp_isr::
; }
;
; /**********************************************************************
; functionName:void timer0_ovf_isr(void)
; description:定时器0比较中断
; **********************************************************************/
; #pragma interrupt_handler timer0_comp_isr:20
; void timer0_comp_isr(void)
; {}
L121:
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 36
jmp _timer2_ovf_isr
.area text(rom, con, rel)
.even
_timer2_ovf_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
;
;
; /**********************************************************************
; functionName:void timer2_ovf_isr(void)
; description:定时器2溢出中断,500mSec
; **********************************************************************/
; #pragma interrupt_handler timer2_ovf_isr:10
; void timer2_ovf_isr(void)
; {
; TCNT2 = 0x71; //溢出时,重新加载新值
ldi R24,113
out 0x24,R24
;
; if (gTmr2OvrCount)
lds R2,_gTmr2OvrCount
lds R3,_gTmr2OvrCount+1
tst R2
brne X7
tst R3
breq L123
X7:
; gTmr2OvrCount --;
lds R24,_gTmr2OvrCount
lds R25,_gTmr2OvrCount+1
sbiw R24,1
sts _gTmr2OvrCount+1,R25
sts _gTmr2OvrCount,R24
L123:
L122:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 40
jmp _spi_stc_isr
.area text(rom, con, rel)
.even
_spi_stc_isr::
; }
;
; /**********************************************************************
; functionName:void spi_stc_isr(void)
; description:SPI中断函数
; **********************************************************************/
; #pragma interrupt_handler spi_stc_isr:11
; void spi_stc_isr(void)
; {}
L125:
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 44
jmp _uart0_rx_isr
.area text(rom, con, rel)
.even
_uart0_rx_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
st -y,R30
st -y,R31
in R2,0x3f
st -y,R2
;
; /**********************************************************************
; functionName:void uart0_rx_isr(void)
; description:串口接受中断函数,完成上位机的回传全部消费记录数据
; **********************************************************************/
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; {
; //接收数据后清零RXC标记
; UartRecvBuffer[UartRecvIndex++] = UDR;
lds R2,_UartRecvIndex
clr R3
mov R24,R2
subi R24,255 ; addi 1
sts _UartRecvIndex,R24
ldi R24,<_UartRecvBuffer
ldi R25,>_UartRecvBuffer
mov R30,R2
clr R31
add R30,R24
adc R31,R25
in R2,0xc
std z+0,R2
; if (UartRecvIndex >= RECVBUFFERLEN)
lds R24,_UartRecvIndex
cpi R24,14
brlo L127
; {
; gbRecvPCFrameCmd = 1; //接收完整一桢数据标记
ldi R24,1
sts _gbRecvPCFrameCmd,R24
; UartRecvIndex = 0;
clr R2
sts _UartRecvIndex,R2
; }
L127:
; //RXC位清零
; UCSRA &= ~(1<<RXC);
cbi 0xb,7
L126:
ld R2,y+
out 0x3f,R2
ld R31,y+
ld R30,y+
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 52
jmp _uart0_tx_isr
.area text(rom, con, rel)
.even
_uart0_tx_isr::
; }
;
; /**********************************************************************
; functionName:void uart0_tx_isr(void)
; description:串口发送中断函数
; **********************************************************************/
; #pragma interrupt_handler uart0_tx_isr:14
; void uart0_tx_isr(void)
; {}
L129:
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 56
jmp _adc_isr
.area text(rom, con, rel)
.even
_adc_isr::
;
; /**********************************************************************
; functionName:void adc_isr(void)
; description:ADC中断函数
; **********************************************************************/
; #pragma interrupt_handler adc_isr:15
; void adc_isr(void)
; {}
L130:
.dbline 0 ; func end
reti
.area vector(rom, abs)
.org 68
jmp _twi_isr
.area text(rom, con, rel)
; status -> R20
.even
_twi_isr::
xcall push_lset
xcall push_gset1
;
; #pragma interrupt_handler twi_isr:18
; void twi_isr(void) //通信模式为主机发送和接收模式
; {
; unsigned char status;
; status = TWSR & 0xf8;
in R20,0x1
andi R20,248
;
; switch(status)
clr R21
cpi R20,48
ldi R30,0
cpc R21,R30
brne X9
xjmp L142
X9:
ldi R24,48
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L148
L147:
cpi R20,24
ldi R30,0
cpc R21,R30
brne X10
xjmp L136
X10:
ldi R24,24
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L150
L149:
cpi R20,8
ldi R30,0
cpc R21,R30
brne X11
xjmp L135
X11:
cpi R20,8
ldi R30,0
cpc R21,R30
brge X12
xjmp L132
X12:
L151:
cpi R20,16
ldi R30,0
cpc R21,R30
brne X13
xjmp L135
X13:
xjmp L132
L150:
cpi R20,32
ldi R30,0
cpc R21,R30
brne X14
xjmp L142
X14:
cpi R20,32
ldi R30,0
cpc R21,R30
brge X15
xjmp L132
X15:
L152:
cpi R20,40
ldi R30,0
cpc R21,R30
breq L136
xjmp L132
L148:
cpi R20,72
ldi R30,0
cpc R21,R30
brne X16
xjmp L142
X16:
ldi R24,72
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L154
L153:
cpi R20,56
ldi R30,0
cpc R21,R30
brne X17
xjmp L140
X17:
cpi R20,56
ldi R30,0
cpc R21,R30
brge X18
xjmp L132
X18:
L155:
cpi R20,64
ldi R30,0
cpc R21,R30
brne X19
xjmp L133
X19:
xjmp L132
L154:
cpi R20,80
ldi R30,0
cpc R21,R30
brne X20
xjmp L143
X20:
cpi R20,80
ldi R30,0
cpc R21,R30
brge X21
xjmp L132
X21:
L156:
cpi R20,88
ldi R30,0
cpc R21,R30
breq L141
xjmp L132
X8:
; {
L135:
; case TW_START: //0x08: START 已发送
; case TW_REP_START: //0x10: 重复START 已发送
; i2cSendByte(I2cSendData[0]); //开始传送从地址
lds R16,_I2cSendData
xcall _i2cSendByte
; break;
xjmp L133
L136:
;
; // 主机发送模式,接收状态码
; case TW_MT_SLA_ACK: //0x18: SLA+W 已发送;接收到从机ACK
; case TW_MT_DATA_ACK: //0x28: 数据已发送;接收到从机ACK
; if(I2cSendDataIndex < I2cSendDataLength)
lds R2,_I2cSendDataLength
lds R3,_I2cSendDataIndex
cp R3,R2
brsh L137
; {
; gbi2cSendByteStatus = TRUE;
ldi R24,1
sts _gbi2cSendByteStatus,R24
; i2cSendByte(I2cSendData[1+I2cSendDataIndex] );
ldi R24,<_I2cSendData+1
ldi R25,>_I2cSendData+1
mov R30,R3
clr R31
add R30,R24
adc R31,R25
ldd R16,z+0
xcall _i2cSendByte
; I2cSendDataIndex++;
lds R24,_I2cSendDataIndex
subi R24,255 ; addi 1
sts _I2cSendDataIndex,R24
; }
xjmp L133
L137:
; else
; {
; i2cSendStop();
xcall _i2cSendStop
; }
; break;
xjmp L133
L140:
;
;
; case TW_MTR_ARB_LOST: //0x38: SLA+W 或数据的仲裁失败
; gbi2cSendCmdStatus = FALSE;
clr R2
sts _gbi2cSendCmdStatus,R2
; TWCR = (TWCR&0x0F)|(1<<TWINT); // 释放总线
in R24,0x36
andi R24,15
ori R24,128
out 0x36,R24
; break;
xjmp L133
L141:
;
;
; // 主机接收模式时的状态码
; case TW_MR_DATA_NACK: //0x58: 主机接收到从机数据;主机未给从机ACK
; // 保存数据
; I2cReceiveData[I2cReceiveDataIndex++] = TWDR;
lds R2,_I2cReceiveDataIndex
clr R3
mov R24,R2
subi R24,255 ; addi 1
sts _I2cReceiveDataIndex,R24
ldi R24,<_I2cReceiveData
ldi R25,>_I2cReceiveData
mov R30,R2
clr R31
add R30,R24
adc R31,R25
in R2,0x3
std z+0,R2
L142:
; //继续发送条件
; case TW_MR_SLA_NACK: //0x48: 主机已发送SLA+R,主机未接收到从机ACK
; case TW_MT_SLA_NACK: //0x20: SLA+W 已发送,未接收到从机ACK
; case TW_MT_DATA_NACK: //0x30: 数据已发送,未接收从机ACK
; gbi2cSendCmdStatus = FALSE;
clr R2
sts _gbi2cSendCmdStatus,R2
; // 发送停止条件
; i2cSendStop();
xcall _i2cSendStop
; break;
xjmp L133
L143:
;
;
; case TW_MR_DATA_ACK: //0x50: 主机接收到从机数据,主机已给从机ACK信号
; gbi2cRecvByteStatus = TRUE;
ldi R24,1
sts _gbi2cRecvByteStatus,R24
; // 保存接收到的数据位
; I2cReceiveData[I2cReceiveDataIndex++] = TWDR;
lds R2,_I2cReceiveDataIndex
clr R3
mov R24,R2
subi R24,255 ; addi 1
sts _I2cReceiveDataIndex,R24
ldi R24,<_I2cReceiveData
ldi R25,>_I2cReceiveData
mov R30,R2
clr R31
add R30,R24
adc R31,R25
in R2,0x3
std z+0,R2
;
; // 检查是否接收完
; //if(I2cReceiveDataIndex < (I2cReceiveDataLength-1))
; // 数据位将接收 , 回复 ACK (传送更多字节)
; //i2cAckSignal(TRUE);
; //else
; if(I2cReceiveDataIndex >= I2cReceiveDataLength )
lds R2,_I2cReceiveDataLength
lds R3,_I2cReceiveDataIndex
cp R3,R2
brlo L133
; { // 数据位将接收 , 主机先回复 从机NACK (传送最后字节)
; i2cAckSignal(FALSE);
clr R16
xcall _i2cAckSignal
; // 主机再发送停止条件
; i2cSendStop();
xcall _i2cSendStop
; }
; case TW_MR_SLA_ACK: //0x40: 主机已发送SLA+R,从机已ACK,主机准备接收数据
; break;
L132:
L133:
L131:
xcall pop_gset1
xcall pop_lset
.dbline 0 ; func end
reti
.area bss(ram, con, rel)
_I2cSendData::
.blkb 16
_I2cReceiveData::
.blkb 16
_Snr_RC500::
.blkb 4
_UartRecvBuffer::
.blkb 14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -