⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cc1000avr.s

📁 CC1000通信
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module cc1000avr.c
	.area text(rom, con, rel)
	.dbfile D:\FZCCC\cc1000avr.c
	.dbfunc e delaycc _delaycc fV
;              i -> R20,R21
;              j -> R22,R23
;              t -> R16,R17
	.even
_delaycc::
	xcall push_gset2
	.dbline -1
	.dbline 94
; /****************************************************************************/
; /* Application note AN009                                                   */
; /* CC1000 interface library                                                 */
; /*                                                                          */
; /* File:      cc1000avr.c                                                   */
; /* Revision:  2.1                                                           */
; /*                                                                          */
; /* Microcontroller:                                                         */
; /*          Atmel AVRmega8L                                                 */
; /* Written for the IAR AVR compiler                                         */
; /*                                                                          */
; /* Author:  Karl H. Torvmark, Field Applications Engineer, Chipcon          */
; /*                                                                          */
; /* Contact: Chipcon AS +47 22 95 85 44                                      */
; /*          wireless@chipcon.com                                            */
; /*                                                                          */
; /* Changes:                                                                 */
; /*      2.1 : First AVR version                                             */
; /****************************************************************************/
; 
; /****************************************************************************/
; /* This library contains functions for configuring the CC1000. These        */
; /* routines use bit-banging to program the CC1000.                          */
; /* Routines to read and write the calibration values in the CC1000 are      */
; /* provided, they aree useful in frequency-agile and frequency hopping      */
; /* applications. See application note AN009 for more information.           */
; /* The routines in this file will have to be adapted depending on the MCU   */
; /* and compiler used.                                                       */
; /****************************************************************************/
; 
; /*                                                                           *
;  * Revision history:                                                         *
;  *                                                                           *
;  * $Log: cc1000avr.c,v $
;  * Revision 2.5  2003/05/08 10:51:52  tos
;  * Corrected LOCK monitor in Calibrate.
;  *
;  * Revision 2.4  2003/05/08 10:05:26  tos
;  * Corrections according to Errata Note 01: reset freq.synth if unable to lock PLL.
;  *
;  * Revision 2.3  2003/04/28 08:21:14  tos
;  * Corrected inconsistent monitoring of CC1000: [calibration complete] + [lock].
;  *
;  *
;  *                                                                           *
;  ****************************************************************************/
; 
; #include "CC1000.h"
; #include "iom128v.h"
; #include <stdio.h>
; 
; /* Pin usage definitions */
; /*#define PDATA       2   
; // PORTB, pin 2
; #define PCLK        1   
; // PORTB, pin 1
; #define PALE        6   
; // PORTA, pin 6
; #define DIO         6   
; // PORTE, pin 6
; #define DCLK        6   
; // PORTB, pin 6
; /**/
; #define PDATA       3   // PORTD, pin 3
; #define PCLK        4   // PORTD, pin 4
; #define PALE        5   // PORTD, pin 5
; #define DIO         1   // PORTD, pin 1
; #define DCLK        2   // PORTD, pin 2
; 
; #define CAL_TIMEOUT   0x7FFE
; //0x9C40   
; #define LOCK_TIMEOUT  0x7FFE
; //0xC0
; //原先为0x7FFE
; /* Contents of CURRENT register for TX and RX, use SmartRF(R) Studio */
; /* to find values for your application */   
;  
; #define TX_CURRENT 0xF3
; #define RX_CURRENT 0x8C
; 
; /* Contents of PLL register for TX and RX, use SmartRF(R) Studio */
; /* to find values for your application */
; 
; #define TX_PLL 0x18
; #define RX_PLL 0x18
; 
; #define PA_VALUE 0xF0  
; ///????0x90
; 
; 
; 
; /////////////////////////////XIAO YU 修改/////////////////////////
; void delaycc(int t)
;      {
	.dbline 96
; 	  int i,j;
; 	  for(i = 0;i < t;i++)
	clr R20
	clr R21
	xjmp L5
L2:
	.dbline 97
	clr R22
	clr R23
	xjmp L9
L6:
	.dbline 97
L7:
	.dbline 97
	subi R22,255  ; offset = 1
	sbci R23,255
L9:
	.dbline 97
	cp R22,R16
	cpc R23,R17
	brlt L6
L3:
	.dbline 96
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	.dbline 96
	cp R20,R16
	cpc R21,R17
	brlt L2
	.dbline -2
L1:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 I
	.dbsym r j 22 I
	.dbsym r t 16 I
	.dbend
	.dbfunc e ConfigureCC1000 _ConfigureCC1000 fV
;    WordCounter -> R20
;     BitCounter -> R10
;           Data -> R22,R23
;  Configuration -> R18,R19
;          Count -> R16
	.even
_ConfigureCC1000::
	xcall push_gset3
	.dbline -1
	.dbline 106
; 	    for(j = 0;j < t;j++);
; 	 }
; 	/////////////// ////////////////////////////////////////////stdio.h
; /****************************************************************************//////////////////////原始的CONFIG
; /*  This routine sends new configuration data to the CC1000                 */
; /*  Based on bit bashing (general I/O pin use)                              */
; /****************************************************************************/
; 
; void ConfigureCC1000(char Count, short Configuration[])
; {
	.dbline 113
;   char  BitCounter;
;   char  WordCounter;
;   short Data;
;  
;  
;    
;   PORTD|=(1<<PALE); //PALE=1
	sbi 0x12,5
	.dbline 115
;   
;   for (WordCounter=0;WordCounter<Count;WordCounter++)
	clr R20
	xjmp L14
L11:
	.dbline 116
;   {
	.dbline 117
;     Data=Configuration[WordCounter];
	ldi R24,2
	mul R24,R20
	movw R30,R0
	add R30,R18
	adc R31,R19
	ldd R22,z+0
	ldd R23,z+1
	.dbline 118
;     PORTD&=~(1<<PALE); // PALE=0
	cbi 0x12,5
	.dbline 121
;     
;     /* Send address bits */
;   for (BitCounter=0;BitCounter<7;BitCounter++)
	clr R10
	xjmp L18
L15:
	.dbline 122
;     {
	.dbline 123
;       PORTD|=(1<<PCLK); // PCLK=1
	sbi 0x12,4
	.dbline 124
;       if ((Data&0x8000)==0) {
	sbrc R23,7
	rjmp L19
	.dbline 124
	.dbline 125
;         PORTD&=~(1<<PDATA); // PDATA=0
	cbi 0x12,3
	.dbline 126
;       }
	xjmp L20
L19:
	.dbline 127
;       else {
	.dbline 128
;         PORTD|=(1<<PDATA); // PDATA=1
	sbi 0x12,3
	.dbline 129
;       }
L20:
	.dbline 130
	lsl R22
	rol R23
	.dbline 131
	cbi 0x12,4
	.dbline 132
L16:
	.dbline 121
	inc R10
L18:
	.dbline 121
	mov R24,R10
	cpi R24,7
	brlo L15
	.dbline 137
;       Data=Data<<1;
;       PORTD&=~(1<<PCLK); //PCLK=0;
;     }
;     
;     /* Send read/write bit */
;     /* Ignore bit in data, always use 1 */
;     
;     PORTD|=(1<<PCLK); //PCLK=1
	sbi 0x12,4
	.dbline 138
;     PORTD|=(1<<PDATA);  //PDATA=1
	sbi 0x12,3
	.dbline 139
;     PORTD&=~(1<<PCLK); //PCLK=0
	cbi 0x12,4
	.dbline 140
;     Data=Data<<1;
	lsl R22
	rol R23
	.dbline 141
;     PORTD|=(1<<PCLK); //PCLK=1
	sbi 0x12,4
	.dbline 142
;     PORTD|=(1<<PALE); //PALE=1
	sbi 0x12,5
	.dbline 146
;     
;     /* Send data bits */
;     
;     for (BitCounter=0;BitCounter<8;BitCounter++)
	clr R10
	xjmp L24
L21:
	.dbline 147
;     {
	.dbline 148
;       PORTD|=(1<<PCLK); //PCLK=1
	sbi 0x12,4
	.dbline 149
;       if ((Data&0x8000)==0) {
	sbrc R23,7
	rjmp L25
	.dbline 149
	.dbline 150
;         PORTD&=~(1<<PDATA); // PDATA=0
	cbi 0x12,3
	.dbline 151
;       }
	xjmp L26
L25:
	.dbline 152
;       else {
	.dbline 153
;         PORTD|=(1<<PDATA); // PDATA=1
	sbi 0x12,3
	.dbline 154
;       }
L26:
	.dbline 155
	lsl R22
	rol R23
	.dbline 156
	cbi 0x12,4
	.dbline 157
L22:
	.dbline 146
	inc R10
L24:
	.dbline 146
	mov R24,R10
	cpi R24,8
	brlo L21
	.dbline 158
	sbi 0x12,4
	.dbline 159
L12:
	.dbline 115
	inc R20
L14:
	.dbline 115
	cp R20,R16
	brlo L11
	.dbline -2
L10:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r WordCounter 20 c
	.dbsym r BitCounter 10 c
	.dbsym r Data 22 S
	.dbsym r Configuration 18 pS
	.dbsym r Count 16 c
	.dbend
	.dbfunc e WriteToCC1000Register _WriteToCC1000Register fV
;            val -> y+0
;           data -> R20
;           addr -> R22
	.even
_WriteToCC1000Register::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	sbiw R28,2
	.dbline -1
	.dbline 228
;       Data=Data<<1;
;       PORTD&=~(1<<PCLK); //PCLK=0
;      }
;   PORTD|=(1<<PCLK); //PCLK=1
;   }   /* Finished with word */   
; }
; 
; /****************************************************************************//////////////////////新的CONFIG
; /*  This routine sends new configuration data to the CC1000                 */
; /*  Based on bit bashing (general I/O pin use)                              */
; /****************************************************************************/
; /*
; void ConfigureCC1000(char Count, short Configuration[])
; {
;   char  BitCounter;
;   char  WordCounter;
;   short Data;
;  
;  
;    
;   PORTA|=(1<<PALE); //PALE=1
;   
;   for (WordCounter=0;WordCounter<Count;WordCounter++)
;   {
;     Data=Configuration[WordCounter];
;     PORTA&=~(1<<PALE); // PALE=0
;     
;     /* Send address bits */
; /*    for (BitCounter=0;BitCounter<7;BitCounter++)
;     {
;       PORTB|=(1<<PCLK); // PCLK=1
;       if ((Data&0x8000)==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 1 */
;  /*    
;     PORTB|=(1<<PCLK); //PCLK=1
;     PORTB|=(1<<PDATA);  //PDATA=1
;     PORTB&=~(1<<PCLK); //PCLK=0
;     Data=Data<<1;
;     PORTB|=(1<<PCLK); //PCLK=1
;     PORTA|=(1<<PALE); //PALE=1
;     
;     /* Send data bits */
;  /*    
;     for (BitCounter=0;BitCounter<8;BitCounter++)
;     {
;       PORTB|=(1<<PCLK); //PCLK=1
;       if ((Data&0x8000)==0) {
;         PORTB&=~(1<<PDATA); // PDATA=0
;       }
;       else {
;         PORTB|=(1<<PDATA); // PDATA=1
;       }
;       Data=Data<<1;
;       PORTB&=~(1<<PCLK); //PCLK=0
;      }
;   PORTB|=(1<<PCLK); //PCLK=1
;   }   /* Finished with word */   
; /* }
; /****************************************************************************/
; /*  This routine writes to a single CC1000 register                         */
; /****************************************************************************/
; 
; void WriteToCC1000Register(char addr, char data)
; {
	.dbline 231
;   short val;
;   
;   val=(addr&0x7F)<<9 | (data&0xFF);
	ldi R18,9
	ldi R19,0
	mov R16,R22
	clr R17
	andi R16,127
	andi R17,0
	xcall lsl16
	movw R2,R16
	mov R24,R20
	clr R25
	andi R25,0
	or R2,R24
	or R3,R25
	std y+1,R3
	std y+0,R2
	.dbline 232
;   ConfigureCC1000(1,&val);
	movw R18,R28
	ldi R16,1
	xcall _ConfigureCC1000
	.dbline -2
L27:
	adiw R28,2
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l val 0 S
	.dbsym r data 20 c
	.dbsym r addr 22 c
	.dbend
	.dbfunc e WriteToCC1000RegisterWord _WriteToCC1000RegisterWord fV
;    addranddata -> y+0
	.even
_WriteToCC1000RegisterWord::
	st -y,r17
	st -y,r16
	.dbline -1
	.dbline 241
; }
; 
; /****************************************************************************/
; /*  This routine writes to a single CC1000 register, with data and address  */
; /*  given in the same variable                                              */
; /****************************************************************************/
; 
; void WriteToCC1000RegisterWord(short addranddata)
; {
	.dbline 243
;  
;   ConfigureCC1000(1,&addranddata);
	movw R18,R28
	ldi R16,1
	xcall _ConfigureCC1000
	.dbline -2
L28:
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbsym l addranddata 0 S
	.dbend
	.dbfunc e ReadFromCC1000Register _ReadFromCC1000Register fc
;          Debug -> R20
;     BitCounter -> R22
;           Data -> R10
;           addr -> R16
	.even
_ReadFromCC1000Register::
	xcall push_gset3
	.dbline -1
	.dbline 251
; }
; 
; /****************************************************************************/////////////////////////原始的READ
; /*  This routine reads from a single CC1000 register                        */
; /****************************************************************************/
; 
; char ReadFromCC1000Register(char addr)
; {
	.dbline 257
;   char BitCounter;
;   char Data;
;   char Debug;
;   
;     
;   PORTD|=(1<<PALE); //PALE=1
	sbi 0x12,5
	.dbline 259
;   
;   Data=addr<<1;
	mov R10,R16
	lsl R10
	.dbline 260
;   PORTD&=~(1<<PALE);
	cbi 0x12,5
	.dbline 263
;     
;    /*Send address bits */
;  for (BitCounter=0;BitCounter<7;BitCounter++)
	clr R22
	xjmp L33
L30:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -