?? nrf905.s
字號:
; SET(PORTB,PWR);
sbi 0x18,0
.dbline 181
; CLR(PORTB,TX_EN);//maybe first
cbi 0x18,2
.dbline 182
; SET(PORTB,TRXCE);
sbi 0x18,1
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_Init _nrf905_Init fV
.even
_nrf905_Init::
.dbline -1
.dbline 187
; }
;
; //初始化nrf905
; void nrf905_Init()
; {
.dbline 188
; nrf905_StandBy();
xcall _nrf905_StandBy
.dbline 189
; DelayMs(10);//!!!must >3ms
ldi R16,10
xcall _DelayMs
.dbline 190
; nrf905_Config();
xcall _nrf905_Config
.dbline 192
;
; nrf905_SpiTest();//test...
xcall _nrf905_SpiTest
.dbline 193
; nrf905_RxOn();
xcall _nrf905_RxOn
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SpiTest _nrf905_SpiTest fV
; i -> R20
.even
_nrf905_SpiTest::
xcall push_gset1
.dbline -1
.dbline 198
; }
;
; //測試:通過讀配置,判斷SPI操作是否正確
; void nrf905_SpiTest()
; {uchar i;
.dbline 199
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 200
; nrf905_SpiRW(RC); //讀配置
ldi R16,16
xcall _nrf905_SpiRW
.dbline 201
; for (i=0;i<10;i++)
clr R20
xjmp L16
L13:
.dbline 202
.dbline 203
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 204
L14:
.dbline 201
inc R20
L16:
.dbline 201
cpi R20,10
brlo L13
.dbline 205
; {
; RxBuf[i]= nrf905_SpiRW(0);//read from nrf905
; }
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L12:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e nrf905_SetTxAddr _nrf905_SetTxAddr fV
.even
_nrf905_SetTxAddr::
.dbline -1
.dbline 210
; }
;
; //寫Tx地址
; void nrf905_SetTxAddr()
; {
.dbline 211
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 212
; nrf905_SpiRW(WTA); //寫Tx地址
ldi R16,34
xcall _nrf905_SpiRW
.dbline 213
; nrf905_SpiRW(TX_ADDRESS_0);
ldi R16,18
xcall _nrf905_SpiRW
.dbline 214
; nrf905_SpiRW(TX_ADDRESS_1);
ldi R16,52
xcall _nrf905_SpiRW
.dbline 215
; nrf905_SpiRW(TX_ADDRESS_2);
ldi R16,86
xcall _nrf905_SpiRW
.dbline 216
; nrf905_SpiRW(TX_ADDRESS_3);
ldi R16,120
xcall _nrf905_SpiRW
.dbline 217
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L17:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SetData _nrf905_SetData fV
; i -> R20
.even
_nrf905_SetData::
xcall push_gset1
.dbline -1
.dbline 222
; }
;
; //寫Tx數據
; void nrf905_SetData()
; {uchar i;
.dbline 224
;
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 225
; nrf905_SpiRW(WTP); //寫TxPayload
ldi R16,32
xcall _nrf905_SpiRW
.dbline 226
; for (i=0;i<SIZE;i++)
clr R20
xjmp L22
L19:
.dbline 227
.dbline 228
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 229
L20:
.dbline 226
inc R20
L22:
.dbline 226
cpi R20,32
brlo L19
.dbline 231
; {
; nrf905_SpiRW(TxBuf[i]);
; }
;
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L18:
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 236
; }
;
; //等待發送結束
; void nrf905_WaitSended()
; {
L24:
.dbline 237
L25:
.dbline 237
; while ((PIND&(1<<DR))==0);
sbis 0x10,4
rjmp L24
.dbline -2
L23:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SendData _nrf905_SendData fV
.even
_nrf905_SendData::
.dbline -1
.dbline 242
; }
;
; //發送TxBuf中的數據
; void nrf905_SendData()
; {
.dbline 243
; nrf905_TxOn();//切換到發送模式
xcall _nrf905_TxOn
.dbline 244
; nrf905_SetTxAddr();//寫發送地址
xcall _nrf905_SetTxAddr
.dbline 245
; nrf905_SetData();//寫數據
xcall _nrf905_SetData
.dbline 246
; nrf905_TxSend();//啟動發送
xcall _nrf905_TxSend
.dbline 247
; nrf905_WaitSended();//等待發送結束
xcall _nrf905_WaitSended
.dbline -2
L27:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_SendAgain _nrf905_SendAgain fV
.even
_nrf905_SendAgain::
.dbline -1
.dbline 253
;
; }
;
; //測試直接重新發送上次寫入的數據
; void nrf905_SendAgain()
; {
.dbline 254
; nrf905_TxOn();
xcall _nrf905_TxOn
.dbline 255
; nrf905_TxSend();
xcall _nrf905_TxSend
.dbline 256
; nrf905_WaitSended();
xcall _nrf905_WaitSended
.dbline -2
L28:
.dbline 0 ; func end
ret
.dbend
.dbfunc e nrf905_ReadData _nrf905_ReadData fV
; i -> R20
.even
_nrf905_ReadData::
xcall push_gset1
.dbline -1
.dbline 262
;
; }
;
; //讀出接收到的數據
; void nrf905_ReadData()
; {
.dbline 265
; uchar i;
;
; CLR(PORTB,CSN);
cbi 0x18,4
.dbline 266
; nrf905_SpiRW(RRP); //讀RxPayload
ldi R16,36
xcall _nrf905_SpiRW
.dbline 267
; for (i=0;i<SIZE;i++)
clr R20
xjmp L33
L30:
.dbline 268
.dbline 269
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 270
L31:
.dbline 267
inc R20
L33:
.dbline 267
cpi R20,32
brlo L30
.dbline 272
; {
; RxBuf[i]=nrf905_SpiRW(0);//read...
; }
;
; SET(PORTB,CSN);
sbi 0x18,4
.dbline -2
L29:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.area bss(ram, con, rel)
.dbfile D:\IccAvr\Pei\ptr8000\nrf905.C
_RxBuf::
.blkb 32
.dbsym e RxBuf _RxBuf A[32:32]c
_TxBuf::
.blkb 32
.dbsym e TxBuf _TxBuf A[32:32]c
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -