Beispiel #1
0
void it_rf_init(void)
{
    // logic 0 and logic 1 power levels for OOK modulation
#ifdef CONFIG_MOD_INTERTECHNO_PW
    uint8_t PATable[2] = { 0x00, it_pwr[it_pwr_level] };
#else
    uint8_t PATable[2] = { 0x00, INTERTECHNO_RF_POWER };
#endif

    ResetRadioCore();

    // minimal register changes
    WriteSingleReg(IOCFG0, 0x06);       //GDO0 Output Configuration
    WriteSingleReg(PKTLEN, INTERTECHNO_SEQ_SIZE*4);       //Packet Length
    WriteSingleReg(PKTCTRL0, 0x00);     //Packet Automation Control
    WriteSingleReg(FREQ2, 0x10);        //Frequency Control Word, High Byte
    WriteSingleReg(FREQ1, 0xB0);        //Frequency Control Word, Middle Byte
    WriteSingleReg(FREQ0, 0x71);        //Frequency Control Word, Low Byte
    WriteSingleReg(MDMCFG4, 0x86);      //Modem Configuration
    WriteSingleReg(MDMCFG3, 0x70);      //Modem Configuration
    WriteSingleReg(MDMCFG2, 0x30);      //Modem Configuration
    WriteSingleReg(MDMCFG1, 0x02);      //Modem Configuration
    WriteSingleReg(MCSM1, 0x00);        //Main Radio Control State Machine Configuration
    WriteSingleReg(MCSM0, 0x00);        //Main Radio Control State Machine Configuration
    WriteSingleReg(FOCCFG, 0x76);       //Frequency Offset Compensation Configuration
    WriteSingleReg(WOREVT1, 0x87);      //High Byte Event0 Timeout
    WriteSingleReg(WOREVT0, 0x6B);      //Low Byte Event0 Timeout
    WriteSingleReg(WORCTRL, 0xF8);      //Wake On Radio Control
    WriteSingleReg(FREND0, 0x11);       //Front End TX Configuration
    WriteSingleReg(TEST0, 0x09);        //Various Test Settings

    WriteBurstPATable(&PATable[0], 2);
}
Beispiel #2
0
void main( void )
{  
  // Stop watchdog timer to prevent time out reset 
  WDTCTL = WDTPW + WDTHOLD; 
  // Increase PMMCOREV level to 2 for proper radio operation
  SetVCore(2);                               
  
  ResetRadioCore();
  InitButtonLeds();
  InitTimer(); 
    
  // Clean out the RX Buffer 
  rxPosition = PACKET_LEN+2;
  while(rxPosition--)
  {
    RxBuffer[rxPosition] = 0; 
  }

  InitRadio();  
  ReceiveOn(); 
//Check RSSI here
  while (1)
  { 
    P1IE |= BIT7;                           // Enable button interrupt
    
    __bis_SR_register( LPM3_bits + GIE );   
    __no_operation(); 
    
    if (buttonPressed)                      // Process a button press->transmit
    {
      ReceiveOff();                         // Button means TX, stop RX
      receiving = 0;                         

      TransmitPacket();                 

      buttonPressed = 0;                    // Re-enable button press                           
    }
    if(receiving)
    {
      ReceivePacket(); 
      __no_operation(); 
      // Check CRC
      if(RxBuffer[CRC_LQI_IDX] & CRC_OK)
      //Got it!
      P1OUT ^= BIT0;                    // Toggle LED1 in celebration

    }
    if(!transmitting)
    {
      ReceiveOn(); 
    }
  }


}
void init_RF(void){
	// Increase PMMCOREV level to 2 for proper radio operation
	SetVCore(2);
	ResetRadioCore();
	InitRadio();

	ReceiveOn();
	receiving = 1;
	transmitting = 0;
	ADDRESS = 0x03;
}
Beispiel #4
0
void Init_RF(void){
  
  // Increase PMMCOREV level to 2 in order to avoid low voltage error 
  // when the RF core is enabled
  SetVCore(2);
  ResetRadioCore();     
  WriteBurstReg(IOCFG2, (unsigned char*)RF1A_REGISTER_CONFIG, CONF_REG_SIZE);
  WritePATable();
  InitButtonLed();
  ReceiveOn();  
  //Wait for RX status to be reached
  while((Strobe(RF_SNOP) & 0x70) != 0x10);
  
}
Beispiel #5
0
/*
 * Phy implementation functions
 */
void phy_init(void)
{
    //Set radio state
    state = Idle;
    spi_init();
    radioConfigureInterrupt();

    //Reset the radio core
    ResetRadioCore();

    //Write configuration
    WriteRfSettings(&rfSettings);

    last_tx_cfg.eirp=0;
    last_tx_cfg.spectrum_id = 0;
    last_tx_cfg.sync_word_class=0;

}
void main()
{
	system_init(buffer, sizeof(buffer), buffer, sizeof(buffer));
#if RF == CC1101 || RF == CC1120
	spi_init();
#endif

	ResetRadioCore();
	int p = ReadSingleReg(PARTNUM);
	log_print_string("PARTNUM 0x%x", p);
	p = ReadSingleReg(VERSION);
	log_print_string("VERSION 0x%x", p);
	log_print_string("started");

	WriteRfSettings(&rfSettings);
//	WriteSingleReg(IOCFG2,0x0B);    //GDO2 Output Pin Configuration
//	WriteSingleReg(IOCFG0,0x0C);    //GDO0 Output Pin Configuration
//	WriteSingleReg(FIFOTHR,0x47);   //RX FIFO and TX FIFO Thresholds
//	WriteSingleReg(PKTCTRL0,0x22);  //Packet Automation Control
//	WriteSingleReg(FSCTRL1,0x08);   //Frequency Synthesizer Control
//	WriteSingleReg(FREQ2,0x10);     //Frequency Control Word, High Byte
//	WriteSingleReg(FREQ1,0xB1);     //Frequency Control Word, Middle Byte
//	WriteSingleReg(FREQ0,0x3A);     //Frequency Control Word, Low Byte
//	WriteSingleReg(MDMCFG4,0xCA);   //Modem Configuration
//	WriteSingleReg(MDMCFG3,0x83);   //Modem Configuration
//	WriteSingleReg(MDMCFG2,0xB0);   //Modem Configuration
//	WriteSingleReg(DEVIATN,0x35);   //Modem Deviation Setting
//	WriteSingleReg(MCSM0,0x18);     //Main Radio Control State Machine Configuration
//	WriteSingleReg(FOCCFG,0x16);    //Frequency Offset Compensation Configuration
//	WriteSingleReg(AGCCTRL2,0x43);  //AGC Control
//	WriteSingleReg(WORCTRL,0xFB);   //Wake On Radio Control
//	WriteSingleReg(FREND0,0x11);    //Front End TX Configuration
//	WriteSingleReg(FSCAL3,0xE9);    //Frequency Synthesizer Calibration
//	WriteSingleReg(FSCAL2,0x2A);    //Frequency Synthesizer Calibration
//	WriteSingleReg(FSCAL1,0x00);    //Frequency Synthesizer Calibration
//	WriteSingleReg(FSCAL0,0x1F);    //Frequency Synthesizer Calibration
//	WriteSingleReg(TEST2,0x81);     //Various Test Settings
//	WriteSingleReg(TEST1,0x35);     //Various Test Settings
//	WriteSingleReg(TEST0,0x09);     //Various Test Settings
//	WriteSingleReg(RSSI,0x80);      //Received Signal Strength Indication
//	WriteSingleReg(MARCSTATE,0x01); //Main Radio Control State Machine State
//	WriteSingleReg(VCO_VC_DAC,0x94);//Current Setting from PLL Calibration Module

	//phy_keep_radio_on(true);

	Strobe(RF_SIDLE);
	Strobe(RF_SFTX);

	//uint8_t spectrum_id[2] = { 4, 0 };
	//phy_translate_and_set_settings(spectrum_id, 0);

	//set_length_infinite(false);
	//WriteSingleReg(PKTLEN, 7);

	Strobe(RF_STX);

	//WriteSingleReg(PKTCTRL0, 0x22);

	//WriteSingleReg(FIFOTHR, RADIO_FIFOTHR_FIFO_THR_17_48);

	//WriteBurstReg(RF_TXFIFOWR, packet, 7);




	/*
	ResetRadioCore();
	log_state();
	Strobe(RF_SIDLE);
	WriteRfSettings(&rfSettings);
	log_print_string("wrote settings");
	log_state();
	Strobe(RF_STX);
	log_print_string("strobed TX");
	*/

	int i;
	for(i = 0; i < 50;i++)
	{
		log_state();
	}



	while(1);
}
void main( void )
{  
  // Stop watchdog timer to prevent time out reset 
  WDTCTL = WDTPW + WDTHOLD; 
  TA1CCTL0 = CCIE;                          // CCR0 interrupt enabled
  TA1CCR0 = 50000;
  TA1CTL = TASSEL_2 + MC_1 + TACLR;         // SMCLK, upmode, clear TAR
   __bis_SR_register(GIE);
  //WDTCTL = WDT_ARST_250;
  //SFRIE1 |= WDTIE;                          // Enable WDT interrupt
  // Increase PMMCOREV level to 2 for proper radio operation
  SetVCore(2);                            
  
  ResetRadioCore();     
  InitRadio();
  InitButtonLeds();
  InitUart();
    
  ReceiveOn(); 
  receiving = 1; 
  _EINT();  
  while (1)
  { 
    //WDTCTL = WDT_ARST_250;
   // __bis_SR_register( LPM3_bits + GIE ); 
    __no_operation();
    
  if((!(BUTTON_IN & (1<<BUTTON_BIT))))
    {
      _NOP();
      delayms(30);
      if(!(BUTTON_IN & (1<<BUTTON_BIT)))
      {
        _NOP();
		buttonPressed = 1;		
        LEDR_ON();
        ReceiveOff();
        receiving = 0;
        Transmit( (unsigned char*)TxBuffer,sizeof TxBuffer);
        transmitting = 1;
		while(!(BUTTON_IN & (1<<BUTTON_BIT)));
      }
      
    }
    if(!transmitting)
    {
      ReceiveOn();
      receiving = 1;
    }
	if(buttonPressed && transmit == 1)
	{
		LEDR_ON();
        ReceiveOff();
        receiving = 0;
        Transmit( (unsigned char*)TxBuffer,sizeof TxBuffer);
        transmitting = 1;
		transmit = 0;
		receive = 1;
		delayms(500);
		buttonPressed = 0;	
	}
	if(count == 20 && buttonPressed == 0 && receive == 1)
	{
	buttonPressed = 1;	
	count = 0;
	transmit = 1;
	receive = 0;
	}
  }
}