Esempio n. 1
0
int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv)
{
	u32		ratevalue;/* 4 */
	int status = NDIS_STATUS_SUCCESS;
	struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context);

	RT_TRACE(_module_mp_, _drv_notice_,
		 ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n"));

	if (poid_par_priv->type_of_oid != SET_OID)
		return NDIS_STATUS_NOT_ACCEPTED;

	if (poid_par_priv->information_buf_len != sizeof(u32))
		return NDIS_STATUS_INVALID_LENGTH;

	ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */
	RT_TRACE(_module_mp_, _drv_notice_,
		 ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue));
	if (ratevalue >= MPT_RATE_LAST)
		return NDIS_STATUS_INVALID_DATA;

	Adapter->mppriv.rateidx = ratevalue;

	_irqlevel_changed_(&oldirql, LOWER);
	SetDataRate(Adapter);
	_irqlevel_changed_(&oldirql, RAISE);

	return status;
}
void CSensorBackendSym::SetProperties()
    {
    if(sensor()->outputRange() != -1)
        {
        //Set measurement range
        TInt err = SetMeasurementRange();
        if(err != KErrNone)
            {
            sensorError(err);
            }
        }
    if(sensor()->dataRate() != 0)
        {
        //Set data rate
        TInt err = SetDataRate();
        if(err != KErrNone)
            {
            sensorError(err);
            }
        }
    }
Esempio n. 3
0
bool ofxCrazyradio::init() {
  int ret = libusb_init(&ctx_);
//  std::cout << "libusb_init: " << ret << std::endl;
//  libusb_set_debug(ctx_, 3);
  
  bool found = false;
  libusb_device **list;
  ssize_t count = libusb_get_device_list(ctx_, &list);
//  std::cout << "libusb_get_device_list: " << count << std::endl;
  for (int i = 0; i < count; i++) {
    struct libusb_device_descriptor desc;
    ret = libusb_get_device_descriptor(list[i], &desc);
    if (desc.idVendor == 0x1915 && desc.idProduct == 0x7777) {
      found = true;
      ret = libusb_open(list[i], &handle_);
//      std::cout << "libusb_open: " << ret << std::endl;
      
//      std::cout << "version: " << std::hex << desc.bcdDevice << std::dec << std::endl;
      
//      uint8_t string_desc[256];
//      ret = libusb_get_string_descriptor_ascii(handle_, desc.iManufacturer, string_desc, 256);
//      std::cout << "libusb_get_string_descriptor_ascii: " << ret << std::endl;
//      std::cout << string_desc << std::endl;
//
      
//      for (int n = 0; n < desc.bNumConfigurations; n++) {
//        libusb_config_descriptor *config_desc;
//        const libusb_interface_descriptor *inter_desc;
//        const libusb_endpoint_descriptor *ep_desc;
//        const libusb_interface *inter;
//        libusb_get_config_descriptor(list[i], n, &config_desc);
//        std::cout << "config: " << (int)config_desc->bConfigurationValue << std::endl;
//        std::cout << "bNumInterfaces: " << (int)config_desc->bNumInterfaces << std::endl;
//        for (int i = 0; i < (int)config_desc->bNumInterfaces; i++) {
//          inter = &config_desc->interface[i];
//          std::cout << "  num_altsetting: " << inter->num_altsetting << std::endl;
//          for (int j = 0; j < inter->num_altsetting; j++) {
//            inter_desc = &inter->altsetting[j];
//            std::cout << "    Interface number: " << (int)inter_desc->bInterfaceNumber << std::endl;
//            std::cout << "    number of endpoint: " << (int)inter_desc->bNumEndpoints << std::endl;
//            for (int k = 0; k < (int)inter_desc->bNumEndpoints; k++) {
//              ep_desc = &inter_desc->endpoint[k];
//              std::cout << "     desc type: " << (int)ep_desc->bDescriptorType << std::endl;
//              std::cout << "     ep address: " << (int)ep_desc->bEndpointAddress << std::endl;
//              std::cout << "     attributes: " << std::hex << (int)ep_desc->bmAttributes << std::dec << std::endl;
//            }
//          }
//        }
//      }
      
//      ret = libusb_kernel_driver_active(handle_, 0);
//      std::cout << "libusb_kernel_driver_active: " << ret << std::endl;
      
      ret = libusb_claim_interface(handle_, 0);
//      std::cout << "libusb_claim_interface: " << ret << std::endl;
      
      libusb_set_configuration(handle_, 1);
      SetDataRate(DR_250KPS);
      SetChannel(2);
      arc_ = -1;
      SetContCarrier(false);
      uint8_t address[] = "\xe7\xe7\xe7\xe7\xe7";
      SetAddress(address);
      SetPower(P_0DBM);
      SetArc(3);
      SetArdBytes(32);
      break;
    }
  }
  libusb_free_device_list(list, 1);
  
  return found;
}
Esempio n. 4
0
int main(int argc, char **argv)
{
    
    int status;
    int i;
    int debug = 0;
    int long_preamble = 0;
    
    int test = TEST_NONE;
    DataRate rate_e = DATA_RATE_1M;
    char *rate_s = "1Mbps";
    char *interface_name = NULL;
    
    
    DBG("argc=%u\n", argc);

    if(argc < 2)
    {
        print_usage();
        return -1;
    }

    interface_name = argv[1];

    
    
    for(i=2;i<argc;i++)
    {
        if(str_comp(argv[i], "-ch:", 4))
        {
            channel = atoi(argv[i]+4);
            if((channel > 14) || (channel < 1))
            {
                CON("Invalid channel: %u\n", channel);
                return -1;
            }
            continue;
        }

        if(str_comp(argv[i], "-time:", 6))
        {
            time = atoi(argv[i]+6);
            if((time > 24*3600) || (time < 1))
            {
                CON("Invalid time: %u\n", time);
                return -1;
            }
            continue;
        }

        if(str_comp(argv[i], "-rate:", 6))
        {
            int rate = atoi(argv[i]+6);
            switch(rate)
            {
                case 1:
                case 1000:
                    rate_e = DATA_RATE_1M;
                    rate_s = "1Mbps";
                    break;
                case 2:    
                case 2000:
                    rate_e = DATA_RATE_2M;
                    rate_s = "2Mbps";
                    break;
                case 5500:
                    rate_e = DATA_RATE_5_5M;
                    rate_s = "5.5Mbps";
                    break;
                //case 6: the user migh have writen "-rate:6.5"...    
                case 6000:
                    rate_e = DATA_RATE_6M;
                    rate_s = "6Mbps";
                    break;
                case 6500:
                    rate_e = DATA_RATE_MCS0;
                    rate_s = "6.5Mbps (MCS0)";
                    break;    
                case 9:    
                case 9000:
                    rate_e = DATA_RATE_9M;
                    rate_s = "9Mbps";
                    break;
                case 11:    
                case 11000:
                    rate_e = DATA_RATE_11M;
                    rate_s = "11Mbps";
                    break;
                case 12:    
                case 12000:
                    rate_e = DATA_RATE_12M;
                    rate_s = "12Mbps";
                    break;
                case 13:    
                case 13000:
                    rate_e = DATA_RATE_MCS1;
                    rate_s = "13Mbps (MSC1)";
                    break;
                case 18:    
                case 18000:
                    rate_e = DATA_RATE_18M;
                    rate_s = "18Mbps";
                    break;
                case 19500:
                    rate_e = DATA_RATE_MCS2;
                    rate_s = "19.5Mbps (MSC2)";
                    break;
                case 22:    
                case 22000:
                    rate_e = DATA_RATE_22M;
                    rate_s = "22Mbps";
                    break;
                case 24:    
                case 24000:
                    rate_e = DATA_RATE_24M;
                    rate_s = "24Mbps";
                    break;
                case 26:    
                case 26000:
                    rate_e = DATA_RATE_MCS3;
                    rate_s = "26Mbps (MSC3)";
                    break;
                case 33:    
                case 33000:
                    rate_e = DATA_RATE_33M;
                    rate_s = "33Mbps";
                    break;
                case 36:    
                case 36000:
                    rate_e = DATA_RATE_36M;
                    rate_s = "36Mbps";
                    break;
                case 39:
                case 39000:
                    rate_e = DATA_RATE_MCS4;
                    rate_s = "39Mbps (MCS4)";
                    break;
                case 48:    
                case 48000:
                    rate_e = DATA_RATE_48M;
                    rate_s = "48Mbps";
                    break;
                case 52:    
                case 52000:
                    rate_e = DATA_RATE_MCS5;
                    rate_s = "52Mbps (MCS5)";
                    break;
                case 54:    
                case 54000:
                    rate_e = DATA_RATE_54M;
                    rate_s = "54Mbps";
                    break;    
                case 58500:
                    rate_e = DATA_RATE_MCS6;
                    rate_s = "58.5Mbps (MCS6)";
                    break;
                case 65:    
                case 65000:
                    rate_e = DATA_RATE_MCS7;
                    rate_s = "65Mbps (MSC7)";
                    break;
               default:
                   CON("Invalid modulation rate %uKbps\n",rate);
                   return -1;
           }
           continue;
        }
        
        if(str_comp(argv[i], "-bi:", 4))
        {
            burst_interval = atoi(argv[i]+4);
            if(burst_interval < 0)
            {
                CON("Invalid burst interval: %u\n", burst_interval);
                return -1;
            }
            continue;
        }
         
        if(str_comp(argv[i], "-size:", 6))
        {
            packet_size = atoi(argv[i]+6);
            if((packet_size < 0) || (packet_size > 1536))
            {
                CON("Invalid packet size: %u\n", packet_size);
                return -1;
            }
            continue;
        }
        
        if(str_comp(argv[i], "-pwr:", 5))
        {
            output_power = atoi(argv[i]+5);
            if((output_power < 0) || (output_power > 30))
            {
                CON("Invalid output power: %ddBm\n", output_power);
                return -1;
            }
            continue;
        }     

        if(str_comp(argv[i], "none", 4))
        {
            test = TEST_NONE;
            continue;
        }

        if(str_comp(argv[i], "tx", 2))
        {
            test = TEST_TX;
            continue;
        }

        if(str_comp(argv[i], "rx", 2))
        {
            test = TEST_RX;
            continue;
        }
        
        if(str_comp(argv[i], "-lp", 3))
        {
            long_preamble = 1;
            continue;
        }  

        if(str_comp(argv[i], "-dbg", 4))
        {
            enable_debug();
            continue;
        }

        CON("I do not understand argument \"%s\", ignoring\n", argv[i]);
    }

    status = set_interface(interface_name);
    if(status)
    {
        CON("Could not set interface name\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        return -1;
    }
  
  
    status = OpenDUT();
    if(status)
    {
        CON("Could not open connection to Nanoradio WiFi-chip\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        return -1;
    }
     
    status = SetLongPreamble(long_preamble);
    if(status)
    {
        CON("Failed to set long preamble\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        goto exit;
    }
     
    status = SetBurstInterval(burst_interval);
    if(status)
    {
        CON("Failed to set burst interval\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        goto exit;
    }   
  
  
    status = SetChannel(channel);
    if(status)
    {
        CON("Failed to write channel to Nanoradio WiFi-chip\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        goto exit;
    }
    
    status = SetPayload(packet_size);
    if(status)
    {
        CON("Failed to set packet size\n");
        CON("  Driver say:\"%s\"\n",GetErrorString());
        goto exit;
    }
  

  status = SetDataRate(rate_e);
  if(status)
  {
    CON("Failed to write data rate to Nanoradio WiFi-chip\n");
    CON("  Driver say:\"%s\"\n",GetErrorString());
    goto exit;
  }

    switch(test)
    {
        case TEST_NONE:
            break;
        case TEST_TX:
        {
            status = TxGain(output_power);
            if(status)
            {
                CON("Failed to set output power\n");
                CON("  Driver say:\"%s\"\n",GetErrorString());
                goto exit;
            }   
         
            status = TxStartWithMod();
            if(status)
            {
                CON("Failed to start TX\n");
                CON("  Driver say:\"%s\"\n",GetErrorString());
                goto exit;
            }
            else
            {
                CON("Sending frames continiously on channel %u with rate %s for %u seconds\n",channel,rate_s,time);
                sleep(time);
                status = TxStop();
                if(status)
                {
                    CON("Failed to stop TX\n");
                    CON("  Driver say:\"%s\"\n",GetErrorString());
                    goto exit;
                }
                
            }
        }
        break;
        
        case TEST_RX:
        {
            status = RxStart();
            if(status)
            {
                CON("Failed to start RX\n");
                CON("  Driver say:\"%s\"\n",GetErrorString());
                goto exit;
            }
            else
            {
                CON("Counting frames on channel %u with rate %s for %u seconds\n",channel,rate_s,time);
                sleep(time);
                status = RxStop();
                if(status)
                {
                    CON("Failed to stop RX\n");
                    CON("  Driver say:\"%s\"\n",GetErrorString());
                    goto exit;
                }
                else
                {
                    CON("Good frames:%u\n", GetGoodFrame());
                }
            }
      }
      break;
  }

exit:

    CloseDUT();
    return status;
}
Esempio n. 5
0
int main(int argc, char* argv[])
{
	BOOL bQuit = FALSE;
	BOOL bPrintHeader = TRUE;
    int portNum = 0;
	int tryPortNum;
	int Ccount = 0;
	
	printf("\n   3DM-GX3 Read and Write Data Rate\n");

	/*-------- If user specifies a port, then use it */
	if (argc > 1) {
		tryPortNum = atoi(argv[1]);
		if (tryPortNum < 2 || tryPortNum > 256) {
			printf("   usage:  DataRate <portNumber>\n");
			printf("        valid ports are 2..256\n");
			exit(1);
		}

	        /*-------- open a port, map a device */
	        portNum = i3dmgx3_openPort(tryPortNum, 115200, 8, 0, 1, 1024, 1024);
	        if (portNum<0) {
		    printf("   port open failed.\n");
		    printf("   Comm error %d, %s: ", portNum, explainError(portNum));
		    exit(1);
	        }

        }else{
          portNum=OnGetSerialPorts();
          if(portNum<0)
             exit(1);
        }
	
	printf("\n  3DM-GX3-25 Using COM Port #%d \n", portNum);
   
	while(!bQuit){
		int chOption = 0;

		if(bPrintHeader)
		{
			printf("\n");
			printf("Enter an Option: (D)ata Rate (C)ontinuous (L)og_Continuous (Q)uit\n");
			printf("D Data Rate      - Modify or review the current Data Rate \n");
			printf("C Continuous     - Put the node in continuous mode and print each record\n");
			printf("L Log Continuous - Put the node in continuous mode log and print each record\n");
			printf("Q Quit           - Quit the application\n");

			bPrintHeader = FALSE;
		}

		//read option from the keyboard
		while(!ReadCharNoReturn(&chOption))
		{
			Sleep(50);
		}

		//
		switch(chOption)
		{
			case 'D':
			case 'd': SetDataRate(portNum); bPrintHeader = TRUE; break;

			case 'C':
			case 'c': ReadContinuousData(portNum); bPrintHeader = TRUE; break;

			case 'L':
			case 'l': 
				      ReadContinuousLogData(portNum); 
				      bPrintHeader = TRUE; 
				      break;

			case 'q':
			case 'Q': bQuit = TRUE; break;

			case 'h':
			case 'H': bPrintHeader = TRUE; break;

			default: printf("Invalid Option\n\n"); bPrintHeader = TRUE;
		}
	}
				
	return 0;
}
Esempio n. 6
0
void SamplingData(int portNum){

int Value=0;
unsigned short DCcheck=0;
BOOL bQuit = FALSE;
BOOL bPrintHeader = TRUE;
BYTE Record[20];
BYTE BlittleEndian[31];
BYTE byteOne=0x00;
BYTE byteTwo=0x00;
int chOption = 0;
short fw_check = 0;
int i = 0;
float LEaccel[4];
float LEang[4];

while(Value == 0)
	{
		if(bPrintHeader)
		{
			printf("\n");
			printf("Select an Option From the Following Menu \n");
			printf("0 Data Rate                - Modify or review the current DataRate\n");
			printf("1 Calculate Orientation    - Enable Calculate Orientation  \n");
			printf("2 Coning & Sculling        - Enable Coning & Sculling \n");
			printf("3 Little Endian            - Change IMU Big Endian format to Little\n");
            printf("4 NaN's Suppression        - Suppress NaN Data  \n");
			printf("5 Finite Size Corrction    - Enable Finite Size Correction \n");
			printf("6 Disable Magnetometer     - Disable the Magnetometer \n");
            printf("7 Enable Magnetometer      - Enable the Magnetometer Low Power Setting \n");
			printf("8 Disable Magnetic North   - Disable the Magnetic North Compenstation \n");
            printf("9 Disable Gravity Comp     - Disable the Gravity Compenstation \n");
            printf("Q Enable Quaternion        - Enable the Quaternion Calculation \n");
			printf("E Exit Sampling            - Exit the Sampling Menu and return to the Main Menu\n");

			bPrintHeader = FALSE;
		}

		//read option from the keyboard
		while(!ReadCharNoReturn(&chOption))
		{
			Sleep(50);
		}
     
		switch (chOption){
			case '0': 
                      SetDataRate(portNum); bPrintHeader = TRUE; break;

			case '1': //Enable Calculate Orientation
					  //DataConditioning = 1;
				      byteOne=0x00;
				      byteTwo = 0x01;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
                      //DCcheck = convert2short(&Record[3]);
                      if(byteTwo == Record[4])
                         printf("\nSample Setting Calculate Orientation now Enabled.\n");
                      else
                         printf("\nError: Failure to Enable Sample Setting Calculate Orientation.\n");
                      bPrintHeader = TRUE; break;

			case '2': //Enable Coning & Sculling
				      byteOne=0x00;
					  byteTwo = 0x02;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
                      if(byteTwo == Record[4])
                         printf("\nSample Setting Coning & Sculling now Enabled.\n");
                      else
                         printf("\nError: Failure to Enable Sample Setting Coning & Sculling.\n");
                      bPrintHeader = TRUE; break;
                                               
            case '3': //Set Floating Point from sensor to Little Endian
				      byteOne=0x00;
				      byteTwo = 0x10;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
					  if(byteTwo == Record[4]){
                         printf("\n\nSample Setting Floating Point data is sent in Little Endian.\n");
						 i3dmgx3_AccelAndAngRate(portNum,&BlittleEndian[0]);
						 //printf("received Data----------------\n");
						 for(i=0;i<4;i++){
							 LEaccel[i] = Little_Endian_Float(&BlittleEndian[1 + i*4]);
							 //LEaccel[0] = FloatFromBytes(BlittleEndian[1 ]);
                             LEang[i]   = Little_Endian_Float(&BlittleEndian[13 + i*4]);
						 }
						 printf("Acceleration & Angular Rate (0xC2)______\n");
                         printf("           X              Y              Z    \n");
						 //printf("  %2.6f\n ",LEaccel[0]);
                         printf(" Accel  %2.6f\t%2.6f\t%2.6f\n", LEaccel[0], LEaccel[1], LEaccel[2]); 
						 printf(" Angle  %2.6f\t%2.6f\t%2.6f\n", LEang[0], LEang[1], LEang[2]);
					  }else
                         printf("Error: Failure to set Sample Setting Floating Point data to Little Endian Format.\n");
                      bPrintHeader = TRUE; break;

			case '4': //Suppress NaN data
				      byteOne=0x00;
					  byteTwo = 0x20;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check);
                      if(byteTwo == Record[4])
                         printf("\nSample Setting NaN data is now suppressed.\n");
                      else
                         printf("\nError: Failure to suppress Sample Setting NaN data. \n"); 
                      bPrintHeader = TRUE; break;

            case '5': //Enable Finite Size Correction
				      byteOne=0x00;
					  byteTwo = 0x40;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check);
                      if(byteTwo == Record[4])
                         printf("\nSample Setting Finite Size Correction now Enabled.\n");
                      else
                         printf("\nError: Failure to Enable Sample Setting Finite Size Correction.\n");
                      bPrintHeader = TRUE; break;

			//Case(s) 6 - 9 and q require firmware 1.1.27 or greater --------------
			case '6': //Disable Magnetometer
				      byteOne=0x01;
					  byteTwo = 0x00;
					  fw_check = 1;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check);
                      if(byteOne == Record[3])
                         printf("\nSample Setting Magnetometer Disabled. \n");
                      else
                         printf("\nError: Failure to Disable Sample Setting Magnetometer.\n"); 
                      bPrintHeader = TRUE; break;
                                               
            case '7': //Enable Magnetometer low power
					  byteOne=0x02;
					  byteTwo = 0x00;
					  fw_check = 1;
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
                      if(byteOne == Record[3])
                         printf("\nSample Setting Magnetometer now Enabled to Low Power Setting.\n");
                      else
                         printf("\nError: Failure to Enable Sample Setting Magnetometer Low Power Setting.\n");
                      bPrintHeader = TRUE; break;

			case '8': //Disable Magnetic North Compensation
					  byteOne = 0x04; //To Enable use byteOne=0x00;
					  byteTwo = 0x00;
					  fw_check = 1; // to enable use fw_check =8 to set time
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
                      if(byteOne == Record[3])
                         printf("\nSample Setting Magnetic North Compensationn Disabled.");
                      else
                         printf("\nError: Failure to Disable Sample Setting Magnetic North Compensation.\n");
					  // if selection is Enabled ask if user wants to run realign up and north 0xDD
					  bPrintHeader = TRUE; break;

            case '9': //Disable Gravity Compensationn
				      byteOne = 0x08; //To Enable use byteOne=0x00;
					  byteTwo = 0x00;
					  fw_check = 1; // to enable use fw_check =9 to set time
                      SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check); 
                      if(byteOne == Record[3])
                         printf("\nSample Setting Gravity Compensationn Disabled");
                      else
                         printf("\nError: Failure to Disable Sample Setting Gravity Compensation\n");
                      // if selection is Enabled ask if user wants to run realign up and north 0xDD
					  bPrintHeader = TRUE; break;

			case 'q':
			case 'Q'://Enable Quaternion(s)
				     byteOne=0x10;  //needs bit 0 bit 1 and bit 11 set on
                     byteTwo=0x03;
					 fw_check = 1;
                     SetSampleSetting(portNum,byteOne, byteTwo, &Record[0], fw_check);
					 if(byteTwo == Record[4]){
                         printf("\nSample Setting Quaternion Calculation now enabled\n");
                         Get_Quaternion(portNum);
                     }
                     else
                          printf("\nError: Failure to set Sample Setting Quaternion Calculation\n");
					  //Get_Quaternion(portNum);
                      bPrintHeader = TRUE; break;

            case 'e':
			case 'E': bQuit = TRUE; bPrintHeader = FALSE; return; break;

			case 'h':
			case 'H': bPrintHeader = TRUE; break;

			default: printf("Invalid Option\n\n"); bPrintHeader = TRUE;
						
		   }			
	 }
}
Esempio n. 7
0
void InitRfm22( U8 radio )
{
	// Variables
	// Data rate 1 - 128 kbps.
	U32 data_rate_bps = 9600;//100000;
	U32 frequency_hz = 434000000;
	
	
	//disable all interrupts
	WriteRegister( radio, RFREG_INT_EN_2, 0x00 );

	//enter ready mode (xtal on, PLL off)
	WriteRegister( radio, RFREG_FUNC_CTRL_1, xton ); //xton

	//set crystal oscillator load capacitance to 0x7F. (no idea why)
	WriteRegister( radio, RFREG_LOAD_CAP, 0x7F ); //xlc[6:0]

	SetDataRate( radio, data_rate_bps );

	SetFrequency( radio, frequency_hz );

	//enable TX and RX packet handling, and CRC generation. MSB first.
	WriteRegister( radio, RFREG_DATA_ACCESS_CTRL, enpacrx | crc_0_ccitt | encrc | enpactx );


	//set all header/packet info
	//Header control: broadcast address check is enabled for all 4 bytes.
	//all 4 received header bytes are checked against the check header bytes too.
	WriteRegister( radio, RFREG_HEADER_CTRL_1, 0xFF );

	//prealen[8] = 0
	//synclen[1:0] = 1, sync word 3 and 2.
	//fixpklen = 0, packet length is indicated in header
	//hdlen[2:0] = 4, header 3, 2, 1, 0 used
	WriteRegister( radio, RFREG_HEADER_CTRL_2, 0x42 );

	//prealen[7:0] = 0x40, 64 dec. thats 32 bytes of preamble, or 256 bits.
	WriteRegister( radio, RFREG_PREAMBLE_LEN, 0x40 );

	//preath[4:0] = 0x4, 4 nibbles are processed during detection. (16 bits)
	WriteRegister( radio, RFREG_PREAMBLE_DETECT_CTRL, 0x20 );

	//sync word, sync[31:0]
	WriteRegister( radio, RFREG_SYNC_WORD_3, 0x2D );
	WriteRegister( radio, RFREG_SYNC_WORD_2, 0xD4 );
	WriteRegister( radio, RFREG_SYNC_WORD_1, 0x00 );
	WriteRegister( radio, RFREG_SYNC_WORD_0, 0x00 );

	//transmit header, txhd[31:0]
	WriteRegister( radio, RFREG_TX_HEADER_3, 's' );
	WriteRegister( radio, RFREG_TX_HEADER_2, 'o' );
	WriteRegister( radio, RFREG_TX_HEADER_1, 'n' );
	WriteRegister( radio, RFREG_TX_HEADER_0, 'g' );

	//pklen[7:0] = 17 dec. affects transmitted packets, not RX since packets include length.
	WriteRegister( radio, RFREG_TX_PACKET_LEN, 17 );

	//Check header, chhd[31:0]
	WriteRegister( radio, RFREG_CHK_HEADER_3, 's' );
	WriteRegister( radio, RFREG_CHK_HEADER_2, 'o' );
	WriteRegister( radio, RFREG_CHK_HEADER_1, 'n' );
	WriteRegister( radio, RFREG_CHK_HEADER_0, 'g' );

	//Header enable, hden[31:0]. mask used to select which bits are compared between incoming packet and our check header
	WriteRegister( radio, RFREG_HEADER_EN_3, 0xFF );
	WriteRegister( radio, RFREG_HEADER_EN_2, 0xFF );
	WriteRegister( radio, RFREG_HEADER_EN_1, 0xFF );
	WriteRegister( radio, RFREG_HEADER_EN_0, 0xFF );


	//tx power
	WriteRegister( radio, RFREG_TX_POWER, 0x00 ); //there could be an error in the datasheet. This should be max power.

	//modulation
	//turn on FIFO mode, GFSK
	WriteRegister( radio, RFREG_MOD_MODE_CTRL_2, modtyp_3_gfsk | dtmod_2_fifo );
	//RFREG_MOD_MODE_CTRL_1 set in data rate area



	ConfigureRxModemSettings(radio,0,0);

	//IF Bandwidth filter


	WriteRegister( radio, RFREG_MODEM_TEST, 0x01 );

	WriteRegister( radio, RFREG_FREQ_DEV, 0x48 );

	WriteRegister( radio, RFREG_VCO_CURRENT_TRIM, 0x7F );

	WriteRegister( radio, RFREG_DRIVIDER_CURRENT_TRIM, 0x40 );

	WriteRegister( radio, RFREG_CHARGEPUMP_CURRENT_OVERRIDE, 0x80 );

	WriteRegister( radio, RFREG_AGC_OVERRIDE_2, 0x0B );

	WriteRegister( radio, RFREG_DELTA_ADC_TUNE_2, 0x04 );



	//packet description:
	//1-512 bytes of preamble.
	//1-4 bytes of sync word
	//0-4 bytes of TX header
	//0 or 1 byte of length
	//DATA
	//0 or 2 bytes of CRC

}