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

📄 cc1000_rar cc1000main_c.htm

📁 asm source code asm source code asm source code asm source code
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                b_TxGo = YES; 
 
                TransCtr = 0; 
                io_data  = LOW; 
                b_Txtrue = NO; 
                b_Headov = NO; 
 
				TRISB &= 0B11111101;         
				OPTION = 0B00001111;  
                GIE    = ON; 
                while(b_TxGo==YES);   
                TRISB |= 0B00000010;         
                GIE    = OFF; 
                OPTION = 0B01001111;  
            } 
            o_led1 = HIGH; 
            break; 
            /* 
            Dly1000(250); 
            Dly1000(250); 
             
            if ((PORTB&0xF0) == 0xF0)  
            { 
                Dly1000(1); 
                if ((PORTB&0xF0) == 0xF0) break; 
            } 
            */ 
        } 
         
        if (b_UART==YES && b_Tstbase==YES) WriteToCC1000Register(CC1000_MODEM0,0x2B);  
        SetupCC1000RX(RXDL);  
        b_IsTx      = NO; 
        b_RxGo      = NO; 
        b_PreFound  = NO; 
        PreCtr      = 0; 
        Rxbuf1      = 0;     
        b_UnlockAvg = YES;   
    } 
} 
 
 
void Transmit(void) 
{ 
	TRISB &= 0B11111101;  			 
     
    io_data = LOW; 
    for (Temp1=11*2+1+1 ; ; ) 	 
    { 
		notbit(PORTB,1); 		 
        CLRWDT(); 
        if (Temp1==1) {Dly1000(3);Dly5(118);} 
        Dly5(77); 
        if(--Temp1==0) break; 
    } 
    notbit(PORTB,1); 			 
	NOP(); 
    for (Temp1=64; ; )  
    { 
		Dly5(75); 
		NOP();NOP();NOP(); 
		asm("rlf _Txbuf8,F"); 
		asm("rlf _Txbuf7,F"); 
		asm("rlf _Txbuf6,F"); 
		asm("rlf _Txbuf5,F"); 
		asm("rlf _Txbuf4,F"); 
		asm("rlf _Txbuf3,F"); 
		asm("rlf _Txbuf2,F"); 
		asm("rlf _Txbuf1,F"); 
        if(!CARRY) {Dly5(79);} 
		notbit(PORTB,1); 		 
        if(CARRY) {Dly5(79);} 
		Dly5(77);NOP();NOP();NOP();NOP(); 
		notbit(PORTB,1); 		 
        if(--Temp1==0) break; 
    } 
    Dly5(80); 
    io_data = LOW; 
    Dly5(80); 
    TRISB |= 0B00000010;  				 
} 
 
 
//=========================================================== 
//=                                                         = 
//=========================================================== 
void Readkey(void) 
{ 
	#asm     
		movlw 0xF0 
		andwf _PORTB,W 
		xorwf _Kbuf,W 
		xorwf _Kbuf,F   ;PORTB&0xF0 -> Kbuf 
		movwf _Temp1 
		movf  _Temp1,F 
	#endasm 
	if (ZERO == NO) {Kctr=0;return;}	 
	 
	if (++Kctr > 5) 
	{ 
	    Kctr = 0; 
	    if (Kbuf == 0xF0) 
	    { 
	        b_Khold = NO; 
	    } 
	    else if (b_Khold == NO) 
	    { 
	        b_Khold = YES; 
	        if (Kbuf == 0x70) 
	        { 
	            b_Kvalid = YES; 
	            Txdata   = 6; 
	        } 
	        else if (Kbuf == 0xB0) 
	        { 
	            b_Kvalid = YES; 
	            Txdata   = 7; 
	        } 
	        else if (Kbuf == 0xD0) 
	        { 
	            b_Kvalid = YES; 
	            Txdata   = 8; 
	        } 
	        else if (Kbuf == 0xE0) 
	        { 
	            b_Kvalid = YES; 
	            Txdata   = 9; 
	        } 
	    } 
	} 
} 
 
 
//=========================================================== 
//=                                                         = 
//=========================================================== 
void SysInit(void) 
{ 
    CLRWDT(); 
    PORTA  = 0b00111110;  
    TRISA  = 0b11000000;  
	PORTB  = 0b00000000;  
    TRISB  = 0b11111111;  
    PORTC  = 0b11111111;  
    TRISC  = 0b00000000;  
    OPTION = 0B01001111;  
    T1CON  = 0B00000001; 
    CCPR1L  = 0; 
    CCPR1H  = 0;			  
    CCP1CON = 0b00000000;     
    TMR2  	= 0; 
    T2CON 	= 0b01111101;   
    PR2   	= 124; 		    
	ADCON0  = 0b00000000;   
	ADCON1  = 0b00000111;   
    PIR1   = 0;  
    PIE1   = 0; 
    INTCON = 0B01010000; 
    while(1)  
    { 
	#asm 
	    movlw 0x0C 
	    andwf _PORTB,W 
	    xorwf _Optbuf,W 
	    xorwf _Optbuf,F ;3 2 1 0 
	    movwf _Temp1 
	    movf  _Temp1,F 
	#endasm 
	 
	    if (ZERO == NO) 
	    { 
	        Optctr = 0; 
	    } 
	    else 
	    { 
	        if (++Optctr > 100) 
	        { 
	            if (Optbuf == 0B00001000) {b_Mcode=YES;b_NRZ=NO;b_UART=NO;b_Tstbase=NO;}      		   
	            else if (Optbuf == 0B00000100) {b_Mcode=NO;b_NRZ=YES;b_UART=NO;b_Tstbase=NO;} 		   
	            else if (Optbuf == 0B00001100) {b_Mcode=NO;b_NRZ=NO;b_UART=YES;b_Tstbase=YES;}  
	            else {b_Mcode=NO;b_NRZ=NO;b_UART=YES;b_Tstbase=NO;} 					  	   
	            break; 
	        } 
	    } 
    } 
 
    CC1000Init(); 
     
    o_led1 = LOW; 
    for(Temp1=8; ; ) 
    { 
        CLRWDT(); 
        Dly1000(100); 
    	if(--Temp1==0) break; 
    } 
    o_led1 = HIGH; 
    PIR1   = 0; 
} 
 
 
//=========================================================== 
//=                                                         = 
//=========================================================== 
void Dly5(INT8U i)  
{ 
    for( ; --i!=0 ; ); 
} 
 
void Dly1000(INT8U i)  
{ 
    while(1) 
    { 
		NOP(); 
        Dly5(198); 
        if (--i == 0) break; 
    } 
} 
 
 
//=========================================================== 
//= Library in C language for configuring CC1000 RF Module  = 
//= MCU: Picmicro family									= 
//= Ver: 1.0												= 
//= Designed by: Figo										= 
//= Start Date:  2005-1-12									= 
//=---------------------------------------------------------= 
//= Revision History										= 
//= V1.0: Orginal Version                                   = 
//=========================================================== 
 
 
//=========================================================================== 
//= This routine writes to a single CC1000 register                         = 
//=========================================================================== 
void WriteToCC1000Register(INT8U addr, INT8U data) 
{ 
    INT16U val; 
     
    val=((INT16U)(addr&0x7F)) << 9 | (INT16U)data & 0x00FF; 
    WriteToCC1000RegisterWord(val); 
} 
 
 
//=========================================================================== 
//= This routine writes to a single CC1000 register, with address and data  = 
//= given in the same variable                                              = 
//=========================================================================== 
void WriteToCC1000RegisterWord(INT16U addranddata) 
{ 
    INT8U  BitCounter; 
     
    union  
    {     // This union is used to easily access the most significant 
                // bit of the configuration data 
               
              // Note : This assumes that the C compiler stores bit-fields 
              // with the first field going into the LSB. If this is not the 
              // case, move the MSB definition to the first bit 
        INT16U Data; 
        struct 
        { 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U :1; 
            INT16U MSB :1; 
        } W; 
    } wdun; 
   
    o_pale=1; 
 
    wdun.Data=addranddata; 
    o_pale=0; 
     
    // Send address bits  
    for (BitCounter=0;BitCounter<7;BitCounter++) 
    { 
        o_pclk    = 1; 
        o_pdata   = wdun.W.MSB; 
        wdun.Data = wdun.Data<<1; 
        o_pclk    = 0; 
    } 
   
    // Send read/write bit, Ignore bit in data, always use 1  
    o_pclk  = 1; 
    o_pdata = 1; 
    o_pclk  = 0; 
    wdun.Data = wdun.Data<<1; 
    o_pclk  = 1; 
    o_pale  = 1; 
     
    // Send data bits  
    for (BitCounter=0;BitCounter<8;BitCounter++) 
    { 
        o_pclk  = 1; 
        o_pdata = wdun.W.MSB; 
        wdun.Data = wdun.Data<<1; 
        o_pclk  = 0; 
    } 
    o_pclk = 1; 
} 
 
 
//=========================================================================== 
//= This routine reads from a single CC1000 register                        = 
//=========================================================================== 
INT8U ReadFromCC1000Register(INT8U addr) 
{ 
    INT8U BitCounter; 
  
    union  
    {     // This unit is used to easily access the most significant  
              // bit of the configuration data  
 
              // Note : This assumes that the C compiler stores bit-fields  
              // with the first field going into the LSB. If this is not the  
              // case, switch the MSB and LSB definitions  
        INT8U Data; 
        struct 
        { 
            INT8U LSB :1; 
            INT8U :1; 
            INT8U :1; 
            INT8U :1; 
            INT8U :1; 
            INT8U :1; 
            INT8U :1; 
            INT8U MSB :1; 
        } B; 
    } byun; 
   

⌨️ 快捷键说明

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