/****************************************************************
*FUNCTION NAME:SendData
*FUNCTION     :use CC1101 send data
*INPUT        :txBuffer: data array to send; size: number of data to send, no more than 61
*OUTPUT       :none
****************************************************************/
void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)
{
	SpiWriteReg(CC1101_TXFIFO,size);
	SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size);			//write data to send
	SpiStrobe(CC1101_STX);									//start send
    while (!digitalRead(GDO0));								// Wait for GDO0 to be set -> sync transmitted
    while (digitalRead(GDO0));								// Wait for GDO0 to be cleared -> end of packet
	SpiStrobe(CC1101_SFTX);									//flush TXfifo
}
예제 #2
0
파일: RF.c 프로젝트: bearxiong99/XXOO_000
/*******************************************************************************
* Description : 
* Syntax      : CC1101(TxBuff, RF_payloadSize)
* Parameters I: 
* Parameters O: 
* return      : 
*******************************************************************************/
void CC1101_Send(uint8_t *TxBuff, const uint8_t len)
{
#ifdef CC1101_DISPLAY_TX_COMM_SYMBOL_EN    
    CC1101_displayTxCommSymbol();
#endif    
    CC1101_ExtInt_disable();  
    
    SpiWriteStrobe(SIDLE);      /* IDL状态下进行配置 */
    delayUs(200);
    CC1101_setPATable();      //8 level 0~7
    CC1101_setTxPower(PA_LEVEL_7);  // choice max PA
    SpiWriteStrobe(SFTX);
    delayUs(200);
    SpiWriteBurstReg(TXFIFO, TxBuff, len); 
    delayUs(200);

#ifdef RF_PA_EN    
    pinPA_Tx_EN;   // Tx PA  (RF PA内部 三极管有延时,配置完PA需 delayUs(200);)
    delayMs(5);
#endif
        
    //delayMs(10);   // ARM 频率快  延时发送 20ms <= T <= 500ms
    SpiWriteStrobe(STX);             

    //CC1101_waitSend();  //待改
//    delayMs(55);   // 20K
    
    delayMs(5);      /* 预留间隔时间 */

#ifdef RF_PA_EN  	
    pinPA_Tx_DIS;  // Tx don't through PA and Rx 
#endif

//------------------------------------------   
#ifdef RF_SLAVE    
    SpiWriteStrobe(SIDLE);      /* IDL状态下进行配置 */
    delayUs(200);
    CC1101_setPATable();      //8 level 0~7
    CC1101_setTxPower(PA_LEVEL_1);  // choice max PA
    
    delayMs(10);   // ARM 频率快  延时发送
    SpiWriteStrobe(STX);            
    
    delayMs(55);
    //CC1101_waitSend();  //待改
    delayMs(5);   
#endif
    
    CC1101_RxMode();  //default Rx mode enalbe ExtInt
    
    //wzg test
    IO_WriteGPIOPin(IO_PORT4,IO_PINxC,IO_BIT_SET);   //M-RXD-LED
    IO_WriteGPIOPin(IO_PORT3,IO_PINxF,IO_BIT_CLR);   //M-TXD-LED 
    //---------------------
}
/****************************************************************
*FUNCTION NAME:Init
*FUNCTION     :CC1101 initialization
*INPUT        :none
*OUTPUT       :none
****************************************************************/
void ELECHOUSE_CC1101::Init(void)
{
	SpiInit();										//spi initialization
	GDO_Set();										//GDO set
	digitalWrite(SS_PIN, HIGH);
	digitalWrite(SCK_PIN, HIGH);
	digitalWrite(MOSI_PIN, LOW);
	Reset();										//CC1101 reset
	RegConfigSettings();							//CC1101 register config
	SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8);		//CC1101 PATABLE config
}
예제 #4
0
파일: RF.c 프로젝트: bearxiong99/XXOO_000
/*******************************************************************************
* Description : 8 level
* Syntax      : 
* Parameters I: 
* Parameters O: 
* return      : 
*******************************************************************************/
static void CC1101_setPATable(void)
{
    SpiWriteBurstReg(PATABLE, (uint8_t *)PA_Tab, 8);    
}