예제 #1
0
파일: radio.c 프로젝트: giu7ppe/openwsn
void radio_loadPacket(uint8_t* packet, uint8_t len) {
   // change state
   radio_vars.state = RADIOSTATE_LOADING_PACKET;
   
   radio_spiStrobe(CC1101_SFTX, &radio_vars.radioStatusByte);
   radio_spiWriteTxFifo(&radio_vars.radioStatusByte, packet, len);
   
   // change state
   radio_vars.state = RADIOSTATE_PACKET_LOADED;
}
예제 #2
0
파일: radio.c 프로젝트: Adilla/openwsn-fw
void radio_rxEnable() {
   // change state
   radio_vars.state = RADIOSTATE_ENABLING_RX;
   
   // put radio in reception mode
   radio_spiStrobe(CC2420_SRXON, &radio_vars.radioStatusByte);
   radio_spiStrobe(CC2420_SFLUSHRX, &radio_vars.radioStatusByte);
   
   // wiggle debug pin
   debugpins_radio_set();
   leds_radio_on();
   
   // busy wait until radio really listening
   while (radio_vars.radioStatusByte.rssi_valid==0) {
      radio_spiStrobe(CC2420_SNOP, &radio_vars.radioStatusByte);
   }
   
   // change state
   radio_vars.state = RADIOSTATE_LISTENING;
}
예제 #3
0
파일: radio.c 프로젝트: giu7ppe/openwsn
void radio_rfOff() {
  // change state
  radio_vars.state = RADIOSTATE_TURNING_OFF;

  // calibrates frequency synthesizer and turns it off
  radio_spiStrobe(CC1101_SCAL, &radio_vars.radioStatusByte);
 
  debugpins_radio_clr();
  leds_radio_off();
  
  // change state
  radio_vars.state = RADIOSTATE_RFOFF;
   
}
예제 #4
0
파일: radio.c 프로젝트: Adilla/openwsn-fw
void radio_rfOff() {
   
   // change state
   radio_vars.state = RADIOSTATE_TURNING_OFF;
   
   radio_spiStrobe(CC2420_SRFOFF, &radio_vars.radioStatusByte);
   // poipoipoi wait until off
   
   // wiggle debug pin
   debugpins_radio_clr();
   leds_radio_off();
   
   // change state
   radio_vars.state = RADIOSTATE_RFOFF;
}
예제 #5
0
파일: radio.c 프로젝트: giu7ppe/openwsn
void radio_txNow() {
   // change state
   radio_vars.state = RADIOSTATE_TRANSMITTING;
   
   radio_spiStrobe(CC1101_STX, &radio_vars.radioStatusByte);
}
예제 #6
0
파일: radio.c 프로젝트: giu7ppe/openwsn
void radio_reset() {
  cc1101_IOCFG0_reg_t   cc1101_IOCFG0_reg;
  cc1101_PKTCTRL0_reg_t cc1101_PKTCTRL0_reg;
  cc1101_PKTLEN_reg_t   cc1101_PKTLEN_reg;
  cc1101_MDMCFG2_reg_t  cc1101_MDMCFG2_reg;
  cc1101_MCSM0_reg_t    cc1101_MCSM0_reg;


  // global reset 
  radio_spiStrobe(CC1101_SRES, &radio_vars.radioStatusByte);

  // default setting as recommended in datasheet
  cc1101_IOCFG0_reg.GDO0_CFG           = 63;   
  cc1101_IOCFG0_reg.GDO0_INV           = 0;
  cc1101_IOCFG0_reg.TEMP_SENSOR_ENABLE = 0;

  radio_spiWriteReg(CC1101_IOCFG0,
		    &radio_vars.radioStatusByte,
		    *(uint8_t*)&cc1101_IOCFG0_reg);

 
  // setting packet control
  cc1101_PKTCTRL0_reg.LENGTH_CONFIG    = 0;  // Fixing packet length 
  cc1101_PKTCTRL0_reg.CRC_EN           = 1;  // Enabling CRC calculation
  cc1101_PKTCTRL0_reg.unused_r0_2      = 0;
  cc1101_PKTCTRL0_reg.PKT_FORMAT       = 0;
  cc1101_PKTCTRL0_reg.WHITE_DATA       = 1;  // Data whitening

  radio_spiWriteReg(CC1101_PKTCTRL0,
		    &radio_vars.radioStatusByte,
		    *(uint8_t*)&cc1101_PKTCTRL0_reg);

  // Setting packet length to 128 bytes
  cc1101_PKTLEN_reg.PACKET_LENGTH      = 128;
  
  radio_spiWriteReg(CC1101_PKTLEN,
		    &radio_vars.radioStatusByte,
		    *(uint8_t*)&cc1101_PKTLEN_reg);


  //Emulating 32 bits word as recommended in datasheet
  cc1101_MDMCFG2_reg.SYNC_MODE         = 3;   // 32 bits sync word
  cc1101_MDMCFG2_reg.MANCHESTER_EN     = 0;
  cc1101_MDMCFG2_reg.MOD_FORMAT        = 0;
  cc1101_MDMCFG2_reg.DEM_DCFILT_OFF    = 0;
  
  radio_spiWriteReg(CC1101_MDMCFG2,
		    &radio_vars.radioStatusByte,
		    *(uint8_t*)&cc1101_MDMCFG2_reg);

  // setting main control state machine 
  cc1101_MCSM0_reg.FS_AUTOCAL          = 0;
  cc1101_MCSM0_reg.PO_TIMEOUT          = 1;
  cc1101_MCSM0_reg.PIN_CTRL_EN         = 0;
  cc1101_MCSM0_reg.XOSC_FORCE_ON       = 1;   // Forcing the XOSC to stay on even in SLEEP state

  radio_spiWriteReg(CC1101_MCSM0,
		    &radio_vars.radioStatusByte,
		    *(uint8_t*)&cc1101_MCSM0_reg);
  
  
}
예제 #7
0
파일: radio.c 프로젝트: Adilla/openwsn-fw
void radio_rfOn() {   
   radio_spiStrobe(CC2420_SXOSCON, &radio_vars.radioStatusByte);
   while (radio_vars.radioStatusByte.xosc16m_stable==0) {
      radio_spiStrobe(CC2420_SNOP, &radio_vars.radioStatusByte);
   }
}