Example #1
0
uint8_t setup_cc2500(void) {

	uint8_t returnValue=0;
	uint8_t initial_power = 0xFB;				// 0 dBm
	// Set-up rx_callback function

	do
	{
		// Changed
		//spi_init();                         // Initialize SPI port

		// FIXME Add uscib0 files
		cc_powerup_reset();               // Reset CCxxxx

		// TODO implement this
		wait_cycles(500);  // Wait for device to reset (Not sure why this is needed)

		if(writeRFSettings())                        // Write RF settings to config reg
		{
			returnValue = 1; // Failed
			break;
		}

		// FIXME Add uscib0 files
		cc_write_burst_reg( TI_CCxxx0_PATABLE, &initial_power, 1);//Write PATABLE

		// FIXME Add uscib0 files

		cc_strobe(TI_CCxxx0_SIDLE);
		WAIT1_Waitms(10);
		cc_strobe(TI_CCxxx0_SFRX);      // Flush RXFIFO
		WAIT1_Waitms(10);
		cc_strobe(TI_CCxxx0_SFTX);      // Flush RXFIFO
		WAIT1_Waitms(10);




		cc_strobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.



		returnValue = cc_read_status(TI_CCxxx0_MARCSTATE);
		returnValue =0;



		// When a pkt is received, it will
		// signal on GDO0 and wake CPU

		// FIXME
		// Configure GDO0 port
	//	GDO0_PxIES |= GDO0_PIN;       // Int on falling edge (end of pkt)
	//	GDO0_PxIFG &= ~GDO0_PIN;      // Clear flag
	//	GDO0_PxIE |= GDO0_PIN;        // Enable int on end of packet
		CC_2500_SETUP_DONE = true;
	}while(0);

	return returnValue;
}
Example #2
0
/*******************************************************************************
 * @fn     void setup_radio( uint8_t (*callback)(void) )
 * @brief  Initialize radio and register Rx Callback function
 * ****************************************************************************/
void setup_cc2500( uint8_t (*callback)(uint8_t*, uint8_t) )
{
  uint8_t initial_power = 0xFB;				// 0 dBm

  // Set-up rx_callback function
  rx_callback = callback;

  spi_setup();                         // Initialize SPI port

  cc_powerup_reset();               // Reset CCxxxx

  wait_cycles(500);  // Wait for device to reset (Not sure why this is needed)

  writeRFSettings();                        // Write RF settings to config reg
  cc_write_burst_reg( TI_CCxxx0_PATABLE, &initial_power, 1);//Write PATABLE

  cc_strobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
                                            // When a pkt is received, it will
                                            // signal on GDO0 and wake CPU

  // Configure GDO0 port
  GDO0_PxIES |= GDO0_PIN;       // Int on falling edge (end of pkt)
  GDO0_PxIFG &= ~GDO0_PIN;      // Clear flag
  GDO0_PxIE |= GDO0_PIN;        // Enable int on end of packet

}
Example #3
0
/*******************************************************************************
 * @fn void cc_powerup_reset()
 * @brief reset radio
 * ****************************************************************************/
void cc_powerup_reset(void)
{
  CSn_PxOUT |= CSn_PIN;
  wait_cycles(30);
  CSn_PxOUT &= ~CSn_PIN;
  wait_cycles(30);
  CSn_PxOUT |= CSn_PIN;
  wait_cycles(45);

  CSn_PxOUT &= ~CSn_PIN;        // /CS enable
  while (!(IFG2&UCB0TXIFG));                // Wait for TXBUF ready
  UCB0TXBUF = TI_CCxxx0_SRES;               // Send strobe
  // Strobe addr is now being TX'ed
  while (UCB0STAT & UCBUSY);                // Wait for TX to complete
  while(SPI_USCIB0_PxIN & SPI_USCIB0_SOMI); // Wait until the device has reset
  CSn_PxOUT |= CSn_PIN;         // /CS disable
}
Example #4
0
void 
ndelay(uint64_t nanos)
{
  ticks in_cycles = REF_SPEED_GHZ * nanos;
  wait_cycles(in_cycles);
}
Example #5
0
void 
udelay(uint64_t micros)
{
  ticks in_cycles = REF_SPEED_GHZ * 1000 * micros;
  wait_cycles(in_cycles);
}