📄 cc1000avr.s
字号:
.dbline 264
; {
.dbline 265
; PORTD|=(1<<PCLK); // PCLK=1
sbi 0x12,4
.dbline 266
; if ((Data&0x80)==0) {
sbrc R10,7
rjmp L34
.dbline 266
.dbline 267
; PORTD&=~(1<<PDATA); // PDATA=0
cbi 0x12,3
.dbline 268
; }
xjmp L35
L34:
.dbline 269
; else {
.dbline 270
; PORTD|=(1<<PDATA); // PDATA=1
sbi 0x12,3
.dbline 271
; }
L35:
.dbline 272
lsl R10
.dbline 273
cbi 0x12,4
.dbline 274
L31:
.dbline 263
inc R22
L33:
.dbline 263
cpi R22,7
brlo L30
.dbline 279
; Data=Data<<1;
; PORTD&=~(1<<PCLK); //PCLK=0;
; }
;
; /*Send read/write bit */
; /* Ignore bit in data, always use 0 */
;
; PORTD|=(1<<PCLK); //PCLK=1
sbi 0x12,4
.dbline 280
; PORTD&=~(1<<PDATA); //PDATA=0
cbi 0x12,3
.dbline 281
; PORTD&=~(1<<PCLK); //PCLK=0
cbi 0x12,4
.dbline 284
;
;
; PORTD|=(1<<PCLK); //PCLK=1
sbi 0x12,4
.dbline 285
; PORTD|=(1<<PALE); //PALE=1
sbi 0x12,5
.dbline 289
;
; /* Receive data bits */
;
; PORTD|=(1<<PDATA); //PDATA=1
sbi 0x12,3
.dbline 291
;
; DDRD&=~(1<<PDATA); /* Set up PDATA as an input */
cbi 0x11,3
.dbline 293
;
; for (BitCounter=0;BitCounter<8;BitCounter++)
clr R22
xjmp L39
L36:
.dbline 294
; {
.dbline 295
; PORTD&=~(1<<PCLK); //PCLK=0
cbi 0x12,4
.dbline 296
; Data=Data<<1;
lsl R10
.dbline 297
; Debug=(1<<PDATA);
ldi R20,8
.dbline 298
; if ((PIND&Debug)==0) {
in R2,0x10
and R2,R20
brne L40
.dbline 298
.dbline 299
; Data&=0xFE;
mov R24,R10
andi R24,254
mov R10,R24
.dbline 300
xjmp L41
L40:
.dbline 300
; } else {
.dbline 301
; Data|=0x01;
mov R24,R10
ori R24,1
mov R10,R24
.dbline 302
; }
L41:
.dbline 303
sbi 0x12,4
.dbline 304
L37:
.dbline 293
inc R22
L39:
.dbline 293
cpi R22,8
brlo L36
.dbline 307
; PORTD|=(1<<PCLK); //PCLK=1
; }
;
;
; DDRD|=(1<<PDATA); /* Set up PDATA as an output again */
sbi 0x11,3
.dbline 309
;
; return Data;
mov R16,R10
.dbline -2
L29:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r Debug 20 c
.dbsym r BitCounter 22 c
.dbsym r Data 10 c
.dbsym r addr 16 c
.dbend
.dbfunc e ResetCC1000 _ResetCC1000 fV
; MainValue -> R20
.even
_ResetCC1000::
xcall push_gset1
.dbline -1
.dbline 381
; }
; /****************************************************************************/////////////////////////新的READ
; /* This routine reads from a single CC1000 register */
; /****************************************************************************/
; /*
; char ReadFromCC1000Register(char addr)
; {
; char BitCounter;
; char Data;
; char Debug;
;
;
; PORTA|=(1<<PALE); //PALE=1
;
; Data=addr<<1;
; PORTA&=~(1<<PALE);
;
; /* Send address bits */
; /* for (BitCounter=0;BitCounter<7;BitCounter++)
; {
; PORTB|=(1<<PCLK); // PCLK=1
; if ((Data&0x80)==0) {
; PORTB&=~(1<<PDATA); // PDATA=0
; }
; else {
; PORTB|=(1<<PDATA); // PDATA=1
; }
; Data=Data<<1;
; PORTB&=~(1<<PCLK); //PCLK=0;
; }
;
; /* Send read/write bit */
; /* Ignore bit in data, always use 0 */
; /*
; PORTB|=(1<<PCLK); //PCLK=1
; PORTB&=~(1<<PDATA); //PDATA=0
; PORTB&=~(1<<PCLK); //PCLK=0
;
;
; PORTB|=(1<<PCLK); //PCLK=1
; PORTA|=(1<<PALE); //PALE=1
;
; /* Receive data bits */
; /*
; PORTB|=(1<<PDATA); //PDATA=1
;
; DDRD&=~(1<<PDATA); /* Set up PDATA as an input */
; /*
; for (BitCounter=0;BitCounter<8;BitCounter++)
; {
; PORTB&=~(1<<PCLK); //PCLK=0
; Data=Data<<1;
; Debug=(1<<PDATA);
; if ((PIND&Debug)==0) {
; Data&=0xFE;
; } else {
; Data|=0x01;
; }
; PORTB|=(1<<PCLK); //PCLK=1
; }
;
;
; DDRD|=(1<<PDATA); /* Set up PDATA as an output again */
;
; /* return Data;
; }
; /****************************************************************************/
; /* This routine resets the CC1000, clearing all registers. */
; /****************************************************************************/
;
; void ResetCC1000(void)
; {
.dbline 384
; char MainValue;
;
; MainValue=ReadFromCC1000Register(CC1000_MAIN);
clr R16
xcall _ReadFromCC1000Register
mov R20,R16
.dbline 385
; WriteToCC1000Register(CC1000_MAIN,MainValue & 0xFE); // Reset CC1000
mov R18,R20
andi R18,254
clr R16
xcall _WriteToCC1000Register
.dbline 386
; WriteToCC1000Register(CC1000_MAIN,MainValue | 0x01); // Bring CC1000 out of reset
mov R18,R20
ori R18,1
clr R16
xcall _WriteToCC1000Register
.dbline -2
L42:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r MainValue 20 c
.dbend
.dbfunc e CalibrateCC1000 _CalibrateCC1000 fc
; TimeOutCounter -> R20,R21
.even
_CalibrateCC1000::
xcall push_gset1
.dbline -1
.dbline 397
; }
;
;
; /****************************************************************************/
; /* This routine calibrates the CC1000 */
; /* Returns 0 if calibration fails, non-zero otherwise. Checks the LOCK */
; /* to check for success. */
; /****************************************************************************/
;
; char CalibrateCC1000(void)
; {
.dbline 400
; int TimeOutCounter;
;
; WriteToCC1000Register(CC1000_PA_POW,0x00); // Turn off PA to avoid spurs
clr R18
ldi R16,11
xcall _WriteToCC1000Register
.dbline 402
; // during calibration in TX mode
; WriteToCC1000Register(CC1000_CAL,0xA6); // Start calibration
ldi R18,166
ldi R16,14
xcall _WriteToCC1000Register
.dbline 405
ldi R20,32766
ldi R21,127
xjmp L47
L44:
.dbline 405
L45:
.dbline 405
subi R20,1
sbci R21,0
L47:
.dbline 405
;
; // Wait for calibration complete
; for(TimeOutCounter=CAL_TIMEOUT; ((ReadFromCC1000Register(CC1000_CAL)&0x08)==0)&&(TimeOutCounter>0); TimeOutCounter--);
ldi R16,14
xcall _ReadFromCC1000Register
sbrc R16,3
rjmp L48
clr R2
clr R3
cp R2,R20
cpc R3,R21
brlt L44
L48:
.dbline 407
;
; WriteToCC1000Register(CC1000_CAL,0x26); /* End calibration */
ldi R18,38
ldi R16,14
xcall _WriteToCC1000Register
.dbline 408
; WriteToCC1000Register(CC1000_PA_POW,PA_VALUE); /* Restore PA setting */
ldi R18,240
ldi R16,11
xcall _WriteToCC1000Register
.dbline 410
ldi R20,32766
ldi R21,127
xjmp L52
L49:
.dbline 410
L50:
.dbline 410
subi R20,1
sbci R21,0
L52:
.dbline 410
; // Wait for lock
; for(TimeOutCounter=LOCK_TIMEOUT; ((ReadFromCC1000Register(CC1000_LOCK)&0x01)==0)&&(TimeOutCounter>0); TimeOutCounter--);
ldi R16,13
xcall _ReadFromCC1000Register
sbrc R16,0
rjmp L53
clr R2
clr R3
cp R2,R20
cpc R3,R21
brlt L49
L53:
.dbline 414
;
;
;
; return ((ReadFromCC1000Register(CC1000_LOCK)&0x01)==1);
ldi R16,13
xcall _ReadFromCC1000Register
mov R24,R16
andi R24,1
cpi R24,1
brne L54
ldi R20,1
ldi R21,0
xjmp L55
L54:
clr R20
clr R21
L55:
mov R16,R20
.dbline -2
L43:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r TimeOutCounter 20 I
.dbend
.dbfunc e SetupCC1000RX _SetupCC1000RX fc
; lock_status -> R20
; i -> R20,R21
; RXPLL -> R22
; RXCurrent -> R20
.even
_SetupCC1000RX::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 425
; //return (1);
; }
;
; /****************************************************************************/
; /* This routine puts the CC1000 into RX mode (from TX). When switching to */
; /* RX from PD, use WakeupC1000ToRX first */
; /****************************************************************************/
;
;
; char SetupCC1000RX(char RXCurrent,char RXPLL)
; {
.dbline 429
; int i;
; char lock_status;
;
; WriteToCC1000Register(CC1000_MAIN,0x11); // Switch into RX, switch to freq. reg A
ldi R18,17
clr R16
xcall _WriteToCC1000Register
.dbline 430
; WriteToCC1000Register(CC1000_PLL,RXPLL); // Use RX refdiv setting
mov R18,R22
ldi R16,12
xcall _WriteToCC1000Register
.dbline 431
; WriteToCC1000Register(CC1000_CURRENT,RXCurrent); // Program VCO current for RX
mov R18,R20
ldi R16,9
xcall _WriteToCC1000Register
.dbline 434
;
; // Wait 250us before monitoring LOCK
; delaycc(12);
ldi R16,12
ldi R17,0
xcall _delaycc
.dbline 437
ldi R20,32766
ldi R21,127
xjmp L60
L57:
.dbline 437
L58:
.dbline 437
subi R20,1
sbci R21,0
L60:
.dbline 437
;
; // Wait for lock
; for(i=LOCK_TIMEOUT; ((ReadFromCC1000Register(CC1000_LOCK)&0x01)==0)&&(i>0); i--);
ldi R16,13
xcall _ReadFromCC1000Register
sbrc R16,0
rjmp L61
clr R2
clr R3
cp R2,R20
cpc R3,R21
brlt L57
L61:
.dbline 440
;
; // If PLL in lock
; if ((ReadFromCC1000Register(CC1000_LOCK)&0x01)==0x01){
ldi R16,13
xcall _ReadFromCC1000Register
mov R24,R16
andi R24,1
cpi R24,1
brne L62
.dbline 440
.dbline 442
; // Indicate PLL in LOCK
; lock_status = LOCK_OK;
ldi R20,1
.dbline 444
xjmp L63
L62:
.dbline 444
; // Else (PLL out of LOCK)
; }else{
.dbline 446
; // If recalibration ok
; if(CalibrateCC1000()){
xcall _CalibrateCC1000
tst R16
breq L64
.dbline 446
.dbline 448
; // Indicate PLL in LOCK
; lock_status = LOCK_RECAL_OK;
ldi R20,2
.dbline 450
xjmp L65
L64:
.dbline 450
; // Else (recalibration failed)
; }else{
.dbline 452
; // Reset frequency syncthesizer (ref.: Errata Note 01)
; ResetFreqSynth();
xcall _ResetFreqSynth
.dbline 454
; // Indicate PLL out of LOCK
; lock_status = LOCK_NOK;
clr R20
.dbline 455
; }
L65:
.dbline 456
; }
L63:
.dbline 459
;
; // Return LOCK status to application
; return (lock_status);
mov R16,R20
.dbline -2
L56:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r lock_status 20 c
.dbsym r i 20 I
.dbsym r RXPLL 22 c
.dbsym r RXCurrent 20 c
.dbend
.dbfunc e SetupCC1000TX _SetupCC1000TX fc
; lock_status -> R20
; i -> R20,R21
; TXPLL -> R22
; TXCurrent -> R20
.even
_SetupCC1000TX::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 468
; }
;
; /****************************************************************************/
; /* This routine puts the CC1000 into TX mode (from RX). When switching to */
; /* TX from PD, use WakeupCC1000ToTX first */
; /****************************************************************************/
;
; char SetupCC1000TX(char TXCurrent,char TXPLL)
; {
.dbline 472
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -