?? 2.4g+?
字號(hào):
X0:
.dbline -2
L1:
adiw R28,1
.dbline 0 ; func end
ret
.dbsym r Get_SO 20 c
.dbend
.dbfunc e nrf24l01init _nrf24l01init fV
.even
_nrf24l01init::
.dbline -1
.dbline 227
; }
;
;
; }
; void nrf24l01init(void)
; {
.dbline 228
; nRF24L01_IRQ_DIR;
cbi 0x4,2
.dbline 229
; nRF24L01_MISO_DIR;
cbi 0x4,1
.dbline 230
; nRF24L01_CE_DIR;
sbi 0xa,5
.dbline 231
; nRF24L01_SCK_DIR;
sbi 0xa,7
.dbline 232
; nRF24L01_CSN_DIR;
sbi 0xa,6
.dbline 233
; nRF24L01_MOSI_DIR;
sbi 0x4,0
.dbline -2
L28:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_CPU _init_CPU fV
.even
_init_CPU::
.dbline -1
.dbline 240
; }
; /*-----------------------------------------------------------------------------
; Module: init_CPU
; Function: Initialization of CPU
; ------------------------------------------------------------------------------*/
; void init_CPU (void)
; {
.dbline 241
; MCUCR = 0x00; //
clr R2
out 0x35,R2
.dbline 242
; EICRA = 0x00; //extended ext ints
sts 105,R2
.dbline 243
; EIMSK = 0x00;
out 0x1d,R2
.dbline 245
;
; TIMSK0 = 0x01; //timer 0 interrupt sources
ldi R24,1
sts 110,R24
.dbline 246
; TIMSK1 = 0x00; //timer 1 interrupt sources
sts 111,R2
.dbline 247
; TIMSK2 = 0x00; //timer 2 interrupt sources
sts 112,R2
.dbline 248
; CLI(); //disable all interrupts
cli
.dbline 249
; NOP();
nop
.dbline 250
; PORTB = 0x01;
out 0x5,R24
.dbline 251
; DDRB = 0xf3;
ldi R24,243
out 0x4,R24
.dbline 252
; PORTD = 0x80;
ldi R24,128
out 0xb,R24
.dbline 253
; DDRD = 0xE3;
ldi R24,227
out 0xa,R24
.dbline 254
; PORTC = 0x80;
ldi R24,128
out 0x8,R24
.dbline 255
; DDRC = 0x40;
ldi R24,64
out 0x7,R24
.dbline 256
; nrf24l01init();
rcall _nrf24l01init
.dbline 257
; nRF24L01_CEL;
cbi 0xb,5
.dbline 258
; delay();
rcall _delay
.dbline 259
; nRF24L01_CSNH; // Spi disable
sbi 0xb,6
.dbline 260
; delay();
rcall _delay
.dbline 261
; nRF24L01_SCKL;
cbi 0xb,7
.dbline 262
; delay();
rcall _delay
.dbline -2
L29:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay _delay fV
.even
_delay::
.dbline -1
.dbline 265
; }
; void delay(void)//
; {
.dbline 266
; NOP();
nop
.dbline 267
; NOP();
nop
.dbline 268
; NOP();
nop
.dbline 269
; NOP();
nop
.dbline 270
; NOP();
nop
.dbline 271
; NOP();
nop
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delayms _delayms fV
; dly -> R16,R17
.even
_delayms::
.dbline -1
.dbline 274
; }
; void delayms(unsigned short dly)//
; {
.dbline 275
rjmp L35
L32:
.dbline 275
L33:
.dbline 275
subi R16,1
sbci R17,0
L35:
.dbline 275
; for(;dly>0;dly--) ;
cpi R16,0
cpc R16,R17
brne L32
X1:
.dbline -2
L31:
.dbline 0 ; func end
ret
.dbsym r dly 16 s
.dbend
.dbfunc e clear_buf _clear_buf fV
; number -> R18
; ptr -> R16,R17
.even
_clear_buf::
.dbline -1
.dbline 279
; }
;
; void clear_buf(unsigned char *ptr,unsigned char number)//清零buffer,指定字節(jié)個(gè)數(shù)
; {
.dbline 280
rjmp L40
L37:
.dbline 280
clr R2
movw R30,R16
st Z+,R2
movw R16,R30
L38:
.dbline 280
dec R18
L40:
.dbline 280
; for (;number>0;number--) *ptr++=0;
clr R2
cp R2,R18
brlo L37
.dbline -2
L36:
.dbline 0 ; func end
ret
.dbsym r number 18 c
.dbsym r ptr 16 pc
.dbend
.dbfunc e SPI_RW _SPI_RW fc
; bit_ctr -> R20
; byte -> R22
.even
_SPI_RW::
rcall push_gset2
mov R22,R16
.dbline -1
.dbline 291
; }
; //------------------------------------------------------
; /**************************************************
; Function: SPI_RW();
;
; Description:
; Writes one byte to nRF24L01, and return the byte read
; from nRF24L01 during write, according to SPI protocol */
; /**************************************************/
; unsigned char SPI_RW(unsigned char byte)
; {
.dbline 293
; unsigned char bit_ctr;
; for(bit_ctr=0;bit_ctr<8;bit_ctr++) // output 8-bit
clr R20
rjmp L45
L42:
.dbline 294
; {
.dbline 295
; if(byte & 0x80)
sbrs R22,7
rjmp L46
.dbline 296
; nRF24L01_MOSIH;
sbi 0x5,0
rjmp L47
L46:
.dbline 298
; else
; nRF24L01_MOSIL;
cbi 0x5,0
L47:
.dbline 299
; delay();
rcall _delay
.dbline 300
; byte = (byte << 1); // shift next bit into MSB..
lsl R22
.dbline 301
; nRF24L01_SCKH;
sbi 0xb,7
.dbline 302
; delay();
rcall _delay
.dbline 303
; if(PINB&nRF24L01_MISO) byte |= 1;
sbis 0x3,1
rjmp L48
.dbline 303
ori R22,1
L48:
.dbline 304
cbi 0xb,7
.dbline 305
rcall _delay
.dbline 306
L43:
.dbline 293
inc R20
L45:
.dbline 293
cpi R20,8
brlo L42
.dbline 307
; nRF24L01_SCKL;
; delay();
; }
; return(byte); // return read byte
mov R16,R22
.dbline -2
L41:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r bit_ctr 20 c
.dbsym r byte 22 c
.dbend
.dbfunc e SPI_RW_Reg _SPI_RW_Reg fc
; status -> R20
; value -> R22
; reg -> R20
.even
_SPI_RW_Reg::
rcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 316
; }
; /**************************************************
; Function: SPI_RW_Reg();
;
; Description:
; Writes value 'value' to register 'reg' */
; /**************************************************/
; unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
; {
.dbline 318
; unsigned char status;
; nRF24L01_CSNL;
cbi 0xb,6
.dbline 319
; delay();
rcall _delay
.dbline 320
; status = SPI_RW(reg); // select register
mov R16,R20
rcall _SPI_RW
mov R20,R16
.dbline 321
; SPI_RW(value); // ..and write value to it..
mov R16,R22
rcall _SPI_RW
.dbline 322
; nRF24L01_CSNH;
sbi 0xb,6
.dbline 323
; delay();
rcall _delay
.dbline 324
; return(status); // return nRF24L01 status byte
mov R16,R20
.dbline -2
L50:
rcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r status 20 c
.dbsym r value 22 c
.dbsym r reg 20 c
.dbend
.dbfunc e SPI_Read _SPI_Read fc
; reg_val -> R20
; reg -> R20
.even
_SPI_Read::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 333
; }
; /**************************************************
; Function: SPI_Read();
;
; Description:
; Read one byte from nRF24L01 register, 'reg' */
; /**************************************************/
; unsigned char SPI_Read(unsigned char reg)
; {
.dbline 335
; unsigned char reg_val;
; nRF24L01_CSNL;
cbi 0xb,6
.dbline 336
; delay();
rcall _delay
.dbline 337
; SPI_RW(reg); // Select register to read from..
mov R16,R20
rcall _SPI_RW
.dbline 338
; reg_val = SPI_RW(0); // ..then read registervalue
clr R16
rcall _SPI_RW
mov R20,R16
.dbline 339
; nRF24L01_CSNH;
sbi 0xb,6
.dbline 340
; delay();
rcall _delay
.dbline 341
; return(reg_val); // return register value
mov R16,R20
.dbline -2
L51:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r reg_val 20 c
.dbsym r reg 20 c
.dbend
.dbfunc e SPI_Read_Buf _SPI_Read_Buf fc
; status -> R20
; byte_ctr -> R22
; bytes -> R10
; pBuf -> R12,R13
; reg -> R20
.even
_SPI_Read_Buf::
rcall push_gset4
movw R12,R18
mov R20,R16
ldd R10,y+8
.dbline -1
.dbline 351
; }
; /**************************************************
; Function: SPI_Read_Buf();
;
; Description:
; Reads 'bytes' #of bytes from register 'reg'
; Typically used to read RX payload, Rx/Tx address */
; /**************************************************/
; unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
; {
.dbline 353
; unsigned char status,byte_ctr;
; nRF24L01_CSNL;
cbi 0xb,6
.dbline 354
; delay();
rcall _delay
.dbline 355
; status = SPI_RW(reg); // Select register to write to and read status byte
mov R16,R20
rcall _SPI_RW
mov R20,R16
.dbline 356
; for(byte_ctr=0;byte_ctr<bytes;byte_ctr++)
clr R22
rjmp L56
L53:
.dbline 357
clr R16
rcall _SPI_RW
mov R30,R22
clr R31
add R30,R12
adc R31,R13
std z+0,R16
L54:
.dbline 356
inc R22
L56:
.dbline 356
cp R22,R10
brlo L53
.dbline 358
; pBuf[byte_ctr] = SPI_RW(0); // Perform SPI_RW to read byte from nRF24L01
; nRF24L01_CSNH;
sbi 0xb,6
.dbline 359
; delay();
rcall _delay
.dbline 360
; return(status); // return nRF24L01 status byte
mov R16,R20
.dbline -2
L52:
rcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r status 20 c
.dbsym r byte_ctr 22 c
.dbsym r bytes 10 c
.dbsym r pBuf 12 pc
.dbsym r reg 20 c
.dbend
.dbfunc e SPI_Write_Buf _SPI_Write_Buf fc
; status -> R20
; byte_ctr -> R22
; bytes -> R10
; pBuf -> R12,R13
; reg -> R20
.even
_SPI_Write_Buf::
rcall push_gset4
movw R12,R18
mov R20,R16
ldd R10,y+8
.dbline -1
.dbline 370
; }
; /**************************************************
; Function: SPI_Write_Buf();
;
; Description:
; Writes contents of buffer '*pBuf' to nRF24L01
; Typically used to write TX payload, Rx/Tx address */
; /**************************************************/
; unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char bytes)
; {
.dbline 372
; unsigned char status,byte_ctr;
; nRF24L01_CSNL; // Set nRF24L01_CSN low, init SPI tranaction
cbi 0xb,6
.dbline 373
; delay();
rcall _delay
.dbline 374
; status = SPI_RW(reg); // Select register to write to and read status byte
mov R16,R20
rcall _SPI_RW
mov R20,R16
.dbline 375
; for(byte_ctr=0; byte_ctr<bytes; byte_ctr++) // then write all byte in buffer(*pBuf)
clr R22
rjmp L61
L58:
.dbline 376
movw R30,R12
ld R16,Z+
movw R12,R30
rcall _SPI_RW
mov R20,R16
L59:
.dbline 375
inc R22
L61:
.dbline 375
cp R22,R10
brlo L58
.dbline 377
; status = SPI_RW(*pBuf++);
; nRF24L01_CSNH; // Set nRF24L01_CSN high again
sbi 0xb,6
.dbline 378
; delay();
rcall _delay
.dbline 379
; return(status); // return nRF24L01 status byte
mov R16,R20
.dbline -2
L57:
rcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r status 20 c
.dbsym r byte_ctr 22 c
.dbsym r bytes 10 c
.dbsym r pBuf 12 pc
.dbsym r reg 20 c
.dbend
.dbfunc e RX_Mode _RX_Mode fV
.even
_RX_Mode::
sbiw R28,1
.dbline -1
.dbline 392
; }
; /**************************************************
; Function: RX_Mode();
;
; Description:
; This function initializes one nRF24L01 device to
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -