コード例 #1
0
ファイル: brutus.c プロジェクト: Nooxet/embedded_bruteforce
int main()
{
    init_platform();

    xil_printf("%s\n\r", "Welcome to Brutus cracker system!");

    while (1) {
    	xil_printf("%s\n\r", "Enter hash: ");
		char recv = XUartLite_RecvByte(STDIN_BASEADDRESS); // read first char


		/* Read password hash */
		char buff[32];
		int idx_buff = 0;
		while (recv != '\r') {
			buff[idx_buff++] = recv;
			recv = XUartLite_RecvByte(STDIN_BASEADDRESS);
		}

		unsigned int i_buff[4] = {0};
		unsigned num = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 8; j++) {
				num = ctox(buff[j + i*8]);
				i_buff[i] += (pow(16, 7-j) * num);
			}
			//xil_printf("%x\n\r", i_buff[i]);
		}

		//xil_printf("%u\n\r", i_buff[0]);


		putfsl(i_buff[0], 0);
		putfsl(i_buff[1], 0);
		putfsl(i_buff[2], 0);
		putfsl(i_buff[3], 0);
		xil_printf("Cracking...\n\r");

		unsigned int resp;
		char *str = &resp; // c-magic

		getfsl(resp, 0);
		unsigned i;
		xil_printf("password: "******"%c", *(str+i));
		}
		getfsl(resp, 0);
		for (i = 0; i < 4; i++) {
			xil_printf("%c", *(str+i));
		}
		xil_printf("\n\r");
    }
    cleanup_platform();

    return 0;
}
コード例 #2
0
ファイル: mainLoop.c プロジェクト: PaintScratcher/uni_embs
char receive(){
	//
	// Helper function to handle receiving from UART and printing back to it for improved user experience
	char recieved = XUartLite_RecvByte(XPAR_RS232_DTE_BASEADDR);
	xil_printf("%c", recieved);
	return recieved;
}
コード例 #3
0
/*
 * runManualTest
 *
 * Provide a menu for user to test each interface manually 
 */
void runManualTest(void) {
	xil_printf("\r\n");
	while(1) {
		xil_printf("---- NetFPGA-SUME Manual Test Menu ----\r\n");
		xil_printf("i: Read DDR3 Info\r\n");
		xil_printf("s: Read DDR3 Test Status\r\n");
		xil_printf("p: Read Power Info\r\n");
		xil_printf("b: Back to Main Menu\r\n");
		xil_printf("Select: ");
		char cmd = XUartLite_RecvByte(XPAR_AXI_UARTLITE_0_BASEADDR);
		xil_printf("%c\r\n", cmd);
		switch (cmd) {
			case 'i':
				ddr3ReadInfo('B');
				break;
			case 's':
				ddr3RwStat();
				break;
			case 'p':
				pmReadInfo();
				break;
			case 'b':
				return;
			default:
				break;
		}
		xil_printf("\r\n");
	}
}
コード例 #4
0
ファイル: xl-xuart.c プロジェクト: mbref/mbref
inline u8 getkey(void)
{
	if(XUartLite_mIsReceiveEmpty(XLB_STDIO_BASEADDR)) {
		return '\0';
	} else {
		return XUartLite_RecvByte(XLB_STDIO_BASEADDR);
	}
}
コード例 #5
0
ファイル: serial.c プロジェクト: cuiyanzhe/ReFrESH
/* --- serGetChar1()  Get 1 char from the UART Lite, but do not block.
   --- Return number of chars received. */
char serGetChar1(unsigned char *str)
{

  /* Check if data is available */
    *str = XUartLite_RecvByte(UARTLITE_BASEADDRESS);
    return 1;

  return 0;
}
コード例 #6
0
ファイル: serial.c プロジェクト: cuiyanzhe/ReFrESH
/* --- serRecvStr1()  Receive n chars from the UART Lite.
   --- If n == 0, get only available chars (don't block) 
   --- n cannot be larger than 255 */
unsigned char serRecvStr1(unsigned char *str, unsigned char n)
{
  unsigned char i;

  i = 0;
  if (n > 0){
    /* If n > 0, block for n chars */
    while(i < n){
        (str[i++]) = XUartLite_RecvByte(UARTLITE_BASEADDRESS);
    }
    return n;
  } else if (XUartLite_IsReceiveEmpty(UARTLITE_BASEADDRESS)){
  	return 0;
  } else {
    /* if n == 0, get as many as available now (non-blocking) */
      (str[i++]) = XUartLite_RecvByte(UARTLITE_BASEADDRESS);
    return i;
  }
}
コード例 #7
0
int main(void)
{
	uint32_t Index;
    uint32_t* gpio_ptr = (uint32_t *)XPAR_GPIO_0_BASEADDR;
    u32 uart_ptr = XPAR_UARTLITE_0_BASEADDR;
    command_t cmd;
    int cmd_args[4];
    char output_string[100];

	print("Type commands.\n\r");

	Index = 0;
	for(;;){
		char_temp = XUartLite_RecvByte(uart_ptr);  // this waits until there is a character available.
    	//*gpio_ptr = char_temp;  // write character to LED's.
		RecvBuffer[Index] = char_temp;
		if (Index==(TEST_BUFFER_SIZE-1)) Index = 0; else Index++;
		if (char_temp=='\r'){ // carriage return detected
			Index = 0;
			//process the command line.
			parse_command(RecvBuffer, &cmd, cmd_args);

			// for now, just print something to indicate that the command is parsed.
			if (cmd==reg_wr) {
				sprintf(output_string, "command = reg_wr, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
			} else if (cmd==reg_rd) {
				sprintf(output_string, "command = reg_rd, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
			} else if (cmd==spi_wr) {
				sprintf(output_string, "command = spi_wr, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
			} else if (cmd==spi_rd) {
				sprintf(output_string, "command = spi_rd, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
			} else if (cmd==led_wr) {
				sprintf(output_string, "command = led_wr, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
				*gpio_ptr = cmd_args[0];
			} else {
				sprintf(output_string, "command = nop, args = 0x%x 0x%x 0x%x 0x%x\n\r", cmd_args[0], cmd_args[1], cmd_args[2], cmd_args[3]);
			}
			print(output_string);
		}
	}

	return XST_SUCCESS;
}
コード例 #8
0
ファイル: handlers.c プロジェクト: Forvater/tangenta_project
////////////  напюанрвхйх опепшбюмхи  //////////////////////////////////////////
void handler_RS232(void *arg2) {
  if(!XUartLite_mIsReceiveEmpty(XPAR_UARTLITE_0_BASEADDR)) {
    sost_rs =  XUartLite_RecvByte(XPAR_UARTLITE_0_BASEADDR);
  }
}
コード例 #9
0
ファイル: uartlite.c プロジェクト: Pedersen175/DAN-uMon
/* target_getchar():
 * Assume there is a character in the UART's input buffer and just
 * pull it out and return it.
 */
int 
target_getchar(void)
{
	return((int)XUartLite_RecvByte(UART_BASE));
}
コード例 #10
0
ファイル: task2.c プロジェクト: PaintScratcher/uni_embs
char receive() {
    char recieved = XUartLite_RecvByte(XPAR_RS232_DTE_BASEADDR);
    xil_printf("%c", recieved);
    return recieved;
}
コード例 #11
0
int main()
{
    int Status;

    init_platform();

	xil_printf("NetFPGA-SUME ddr3B Acceptance Test\r\n");

	/*
	 * Setup Iic Instance
	 */
	Status = IicInit(&IicInstance);
	if (Status != XST_SUCCESS) {
		xil_printf("I2C Initialization FAILED\n\r");
		return XST_FAILURE;
	}

	/*
	 * Setup the Interrupt System.
	 */
	Status = SetupInterruptSystem(&IicInstance);
	if (Status != XST_SUCCESS) {
		xil_printf("SetupInterruptSystem FAILED\n\r");
		return XST_FAILURE;
	}

	/*
	 * Enable Iic Bus
	 */
	Status = IicInitPost(&IicInstance);
	if (Status != XST_SUCCESS) {
		xil_printf("I2C Initialization FAILED\n\r");
		return XST_FAILURE;
	}

	Status = ddr3Test_Init();
	if (Status != XST_SUCCESS) {
		xil_printf("I2C Initialization FAILED\n\r");
		return XST_FAILURE;
	}

	while(1) {
		xil_printf("============ NetFPGA-SUME ============\n\r");
		xil_printf("a: Auto Test \r\n");
		xil_printf("m: Manual Test \r\n");
		xil_printf("Select: ");
		char cmd = XUartLite_RecvByte(XPAR_AXI_UARTLITE_0_BASEADDR);
		xil_printf("%c\r\n", cmd);
		switch (cmd) {
			case 'a':
				runAutoTest();
				break;
			case 'm':
				runManualTest();
				break;
			default:
				break;
		}
		xil_printf("\r\n");
	}

    return 0;
}
コード例 #12
0
ファイル: inbyte.c プロジェクト: Abagnale/tlm
char inbyte(void) {
	 return XUartLite_RecvByte(STDIN_BASEADDRESS);
}
コード例 #13
0
ファイル: EEPROM_l.c プロジェクト: shailcoolboy/Warp-Trinity
char WarpEEPROM_ControlByteWrite(unsigned int* baseaddr, char ByteSelect, char value2store)
{   
   Xuint8 choice;
   if(ByteSelect < 5)
   {
      print("\r\nReturning\r\n");
      return; // Remove in order to enable writing to control bytes.
      print("\r\nSETTING THE PROTECTION REGISTERS TO WRITE PROTECT OR EPROM MODE IS\r\n");
      print("\r\n                    ***IRREVERSIBLE***\r\n");
      print("\r\nDo you wish to continue? (y)\r\n");
      choice = XUartLite_RecvByte(STDIN_BASEADDRESS);
      if(choice != 'y')
         return ABORT;
      
      print("\r\nPlease Verify the Control Byte you are Writing\r\n");
      print("      0: Protection Control Byte Page 0\r\n");      
      print("      1: Protection Control Byte Page 1\r\n");      
      print("      2: Protection Control Byte Page 2\r\n");      
      print("      3: Protection Control Byte Page 3\r\n");      
      print("      4: Copy Protection Byte\r\n");      
      print("      5: User Byte #1\r\n");      
      print("      6: User Byte #2\r\n");
      choice = XUartLite_RecvByte(STDIN_BASEADDRESS);   
      if((choice - 48) != ByteSelect)
         return ABORT;
         
      print("\r\nPlease Verify the value you are writing is %x.  (k)\r\n", value2store);
      choice = XUartLite_RecvByte(STDIN_BASEADDRESS);
      if(choice != 'k')
         return ABORT;
      
      print("\r\nSETTING THE PROTECTION REGISTERS TO 'WRITE PROTECT' OR 'EPROM MODE' IS\r\n");
      print("\r\n                    ***IRREVERSIBLE***\r\n");
      print("\r\nDo you wish to continue? (y)\r\n");
      choice = XUartLite_RecvByte(STDIN_BASEADDRESS);
      if(choice != 'y')
         return ABORT;
   }
   
   // Obtain Current Control Register Values
   Xuint8 control_regs[8], mem_address;
   WarpEEPROM_ReadControlBytes(baseaddr, control_regs); 
   mem_address = 0x80;
   switch(ByteSelect)
   {   
      case(0)  : 
      {
         control_regs[0] = value2store; break;
      }
      case(1)  : 
      {
         control_regs[1] = value2store; break;
      
      }
      case(2)  : 
      {
         control_regs[2] = value2store; break;
      
      }
      case(3)  : 
      {
         control_regs[3] = value2store; break;
      
      }
      case(4)  : 
      {
         control_regs[4] = value2store; break;
      
      }
      case(5)  : 
      {
         control_regs[6] = value2store; break;
      
      }
      case(6)  : 
      {
         control_regs[7] = value2store; break;
      
      }
      default : return; break;
   } 

      ////////////////////////////////////////////////////////////////////////////////////
      // Write Scratchpad
      Xuint8 CRC_n, check, verify[14];
      WarpEEPROM_Initialize(baseaddr);
      WarpEEPROM_WriteByte(baseaddr, 0xCC);     
      
      WarpEEPROM_WriteByte(baseaddr, 0x0F);             verify[0] = 0x0F;
      
      WarpEEPROM_WriteByte(baseaddr, mem_address);      verify[1] = mem_address;
      WarpEEPROM_WriteByte(baseaddr, 0x0);              verify[2] = 0x0;
      
      WarpEEPROM_WriteByte(baseaddr, control_regs[0]);  verify[3] = control_regs[0];
      WarpEEPROM_WriteByte(baseaddr, control_regs[1]);  verify[4] = control_regs[1];
      WarpEEPROM_WriteByte(baseaddr, control_regs[2]);  verify[5] = control_regs[2];
      WarpEEPROM_WriteByte(baseaddr, control_regs[3]);  verify[6] = control_regs[3];
      WarpEEPROM_WriteByte(baseaddr, control_regs[4]);  verify[7] = control_regs[4];
      WarpEEPROM_WriteByte(baseaddr, control_regs[5]);  verify[8] = control_regs[5];
      WarpEEPROM_WriteByte(baseaddr, control_regs[6]);  verify[9] = control_regs[6];
      WarpEEPROM_WriteByte(baseaddr, control_regs[7]); verify[10] = control_regs[7];
      
      CRC_n = WarpEEPROM_ReadByte(baseaddr); 
      verify[11] = ~CRC_n;
      CRC_n = WarpEEPROM_ReadByte(baseaddr); 
      verify[12] = ~CRC_n;
      
      check = WarpEEPROM_VerifyScratchpad(verify, 0);
      if(check != 0)
         return FAILURE;   
      
      ////////////////////////////////////////////////////////////////////////////////////
      // Read Scratchpad
      WarpEEPROM_Initialize(baseaddr);
      WarpEEPROM_WriteByte(baseaddr, 0xCC);     
      
      WarpEEPROM_WriteByte(baseaddr, 0xAA); verify[0] = 0xAA;
      
       verify[1] = WarpEEPROM_ReadByte(baseaddr);
       verify[2] = WarpEEPROM_ReadByte(baseaddr);
       verify[3] = WarpEEPROM_ReadByte(baseaddr); 
       
       verify[4] = WarpEEPROM_ReadByte(baseaddr);
       verify[5] = WarpEEPROM_ReadByte(baseaddr);
       verify[6] = WarpEEPROM_ReadByte(baseaddr);
       verify[7] = WarpEEPROM_ReadByte(baseaddr);
       verify[8] = WarpEEPROM_ReadByte(baseaddr);
       verify[9] = WarpEEPROM_ReadByte(baseaddr);
      verify[10] = WarpEEPROM_ReadByte(baseaddr);
      verify[11] = WarpEEPROM_ReadByte(baseaddr);
      
      CRC_n = WarpEEPROM_ReadByte(baseaddr); verify[12] = ~CRC_n;
      CRC_n = WarpEEPROM_ReadByte(baseaddr); verify[13] = ~CRC_n;
      
      check = WarpEEPROM_VerifyScratchpad(verify, 1);
      if(check != 0)
         return FAILURE;
      
      ////////////////////////////////////////////////////////////////////////////////////
      // Copy Scratchpad
      WarpEEPROM_Initialize(baseaddr);
      WarpEEPROM_WriteByte(baseaddr, 0xCC);     
      
      WarpEEPROM_WriteByte(baseaddr, 0x55);
      WarpEEPROM_WriteByte(baseaddr, verify[1]);
      WarpEEPROM_WriteByte(baseaddr, verify[2]);
      WarpEEPROM_WriteByte(baseaddr, verify[3]);
      usleep(12500);
      
      check = WarpEEPROM_ReadByte(baseaddr);
      if(check == 0xAA)
      {
         return SUCCESS;
      }
      else 
         return FAILURE;
}
コード例 #14
0
ファイル: lec18.c プロジェクト: jfalkinburg/ECE383_web
int main(void) {

    u8  c;

    while(1) {

    	c=XUartLite_RecvByte(uartReadReg);

    	switch(c) {

    		//-------------------------------------------------
    		// Reply with the help menu
    		//-------------------------------------------------
    		case '?':
    			xil_printf("--------------------------\r\n");
    			xil_printf("	count Q = %x\r\n",Xil_In16(countQReg));
    			xil_printf("--------------------------\r\n");
    			xil_printf("?: help menu\r\n");
    			xil_printf("o: k\r\n");
    			xil_printf("c: COUNTER	count up LEDs (by 9)\r\n");
    			xil_printf("l: COUNTER	load counter\r\n");
    			xil_printf("r: COUNTER	reset counter\r\n");
    			xil_printf("f: flush terminal\r\n");
    			break;

    		//-------------------------------------------------
    		// Basic I/O loopback
    		//-------------------------------------------------
    		case 'o':
    			xil_printf("k \r\n");
    			break;

    		//-------------------------------------------------
    		// Tell the counter to count up
    		//-------------------------------------------------
    		case 'c':
    			Xil_Out8(countCtrlReg,count_COUNT);
    			Xil_Out8(countCtrlReg,count_HOLD);
    			break;

        	//-------------------------------------------------
        	// Tell the counter to load a value
        	//-------------------------------------------------
        	case 'l':
        		xil_printf("Enter a 0-9 value to store in the counter: ");
            	c=XUartLite_RecvByte(uartReadReg) - 0x30;
        		Xil_Out8(countQReg,c);					// put value into slv_reg1
        		Xil_Out8(countCtrlReg,count_LOAD);				// load command
    			xil_printf("%c\r\n",c+0x30);
        		break;

            //-------------------------------------------------
            // Reset the counter
            //-------------------------------------------------
            case 'r':
            	Xil_Out8(countCtrlReg,count_RESET);				// reset command
            	break;

            //-------------------------------------------------
            // Clear the terminal window
            //-------------------------------------------------
            case 'f':
            	for (c=0; c<40; c++) xil_printf("\r\n");
               	break;

          //-------------------------------------------------
          // Unknown character was
          //-------------------------------------------------
    		default:
    			xil_printf("unrecognized character: %c\r\n",c);
    			break;
    	} // end case
    } // end while 1
    return 0;
} // end main
コード例 #15
0
ファイル: main.c プロジェクト: cbusho/Lab4_Busho
int main(void)
{
 while (1)
 {
	 unsigned char c, d, e;
	 c = 0x00;
	 d = 0x00;
	 e = 0x00;

	 while(c == 0x00){
		 c = XUartLite_RecvByte(0x84000000); //receive letter
	 }
	 XUartLite_SendByte(0x84000000, c);

	 while(d == 0x00){
		 d = XUartLite_RecvByte(0x84000000); //receive letter
	 }
	 XUartLite_SendByte(0x84000000, d);

	 while(e == 0x00){
		 e = XUartLite_RecvByte(0x84000000); //receive letter
	 }
	 XUartLite_SendByte(0x84000000, e);
	 XUartLite_SendByte(0x84000000, 0x20);	 //send space char

	 //led command
	 if((c == 0x6C) && (d == 0x65) && (e == 0x64)){
		 c = 0x00;
		 d = 0x00;
		 e = 0x00;

		 while(c == 0x00){
		 	 c = XUartLite_RecvByte(0x84000000) - 0x30; //receive letter
		 	 d = c - 0x27;
		 	 if((c >= 0x0) && (c <= 0x9)){
		 		 e = c;
		 	 }
		 	 else if((d >= 0xA) && (d <= 0xF)){
		 		 e = d;
		 	 }
		 	 else{
		 		 e = 0x0;
		 	 }
		 }
		 XUartLite_SendByte(0x84000000, c + 0x30);
		 e = e << 4;

		 c = 0x00;
		 d = 0x00;

		 while(c == 0x00){
			 c = XUartLite_RecvByte(0x84000000) - 0x30; //receive letter
			 d = c - 0x27;
			 if((c >= 0x0) && (c <= 0x9)){
				 e += c;
			 }
			 else if((d >= 0xA) && (d <= 0xF)){
				 e += d;
			 }
			 else{
				 e = e;
			 }
		 }
		 XUartLite_SendByte(0x84000000, c + 0x30);
		 Xil_Out8(0x83000000, e);

	 }

	 //switch command
	 if((c == 0x73) && (d == 0x77) && (e == 0x74)){
		 c = 0x00;
		 d = 0x00;
		 e = 0x00;

		 c = Xil_In8(0x83000004) & 0xF;
		 d = Xil_In8(0x83000004) & 0xF0;

		 d = d >> 4;

		 if(c <= 0x9){
			 c = c + 0x30;
		 }
		 else{
			 c = c + 0x57;
		 }

		 if(d <= 0x9){
			 d = d + 0x30;
		 }
		 else{
			 d = d + 0x57;
		 }

		 XUartLite_SendByte(0x84000000, d);
		 XUartLite_SendByte(0x84000000, c);

	 }

	 XUartLite_SendByte(0x84000000, 0xA);	 //send new line char
	 XUartLite_SendByte(0x84000000, 0xD);	 //send return char

 }
コード例 #16
0
ファイル: controller.c プロジェクト: jaximus/DPD_Design
int main(){
w3_node_init();

// Write some code here that gives a user instructions for controlling your transceiver.
// --- Enable/disable transmitter
// --- Enable/disable receiver
// --- Enable/disable/reset CFO Correction
// --- Enable/disable/reset timing correction
// --- Select output of DAC (to view signals at various stages in your design)
// --- Modify all filter coefficients (both for CFO and timing synchronization) for tuning


//Set up the UART
XUartLite_Initialize(&UartLite, XPAR_UARTLITE_0_DEVICE_ID);

//Set up the Radio - For details about these calls, see http://warp.rice.edu/svn/WARP/PlatformSupport/CustomPeripherals/pcores/radio_controller_v3_00_b/doc/html/api/index.html

// Configure TX enable, RX enable, and Rx HP filter for software control
radio_controller_setCtrlSource(RC_BASEADDR, RC_RFA, (RC_REG0_TXEN_CTRLSRC|RC_REG0_RXEN_CTRLSRC|RC_REG0_RXHP_CTRLSRC), RC_CTRLSRC_REG);

// Configure TX  low-pass filter response to have a corner frequency of 18 MHz:
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA, RC_PARAMID_TXLPF_BW, 0x01);

//Enable software Tx Gain control:
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA,RC_PARAMID_TXGAINS_SPI_CTRL_EN, 0x01);

//Enable software Rx Gain control:
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA,RC_PARAMID_RXGAINS_SPI_CTRL_EN, 0x01);

//Initialize the baseband Tx gain to its max value (0 dB)
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA,RC_PARAMID_TXGAIN_BB, 0x00);

//Initialize the RF Tx gain
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA, RC_PARAMID_TXGAIN_RF, TxGain);

// Configure receive HPF cutoff of 30kHz (DC block)
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA, RC_PARAMID_RXHPF_HIGH_CUTOFF_EN, 0x01);

//14MHz Low Pass Filter on RX (our max freq is 10MHz + 2.25MHz)
// 0: 7.5MHz<br>1: 9.5MHz<br>2: 14MHz<br>3: 18MHz
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA, RC_PARAMID_RXLPF_BW, 0x03);

//Initialize the Rx RF Gain (1:0dB, 2:15dB , 3:30dB )
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA,RC_PARAMID_RXGAIN_RF, RxCoarseGain);

//Initialize the Rx baseband Gain
radio_controller_setRadioParam(RC_BASEADDR, RC_RFA, RC_PARAMID_RXGAIN_BB, RxFineGain);

// Enable the receiver by default

// Set center frequency (i.e. choose the WiFi channel)
radio_controller_setCenterFrequency(RC_BASEADDR , RC_RFA, RC_24GHZ, wifiChannel);


//DECLERATION OF VARIABLES
int x = 0;											//Variable used for reading UART
Xuint32 dataIn;										//Variable used to temporarily store data read from memory using the XIO_In32() function
Xuint32 dataOut;									//Variable used to temporarily store data to write to memory using the XIO_Out32() function

XIo_Out32(Delay,43);								//Write the desired value for the PA delay

radio_controller_RxEnable(RC_BASEADDR, RC_RFB);		//Turn on Receiver RFB
radio_controller_TxEnable(RC_BASEADDR, RC_RFA);		//Turn on Transmitter RFA


dataIn = XIo_In32(Delay);							//Read in first delay for sanity check
xil_printf("first delay: %d  \n \r", dataIn);		//Print to terminal for user to look at

XIo_Out32(Controls,0x80000000);						//Turn On LTE signal

while(1){
	x = XUartLite_RecvByte(STDIN_BASEADDRESS);	//Input from UART
	
	////TURN TRAINING ON////
	if(x=='t'){									
		XIo_Out32(Controls,0x04000000); 		//Turn Off Signal, DPD, learning, and reset
		XIo_Out32(Controls,0xF0000000);			//Turn On LTE, DPD, and Training
		xil_printf("Training Activated \n \r");
	}
	
	////COMMANDS TO LOOK AT AND CHANGE DELAY////
	if(x=='d'){									//Read current delay
		dataIn = XIo_In32(Delay);
		xil_printf("Current Delay: %d  \n \r", dataIn);
		}
	if(x=='e'){															//Increase delay
		radio_controller_TxRxDisable(RC_BASEADDR, RC_RFA|RC_RFB);		//Turn off TX and RX RFB
		XIo_Out32(Controls,0x04000000);									//Turn Off LTE, DPD, Training, and Reset
		dataIn = XIo_In32(Delay);										//Read current delay
		dataOut = dataIn + 1;											//step by 1
		XIo_Out32(Delay,dataOut);										//Write to delay
		dataIn = XIo_In32(Delay);										//Read current delay
		xil_printf("New Delay: %d  \n \r", dataIn);
		radio_controller_RxEnable(RC_BASEADDR, RC_RFB);					//Turn on Receiver RFB
		radio_controller_TxEnable(RC_BASEADDR, RC_RFA);					//Turn on Transmitter RFA
		XIo_Out32(Controls,0xF0000000);									//Turn On LTE, DPD, and Training
		}
	if(x=='c'){															//Decrease delay
		radio_controller_TxRxDisable(RC_BASEADDR, RC_RFA|RC_RFB);		//Turn off TX and RX RFB
		XIo_Out32(Controls,0x04000000);									//Turn Off LTE, DPD, Training, and Reset
		dataIn = XIo_In32(Delay);										//Read current delay
		dataOut = dataIn - 1;											//step by 1
		XIo_Out32(Delay,dataOut);										//Write to delay
		dataIn = XIo_In32(Delay);										//Read current delay
		xil_printf("New Delay: %d  \n \r", dataIn);
		radio_controller_RxEnable(RC_BASEADDR, RC_RFB);					//Turn on Receiver RFB
		radio_controller_TxEnable(RC_BASEADDR, RC_RFA);					//Turn on Transmitter RFA
		XIo_Out32(Controls,0xF0000000);									//Turn On LTE, DPD, and Training
		}

	////REPORT ALL ALPHAS FROM TRAINING////
	if(x=='l'){
		int i = 0;
		for(i = 0;i<Alpha_depth;i=i+4 ){
			dataIn = XIo_In32(Alpha_memory+i);				//Read alpha
			xil_printf("%08x, address: %08x  \n \r", dataIn, Alpha_memory+i);
			}
		}

	////COMMANDS FOR CHANGING ALPHA MANUALLY///
	if(x=='a'){								//Switch to Manual Alpha
		XIo_Out32(Controls,0x04000000); 	//Turn Off Signal, DPD, learning, and reset
		XIo_Out32(Controls,0xC8000000);		//Turn On LTE, DPD, and manual alpha
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		xil_printf("Current Alpha: %08x  \n \r", dataIn);
	}
	if(x=='q'){								//Increase Manual Alpha Real
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		dataOut = dataIn + 0x01000000;		//step by 2^-6 = 0.015625
		XIo_Out32(Alpha_user,dataOut);		//Write to user defined alpha
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		xil_printf("New Alpha: %08x  \n \r", dataIn);
	}
	if(x=='z'){								//Decrease Manual Alpha Real
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		dataOut = dataIn - 0x01000000;		//step by -2^-6 = -0.015625
		XIo_Out32(Alpha_user,dataOut);		//Write to user defined alpha
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		xil_printf("New Alpha: %08x  \n \r", dataIn);
	}
	if(x=='w'){								//Increase Manual Alpha Imag
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		dataOut = dataIn + 0x00000100;		//step by 2^-6 = 0.015625
		XIo_Out32(Alpha_user,dataOut);		//Write to user defined alpha
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		xil_printf("New Alpha: %08x  \n \r", dataIn);
	}
	if(x=='x'){								//Decrease Manual Alpha Imag
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		dataOut = dataIn - 0x00000100;		//step by -2^-6 = -0.015625
		XIo_Out32(Alpha_user,dataOut);		//Write to user defined alpha
		dataIn = XIo_In32(Alpha_user);		//Read current user defined alpha
		xil_printf("New Alpha: %08x  \n \r", dataIn);
	}
}
}