📄 nrf905.s
字号:
xcall _nrf905_SpiRW
.dbline 215
; for (i=0;i<10;i++)
clr R10
xjmp L16
L13:
.dbline 216
.dbline 217
clr R16
xcall _nrf905_SpiRW
ldi R24,<_RxBuf
ldi R25,>_RxBuf
mov R30,R10
clr R31
add R30,R24
adc R31,R25
std z+0,R16
.dbline 218
L14:
.dbline 215
inc R10
L16:
.dbline 215
mov R24,R10
cpi R24,10
brlo L13
.dbline 222
; {
; RxBuf[i]=nrf905_SpiRW(0);//read from nrf905
; }
;
;
; //for (i=0;i<10;i++)
; {
.dbline 223
; if(RxBuf[0]==CH_NO_BYTE)CPL(PORTD,LED);
lds R24,_RxBuf
cpi R24,76
brne L17
.dbline 223
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L17:
.dbline 224
; if(RxBuf[1]==(PA_PWR_10dBm | HFREQ_PLL_433MHz))CPL(PORTD,LED);
lds R24,_RxBuf+1
cpi R24,12
brne L19
.dbline 224
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L19:
.dbline 225
; if(RxBuf[2]==(TX_AFW_4BYTE | RX_AFW_4BYTE))CPL(PORTD,LED);
lds R24,_RxBuf+2
cpi R24,68
brne L22
.dbline 225
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L22:
.dbline 226
; if(RxBuf[3]==RX_PW_1BYTE)CPL(PORTD,LED);
lds R24,_RxBuf+3
cpi R24,1
brne L25
.dbline 226
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L25:
.dbline 227
; if(RxBuf[4]==TX_PW_1BYTE)CPL(PORTD,LED);
lds R24,_RxBuf+4
cpi R24,1
brne L28
.dbline 227
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L28:
.dbline 228
; if(RxBuf[5]==(RX_ADDRESS_0))CPL(PORTD,LED);
ldi R20,18
ldi R21,0
ldi R22,0
ldi R23,0
lds R2,_RxBuf+5
clr R3
clr R4
clr R5
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
brne L31
.dbline 228
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L31:
.dbline 229
; if(RxBuf[6]==RX_ADDRESS_1)CPL(PORTD,LED);
ldi R20,52
ldi R21,0
ldi R22,0
ldi R23,0
lds R2,_RxBuf+6
clr R3
clr R4
clr R5
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
brne L34
.dbline 229
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
L34:
.dbline 234
; //if(RxBuf[7]==RX_ADDRESS_2)CPL(PORTD,LED);
; //if(RxBuf[8]==RX_ADDRESS_3)CPL(PORTD,LED);
; //if(RxBuf[9]==(CRC16_EN | XOF_16MHz))CPL(PORTD,LED);
;
; }
.dbline 235
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L12:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 10 c
.dbend
.dbfunc e nrf905_SetTxAddr _nrf905_SetTxAddr fV
.even
_nrf905_SetTxAddr::
.dbline -1
.dbline 240
; }
;
; //写Tx地址
; void nrf905_SetTxAddr()
; {
.dbline 241
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 242
; nrf905_SpiRW(WTA); //写Tx地址
ldi R16,34
xcall _nrf905_SpiRW
.dbline 243
; nrf905_SpiRW(TX_ADDRESS_0);
ldi R16,135
xcall _nrf905_SpiRW
.dbline 244
; nrf905_SpiRW(TX_ADDRESS_1);
ldi R16,101
xcall _nrf905_SpiRW
.dbline 245
; nrf905_SpiRW(TX_ADDRESS_2);
ldi R16,67
xcall _nrf905_SpiRW
.dbline 246
; nrf905_SpiRW(TX_ADDRESS_3);
ldi R16,33
xcall _nrf905_SpiRW
.dbline 247
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L37:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SetData _nrf905_SetData fV
; i -> R20
.even
_nrf905_SetData::
xcall push_gset1
.dbline -1
.dbline 252
; }
;
; //写Tx数据
; void nrf905_SetData()
; {uchar i;
.dbline 254
;
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 255
; nrf905_SpiRW(WTP); //写TxPayload
ldi R16,32
xcall _nrf905_SpiRW
.dbline 256
; for (i=0;i<SIZE;i++)
clr R20
xjmp L42
L39:
.dbline 257
.dbline 258
ldi R24,<_TxBuf
ldi R25,>_TxBuf
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R16,z+0
xcall _nrf905_SpiRW
.dbline 259
L40:
.dbline 256
inc R20
L42:
.dbline 256
cpi R20,32
brlo L39
.dbline 261
; {
; nrf905_SpiRW(TxBuf[i]);
; }
;
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L38:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e nrf905_WaitSended _nrf905_WaitSended fV
.even
_nrf905_WaitSended::
.dbline -1
.dbline 266
; }
;
; //等待发送结束
; void nrf905_WaitSended()
; {
L44:
.dbline 267
L45:
.dbline 267
; while ((PINB&(1<<DR))==0);
sbis 0x16,3
rjmp L44
.dbline -2
L43:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SendData _nrf905_SendData fV
.even
_nrf905_SendData::
.dbline -1
.dbline 272
; }
;
; //发送TxBuf中的数据
; void nrf905_SendData()
; {
.dbline 273
; nrf905_TxOn();//切换到发送模式
xcall _nrf905_TxOn
.dbline 275
;
; nrf905_SetTxAddr();//写发送地址
xcall _nrf905_SetTxAddr
.dbline 276
; nrf905_SetData();//写数据
xcall _nrf905_SetData
.dbline 277
; nrf905_TxSend();//启动发送
xcall _nrf905_TxSend
.dbline 278
; nrf905_WaitSended();//等待发送结束
xcall _nrf905_WaitSended
.dbline -2
L47:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SendAgain _nrf905_SendAgain fV
.even
_nrf905_SendAgain::
.dbline -1
.dbline 284
;
; }
;
; //测试直接重新发送上次写入的数据
; void nrf905_SendAgain()
; {
.dbline 285
; nrf905_TxOn();
xcall _nrf905_TxOn
.dbline 286
; nrf905_TxSend();
xcall _nrf905_TxSend
.dbline 287
; nrf905_WaitSended();
xcall _nrf905_WaitSended
.dbline -2
L48:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_ReadData _nrf905_ReadData fV
; i -> R20
.even
_nrf905_ReadData::
xcall push_gset1
.dbline -1
.dbline 293
;
; }
;
; //读出接收到的数据
; void nrf905_ReadData()
; {
.dbline 296
; uchar i;
;
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 297
; nrf905_SpiRW(RRP); //读RxPayload
ldi R16,36
xcall _nrf905_SpiRW
.dbline 298
; for (i=0;i<SIZE;i++)
clr R20
xjmp L53
L50:
.dbline 299
.dbline 300
clr R16
xcall _nrf905_SpiRW
ldi R24,<_RxBuf
ldi R25,>_RxBuf
mov R30,R20
clr R31
add R30,R24
adc R31,R25
std z+0,R16
.dbline 301
L51:
.dbline 298
inc R20
L53:
.dbline 298
cpi R20,32
brlo L50
.dbline 303
; {
; RxBuf[i]=nrf905_SpiRW(0);//read...
; }
;
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L49:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.area bss(ram, con, rel)
.dbfile C:\DOCUME~1\charon\MYDOCU~1\AVR\NRF905\nrf905.C
_RxBuf::
.blkb 100
.dbsym e RxBuf _RxBuf A[100:100]c
_TxBuf::
.blkb 100
.dbsym e TxBuf _TxBuf A[100:100]c
_key:
.blkb 1
.dbfile C:\DOCUME~1\charon\MYDOCU~1\AVR\NRF905/config.h
.dbsym s key _key c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -