示例#1
0
void JtagInitGpio ()
{
	js_printf("===== Initializing PS GPIO pins...\n\r");
	XGpioPs_Config *ptrConfigPtrPs = XGpioPs_LookupConfig(0);
	XGpioPs_CfgInitialize(&structXGpioPs,ptrConfigPtrPs,ptrConfigPtrPs->BaseAddr);

	/* Unlock the SLCR block */
	Xil_Out32 (0xF8000000 + 0x8, 0xDF0D);

	GpioConfig((GPIO_BASE_ADDR+(g_mio_jtag_tdi*4)),GPIO_MASK_VAL, GPIO_TDI_VAL);
    GpioConfig((GPIO_BASE_ADDR+(g_mio_jtag_tdo*4)),GPIO_MASK_VAL, GPIO_TDO_VAL);
    GpioConfig((GPIO_BASE_ADDR+(g_mio_jtag_tck*4)),GPIO_MASK_VAL, GPIO_TCK_VAL);
    GpioConfig((GPIO_BASE_ADDR+(g_mio_jtag_tms*4)),GPIO_MASK_VAL, GPIO_TMS_VAL);
    GpioConfig((GPIO_BASE_ADDR+(g_mio_jtag_mux_sel*4)),GPIO_MASK_VAL, GPIO_MUX_SEL_VAL);

	XGpioPs_SetDirectionPin(&structXGpioPs,MIO_TCK,1);
	XGpioPs_SetOutputEnablePin(&structXGpioPs,MIO_TCK,1);

	XGpioPs_SetDirectionPin(&structXGpioPs,MIO_TMS,1);
	XGpioPs_SetOutputEnablePin(&structXGpioPs,MIO_TMS,1);

	XGpioPs_SetDirectionPin(&structXGpioPs,MIO_TDI,1);
	XGpioPs_SetOutputEnablePin(&structXGpioPs,MIO_TDI,1);

	XGpioPs_SetDirectionPin(&structXGpioPs,MIO_MUX_SELECT,1);
	XGpioPs_SetOutputEnablePin(&structXGpioPs,MIO_MUX_SELECT,1);
	XGpioPs_WritePin(&structXGpioPs, MIO_MUX_SELECT, g_mux_sel_def_val);
	
	XGpioPs_SetDirectionPin(&structXGpioPs,MIO_TDO,0);
	XGpioPs_SetOutputEnablePin(&structXGpioPs,MIO_TDO,0);
} /* initGpio() */
int main()
{
	XGpioPs_Config *GPIOConfigPtr;      //gpio config
	//int io;



	init_platform();

	//GPIO Initilization
	GPIOConfigPtr = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
	XGpioPs_CfgInitialize(&Gpio, GPIOConfigPtr,GPIOConfigPtr->BaseAddr);
	//set direction and enable output

	XGpioPs_SetDirectionPin(&Gpio, intpin, 1);
	XGpioPs_SetOutputEnablePin(&Gpio, intpin, 1);
	XGpioPs_WritePin(&Gpio, intpin, 0);

    //set direction input pin
    XGpioPs_SetDirectionPin(&Gpio, pbsw, 0);

    SetupInterruptSystem(&Intc,&FPGA,FPGA_INT,&Gpio, GPIO_INTERRUPT_ID);

    printf("system running\n\r");
while(1){
}

    return 0;

}
示例#3
0
/***************************************************************************//**
 * @brief gpio_direction
*******************************************************************************/
int32_t gpio_direction(uint8_t pin, uint8_t direction)
{
#ifdef _XPARAMETERS_PS_H_
	XGpioPs_SetDirectionPin(&gpio_instance, pin, direction);
	XGpioPs_SetOutputEnablePin(&gpio_instance, pin, 1);
#else
	uint32_t channel = 1;
	uint32_t config	 = 0;

	/* We assume that pin 32 is the first pin from channel 2 */
	if (pin >= 32) {
		channel = 2;
		pin -= 32;
	}

	config = XGpio_GetDataDirection(&gpio_instance, channel);
	if (direction) {
		config &= ~(1 << pin);
	} else {
		config |= (1 << pin);
	}
	XGpio_SetDataDirection(&gpio_instance, channel, config);
#endif

	return 0;
}
示例#4
0
/***************************************************************************//**
 * @brief gpio_direction
*******************************************************************************/
void gpio_direction(uint8_t pin, uint8_t direction)
{
#ifdef _XPARAMETERS_PS_H_
	XGpioPs_SetDirectionPin(&gpio_instance, pin, direction);
	XGpioPs_SetOutputEnablePin(&gpio_instance, pin, 1);
#endif
}
/*-----------------------------------------------------------*/
void prvSetGpioHardware( void )
{
 	int Status;
 	/*
 	 * Initialize the GPIO driver.
 	 */
 	ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);
 	Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,
 					ConfigPtr->BaseAddr);
 	if (Status != XST_SUCCESS) {
 		xil_printf("GPIO Initialize failed\n");
 	}

 	/*
 	 * Set the direction for the pin to be output and
 	 * Enable the Output enable for the LED Pin.
 	 */
 	XGpioPs_SetDirectionPin(&Gpio, OUTPUT_PIN, 1);
 	XGpioPs_SetOutputEnablePin(&Gpio, OUTPUT_PIN, 1);

 	/*
 	 * Set the GPIO output to be low.
 	 */
 	XGpioPs_WritePin(&Gpio, OUTPUT_PIN, 0x0);
}
示例#6
0
/***************************************************************************//**
 * @brief gpio_direction
*******************************************************************************/
void gpio_direction(uint8_t pin, uint8_t direction)
{
#ifdef _XPARAMETERS_PS_H_
	XGpioPs_SetDirectionPin(&gpio_instance, pin, direction);
	XGpioPs_SetOutputEnablePin(&gpio_instance, pin, 1);
#else
	uint32_t config = 0;
	uint32_t tri_reg_addr;

	if (pin >= 32) {
		tri_reg_addr = XGPIO_TRI2_OFFSET;
		pin -= 32;
	} else
		tri_reg_addr = XGPIO_TRI_OFFSET;

	config = Xil_In32((gpio_config->BaseAddress + tri_reg_addr));
	if(direction)
	{
		config &= ~(1 << pin);
	}
	else
	{
		config |= (1 << pin);
	}
	Xil_Out32((gpio_config->BaseAddress + tri_reg_addr), config);
#endif
}
示例#7
0
/*****************************************************************************
*
* This function sets GPIO LED device state configured as OUTPUT.
*
* @param	None.
*
* @return	0 if successful, else -1.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_set_led(zed_ali3_controller_demo_t *pDemo, int led_number, int led_state)
{
    /*
     * Set the direction for the GPIO pin to be output and
     * Enable the Output enable for the LED Pin.
     */
#ifdef PS_GPIO_USER_LED0
    if (led_number == 0)
    {
        XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), PS_GPIO_USER_LED0, 1);
        XGpioPs_SetOutputEnablePin(&(pDemo->gpio_driver), PS_GPIO_USER_LED0, 1);
    }
#ifdef PS_GPIO_USER_LED1
    else if (led_number == 1)
    {
    	XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), PS_GPIO_USER_LED1, 1);
        XGpioPs_SetOutputEnablePin(&(pDemo->gpio_driver), PS_GPIO_USER_LED1, 1);
    }
#endif
#else
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), 1);
    XGpioPs_SetOutputEnablePin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), 1);
#endif

    /*
     * Set the GPIO output to the specified state.
     */
#ifdef PS_GPIO_USER_LED0
    if (led_number == 0)
    {
        XGpioPs_WritePin(&(pDemo->gpio_driver), PS_GPIO_USER_LED0, led_state);
    }
#ifdef PS_GPIO_USER_LED1
    else if (led_number == 1)
    {
    	XGpioPs_WritePin(&(pDemo->gpio_driver), PS_GPIO_USER_LED1, led_state);
    }
#endif
#else
    XGpioPs_WritePin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), led_state);
#endif

    return 0;
}
示例#8
0
/*****************************************************************************
*
* This function gets a GPIO button device state configured as INPUT.
*
* @param	None.
*
* @return	1 if depressed, else 0.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_get_button(zed_ali3_controller_demo_t *pDemo, int button_number)
{
    int button_state;

    /*
     * Set the direction for the specified pin to be input.
     */
#ifdef PS_GPIO_USER_BUTTON0
    if (button_number == 0)
    {
    	XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), PS_GPIO_USER_BUTTON0, 0);
    }
#ifdef PS_GPIO_USER_BUTTON1
    else if (button_number == 1)
    {
    	XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), PS_GPIO_USER_BUTTON1, 0);
    }
#endif
#else
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), (PS_GPIO_USER_BUTTON_START + button_number), 0);
#endif

    /*
     * Read the state of the data so that it can be  verified.
     */
#ifdef PS_GPIO_USER_BUTTON0
    if (button_number == 0)
    {
    	button_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), PS_GPIO_USER_BUTTON0);
    }
#ifdef PS_GPIO_USER_BUTTON1
    else if (button_number == 1)
    {
    	button_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), PS_GPIO_USER_BUTTON1);
    }
#endif
#else
    button_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), (PS_GPIO_USER_BUTTON_START + button_number));
#endif

    return button_state;
}
示例#9
0
/**
 * @brief Enable the output direction of the specified GPIO.
 * @param desc - The GPIO descriptor.
 * @param value - The value.
 *                Example: GPIO_HIGH
 *                         GPIO_LOW
 * @return SUCCESS in case of success, FAILURE otherwise.
 */
int32_t gpio_direction_output(struct gpio_desc *desc,
			      uint8_t value)
{
	XGpioPs_SetDirectionPin(&desc->instance, desc->number, 1);

	XGpioPs_SetOutputEnablePin(&desc->instance, desc->number, 1);

	XGpioPs_WritePin(&desc->instance, desc->number, value);

	return SUCCESS;
}
示例#10
0
/**
*
* This function performs a test on the GPIO driver/device with the GPIO
* configured as INPUT.
*
* @param	DataRead is the pointer where the data read from GPIO Input is
*		returned
*
* @return	- XST_SUCCESS if the example has completed successfully.
*		- XST_FAILURE if the example has failed.
*
* @note		None.
*
******************************************************************************/
static int GpioInputExample(u32 *DataRead)
{

	/*
	 * Set the direction for the specified pin to be input.
	 */
	XGpioPs_SetDirectionPin(&Gpio, INPUT_PIN, 0x0);

	/*
	 * Read the state of the data so that it can be  verified.
	 */
	*DataRead = XGpioPs_ReadPin(&Gpio, INPUT_PIN);

	return XST_SUCCESS;
}
示例#11
0
void vParTestInitialise( void )
{
XGpioPs_Config *pxConfigPtr;
BaseType_t xStatus;

	/* Initialise the GPIO driver. */
	pxConfigPtr = XGpioPs_LookupConfig( XPAR_XGPIOPS_0_DEVICE_ID );
	xStatus = XGpioPs_CfgInitialize( &xGpio, pxConfigPtr, pxConfigPtr->BaseAddr );
	configASSERT( xStatus == XST_SUCCESS );
	( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */

	/* Enable outputs and set low. */
	XGpioPs_SetDirectionPin( &xGpio, partstLED_OUTPUT, partstDIRECTION_OUTPUT );
	XGpioPs_SetOutputEnablePin( &xGpio, partstLED_OUTPUT, partstOUTPUT_ENABLED );
	XGpioPs_WritePin( &xGpio, partstLED_OUTPUT, 0x0 );
}
示例#12
0
/*****************************************************************************
*
* This function sets GPIO LED device state configured as OUTPUT.
*
* @param	None.
*
* @return	0 if successful, else -1.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_set_led(zed_ali3_controller_demo_t *pDemo, int led_number, int led_state)
{
    /*
     * Set the direction for the GPIO pin to be output and
     * Enable the Output enable for the LED Pin.
     */
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), 1);
    XGpioPs_SetOutputEnablePin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), 1);

    /*
     * Set the GPIO output to the specified state.
     */
    XGpioPs_WritePin(&(pDemo->gpio_driver), (PS_GPIO_USER_LED_START + led_number), led_state);

    return 0;
}
示例#13
0
/*****************************************************************************
*
* This function gets a GPIO button device state configured as INPUT.
*
* @param	None.
*
* @return	1 if depressed, else 0.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_get_button(zed_ali3_controller_demo_t *pDemo, int button_number)
{
    int button_state;

    /*
     * Set the direction for the specified pin to be input.
     */
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), (PS_GPIO_USER_BUTTON_START + button_number), 0);

    /*
     * Read the state of the data so that it can be  verified.
     */
    button_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), (PS_GPIO_USER_BUTTON_START + button_number));

    return button_state;
}
示例#14
0
/*****************************************************************************
*
* This function gets a GPIO switch device state configured as INPUT.
*
* @param	None.
*
* @return	1 if set to ON postion, else 0.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_get_switch(zed_ali3_controller_demo_t *pDemo, int switch_number)
{
    int switch_state;

    /*
     * Set the direction for the specified pin to be input.
     */
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), (PS_GPIO_USER_SWITCH_START + switch_number), 0);

    /*
     * Read the state of the data so that it can be  verified.
     */
    switch_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), (PS_GPIO_USER_SWITCH_START + switch_number));

    return switch_state;
}
示例#15
0
/*****************************************************************************
*
* This function gets a GPIO MIO state configured as INPUT.
*
* @param	None.
*
* @return	1 if depressed, else 0.
*
* @note		None.
*
****************************************************************************/
int ps_gpio_get_mio_state(zed_ali3_controller_demo_t *pDemo, int mio_number)
{
    int mio_state;

    /*
     * Set the direction for the specified pin to be input.
     */
    XGpioPs_SetDirectionPin(&(pDemo->gpio_driver), mio_number, 0);

    /*
     * Read the state of the data so that it can be  verified.
     */
    mio_state = XGpioPs_ReadPin(&(pDemo->gpio_driver), mio_number);

    return mio_state;
}
void vApplicationSetupHardware( void )
{
	XScuGic * InterruptController = prvGetInterruptControllerInstance();
	int iPinNumberEMIO = 54;
	u32 uPinDirectionEMIO = 0x0;
	u32 uPinDirection = 0x1;
	print("##### Application Starts #####\n\r");
	print("\r\n");
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-1 :AXI GPIO Initialization
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	u32 xStatus = XGpio_Initialize(&GPIOInstance_Ptr,XPAR_AXI_GPIO_0_DEVICE_ID);
	if(XST_SUCCESS != xStatus)
		print("GPIO INIT FAILED\n\r");
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-2 :AXI GPIO Set the Direction
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XGpio_SetDataDirection(&GPIOInstance_Ptr, 1,1);
	//set up GPIO interrupt
	XGpio_InterruptEnable(&GPIOInstance_Ptr, 0x1);
	XGpio_InterruptGlobalEnable(&GPIOInstance_Ptr);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-3 :AXI Timer Initialization
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	xStatus = XTmrCtr_Initialize(&TimerInstancePtr, XPAR_AXI_TIMER_0_DEVICE_ID);
	if(XST_SUCCESS != xStatus)
		print("TIMER INIT FAILED \n\r");
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-4 :Set Timer Handler
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XTmrCtr_SetHandler(&TimerInstancePtr, Timer_InterruptHandler, &TimerInstancePtr);
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-5 :Setting timer Reset Value
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XTmrCtr_SetResetValue(&TimerInstancePtr, 0, 0x0F000000);
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-6 :Setting timer Option (Interrupt Mode And Auto Reload )
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XTmrCtr_SetOptions(&TimerInstancePtr, XPAR_AXI_TIMER_0_DEVICE_ID, (XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION));
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-7 :PS GPIO Intialization
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	GpioConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
	if(GpioConfigPtr == NULL)
		print(" PS GPIO config lookup FAILED \n\r");
	xStatus = XGpioPs_CfgInitialize(&psGpioInstancePtr, GpioConfigPtr, GpioConfigPtr->BaseAddr);
	if(XST_SUCCESS != xStatus)
		print(" PS GPIO INIT FAILED \n\r");
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-8 :PS GPIO pin setting to Output
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XGpioPs_SetDirectionPin(&psGpioInstancePtr, 54, uPinDirection);
	XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, 54,1);
//	XGpioPs_SetDirectionPin(&psGpioInstancePtr, 8,uPinDirection);
//	XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, 8, 1);
	print(" INITED MIO \n\r");
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-9 :EMIO PIN Setting to Input port
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	XGpioPs_SetDirectionPin(&psGpioInstancePtr,	iPinNumberEMIO, uPinDirectionEMIO);
	XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberEMIO, 0);
	//XGpioPs_IntrEnable(&psGpioInstancePtr, XGPIOPS_BANK2, 0x1);
	// instance, bank, edge, rising, single edge
	XGpioPs_IntrEnablePin(&psGpioInstancePtr, iPinNumberEMIO);
	XGpioPs_SetIntrType(&psGpioInstancePtr, XGPIOPS_BANK2, 1, 1, 0);
	XGpioPs_SetCallbackHandler(&psGpioInstancePtr, (void *) &psGpioInstancePtr, EMIO_Button_InterruptHandler);

	print(" INITED FIRST EMIO \n\r");
	// EMIO output
	XGpioPs_SetDirectionPin(&psGpioInstancePtr, 55, uPinDirection);
	XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, 55, 1);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//Step-10 : SCUGIC interrupt controller Initialization
	//Registration of the Timer ISR
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	u32 Status = XScuGic_Connect(InterruptController,
							 XPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR,
							 (Xil_ExceptionHandler)XTmrCtr_InterruptHandler,
							 (void *)&TimerInstancePtr);

	if (Status != XST_SUCCESS) {
		print(" Error connection timer interrupt \n \r");
	}

	Status = XScuGic_Connect(InterruptController,
							XPAR_FABRIC_AXI_GPIO_0_IP2INTC_IRPT_INTR,
							 (Xil_ExceptionHandler)Button_InterruptHandler,
							 (void *)&GPIOInstance_Ptr);
	if (Status != XST_SUCCESS) {
		print(" Error connection button interrupt \n \r");
	}

	/*
	 * Connect the device driver handler that will be called when an
	 * interrupt for the device occurs, the handler defined above performs
	 * the specific interrupt processing for the device.
	 */
	Status = XScuGic_Connect(InterruptController,
							XPS_GPIO_INT_ID,
							(Xil_ExceptionHandler)XGpioPs_IntrHandler,
							(void *)&psGpioInstancePtr);
	if (Status != XST_SUCCESS) {
		print(" Error connection button EMIO interrupt \n \r");
	}

	/*
	* Enable the interrupt for the device and then cause (simulate) an
	* interrupt so the handlers will be called
	*/
	XScuGic_Enable(InterruptController, XPAR_FABRIC_AXI_GPIO_0_IP2INTC_IRPT_INTR);
	XScuGic_Enable(InterruptController, XPS_GPIO_INT_ID);
	XScuGic_Enable(InterruptController, XPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR);

	// turn off all LEDs
	XGpioPs_WritePin(&psGpioInstancePtr, iPinNumber, 0);
	XGpioPs_WritePin(&psGpioInstancePtr, 55, 0);

	print(" End of init \n\r");
}
示例#17
0
int main (void) 
{

      XGpio sw, led;
	  int i, pshb_check, sw_check;
	  XGpioPs_Config*GpioConfigPtr;
	  int xStatus;
	  int iPinNumberEMIO = 54;
	  u32 uPinDirectionEMIO = 0x0;
	  u32 uPinDirection = 0x1;
	
	  xil_printf("-- Start of the Program --\r\n");

	  // AXI GPIO switches Intialization
	  XGpio_Initialize(&sw, XPAR_SWITCHES_DEVICE_ID);

	  // AXI GPIO leds Intialization
	  XGpio_Initialize(&led, XPAR_LEDS_DEVICE_ID);

	  // PS GPIO Intialization
	  GpioConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
	  if(GpioConfigPtr == NULL)
	    return XST_FAILURE;
	  xStatus = XGpioPs_CfgInitialize(&psGpioInstancePtr,
	      GpioConfigPtr,
	      GpioConfigPtr->BaseAddr);
	  if(XST_SUCCESS != xStatus)
	    print(" PS GPIO INIT FAILED \n\r");
	  //PS GPIO pin setting to Output
	  XGpioPs_SetDirectionPin(&psGpioInstancePtr, iPinNumber,uPinDirection);
	  XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumber,1);
	  //EMIO PIN Setting to Input port
	  XGpioPs_SetDirectionPin(&psGpioInstancePtr,
	      iPinNumberEMIO,uPinDirectionEMIO);
	  XGpioPs_SetOutputEnablePin(&psGpioInstancePtr, iPinNumberEMIO,0);

	  xil_printf("-- Press BTNR (Zedboard) or BTN3 (Zybo) to see the LED light --\r\n");
	  xil_printf("-- Change slide switches to see corresponding output on LEDs --\r\n");
	  xil_printf("-- Set slide switches to 0x0F to exit the program --\r\n");

	  while (1)
	  {
		  sw_check = XGpio_DiscreteRead(&sw, 1);
		  XGpio_DiscreteWrite(&led, 1, sw_check);
	      pshb_check = XGpioPs_ReadPin(&psGpioInstancePtr,iPinNumberEMIO);
          XGpioPs_WritePin(&psGpioInstancePtr,iPinNumber,pshb_check);
          if((sw_check & 0x0f)==0x0F)
        	  break;
		  for (i=0; i<9999999; i++); // delay loop
	   }
	  xil_printf("-- End of Program --\r\n");
#ifdef MULTIBOOT
	  // Driver Instantiations
	  XDcfg XDcfg_0;
	  u32 MultiBootReg = 0;
	  #define PS_RST_CTRL_REG	(XPS_SYS_CTRL_BASEADDR + 0x200)
	  #define PS_RST_MASK	0x1	/* PS software reset */
	  #define SLCR_UNLOCK_OFFSET 0x08

	  // Initialize Device Configuration Interface
	  XDcfg_Config *Config = XDcfg_LookupConfig(XPAR_XDCFG_0_DEVICE_ID);
	  XDcfg_CfgInitialize(&XDcfg_0, Config, Config->BaseAddr);

	  MultiBootReg = 0; // Once done, boot the master image stored at 0xfc00_0000
	  Xil_Out32(0xF8000000 + SLCR_UNLOCK_OFFSET, 0xDF0DDF0D); // unlock SLCR
	  XDcfg_WriteReg(XDcfg_0.Config.BaseAddr, XDCFG_MULTIBOOT_ADDR_OFFSET, MultiBootReg); // write to multiboot reg
	  // synchronize
		__asm__(
			"dsb\n\t"
			"isb"
		);
      Xil_Out32(PS_RST_CTRL_REG, PS_RST_MASK);
#endif
	  return 0;
}
示例#18
0
//////////////////////////// MAIN //////////////////// MAIN //////////////
int main()
{
	// Local Variables for main()
	int i = 0;				// index
	int	menusel = 99999;	// Menu Select
	int mode = 9;			// Mode of Operation
	int enable_state = 0; 	// 0: disabled, 1: enabled
	int thres = 0;			// Trigger Threshold
	char updateint = 'N';	// switch to change integral values
	u32 databuff = 0;		// size of the data buffer

	// Initialize System
    init_platform();  		// This initializes the platform, which is ...
	ps7_post_config();
	Xil_DCacheDisable();	//
	InitializeAXIDma();		// Initialize the AXI DMA Transfer Interface
	Xil_Out32 (XPAR_AXI_GPIO_16_BASEADDR, 16384);
	Xil_Out32 (XPAR_AXI_GPIO_17_BASEADDR , 1);
	InitializeInterruptSystem(XPAR_PS7_SCUGIC_0_DEVICE_ID);

	for (i=0; i<32; i++ ) { RecvBuffer[i] = '_'; }		// Clear RecvBuffer Variable
	for (i=0; i<32; i++ ) { SendBuffer[i] = '_'; }		// Clear SendBuffer Variable

	//*******************Setup the UART **********************//
	XUartPs_Config *Config = XUartPs_LookupConfig(UART_DEVICEID);
	if (NULL == Config) { return 1;}
	Status = XUartPs_CfgInitialize(&Uart_PS, Config, Config->BaseAddress);
	if (Status != 0){ return 1;	}

	/* Conduct a Selftest for the UART */
	Status = XUartPs_SelfTest(&Uart_PS);
	if (Status != 0) { return 1; }

	/* Set to normal mode. */
	XUartPs_SetOperMode(&Uart_PS, XUARTPS_OPER_MODE_NORMAL);
	//*******************Setup the UART **********************//

	//*******************Receive and Process Packets **********************//
	Xil_Out32 (XPAR_AXI_GPIO_0_BASEADDR, 11);
	Xil_Out32 (XPAR_AXI_GPIO_1_BASEADDR, 71);
	Xil_Out32 (XPAR_AXI_GPIO_2_BASEADDR, 167);
	Xil_Out32 (XPAR_AXI_GPIO_3_BASEADDR, 2015);
	Xil_Out32 (XPAR_AXI_GPIO_4_BASEADDR, 12);
	Xil_Out32 (XPAR_AXI_GPIO_5_BASEADDR, 75);
	Xil_Out32 (XPAR_AXI_GPIO_6_BASEADDR, 75);
	Xil_Out32 (XPAR_AXI_GPIO_7_BASEADDR, 5);
	Xil_Out32 (XPAR_AXI_GPIO_8_BASEADDR, 25);
	//*******************Receive and Process Packets **********************//

	//******************Setup Detector and Module Objects*****************//
	//LDetector *Detector = LDetector();
	//Detector->SetMode(1); // Processed Data Mode
	//******************Setup Detector and Module Objects*****************//


	// *********** Setup the Hardware Reset GPIO ****************//
	GPIOConfigPtr = XGpioPs_LookupConfig(XPAR_PS7_GPIO_0_DEVICE_ID);
	Status = XGpioPs_CfgInitialize(&Gpio, GPIOConfigPtr, GPIOConfigPtr ->BaseAddr);
	if (Status != XST_SUCCESS) { return XST_FAILURE; }
	XGpioPs_SetDirectionPin(&Gpio, SW_BREAK_GPIO, 1);
	// *********** Setup the Hardware Reset MIO ****************//

	// ******************* POLLING LOOP *******************//
	xil_printf("\n\r Turn on Local Echo: under Terminal-Setup in Tera Term \n\r");
	xil_printf(" Code is expecting a 'Return' after Each Command \n\r");
	while(1){
		sw = 0;   //  stop switch reset to 0
		XUartPs_SetOptions(&Uart_PS,XUARTPS_OPTION_RESET_RX);	// Clear UART Read Buffer
		for (i=0; i<32; i++ ) { RecvBuffer[i] = '_'; }			// Clear RecvBuffer Variable

		sleep(0.5);  // Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 0.5 s
		xil_printf("\n\r MAIN MENU \n\r");
		xil_printf("******************************\n\r");
		xil_printf(" 0) Set Mode of Operation\n\r");
		xil_printf(" 1) Enable or disable the system\n\r");
		xil_printf(" 2) Continuously Read of Processed Data\n\r");
		xil_printf("\n\r **Setup Parameters ** \n\r");
		xil_printf(" 3) Set Trigger Threshold\n\r");
		xil_printf(" 4) Set Integration Times (number of clock cycles * 4ns) \n\r");
		xil_printf("\n\r ** Additional Commands ** \n\r");
		xil_printf(" 5) Perform a DMA transfer of Waveform Data\n\r");
		xil_printf(" 6) Perform a DMA transfer of Processed Data\n\r");
		xil_printf(" 7) Check the Size of the Data Buffered (Max = 4095) \n\r");
		xil_printf(" 8) Clear the Processed Data Buffers\n\r");
		xil_printf(" 9) Execute Print of Data on DRAM \n\r");
		xil_printf("******************************\n\n\r");
		while (XUartPs_IsSending(&Uart_PS)) {i++;}  // Wait until Write Buffer is Sent

		// Wait for Input, Check
		// If input is valid break while and enter case statement
		// If input is invalid break and try again
		ReadCommandPoll();
		menusel = 99999;
		sscanf(RecvBuffer,"%01d",&menusel);
		if ( menusel < 0 || menusel > 9 ) {
			xil_printf(" Invalid Command: Enter 0-9 \n\r");
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
		}

		switch (menusel) { // Switch-Case Menu Select

		case 0: //Set Mode of Operation
			mode = 99; //Detector->GetMode();
			xil_printf("\n\r Waveform Data: \t Enter 0 <return>\n\r");
			xil_printf(" LPF Waveform Data: \t Enter 1 <return>\n\r");
			xil_printf(" DFF Waveform Data: \t Enter 2 <return>\n\r");
			xil_printf(" TRG Waveform Data: \t Enter 3 <return>\n\r");
			xil_printf(" Processed Data: \t Enter 4 <return>\n\r");
			ReadCommandPoll();
			sscanf(RecvBuffer,"%01d",&mode);

			if (mode < 0 || mode > 4 ) { xil_printf("Invalid Command\n\r"); break; }
			// mode = 0, AA waveform
			// mode = 1, LPF waveform
			// mode = 2, DFF waveform
			// mode = 3, TRG waveform
			// mode = 4, Processed Data
			//Detector->SetMode(mode);  // Set Mode for Detector
			Xil_Out32 (XPAR_AXI_GPIO_14_BASEADDR, ((u32)mode));
			// Register 14
			if ( mode == 0 ) { xil_printf("Transfer AA Waveforms\n\r"); }
			if ( mode == 1 ) { xil_printf("Transfer LPF Waveforms\n\r"); }
			if ( mode == 2 ) { xil_printf("Transfer DFF Waveforms\n\r"); }
			if ( mode == 3 ) { xil_printf("Transfer TRG Waveforms\n\r"); }
			if ( mode == 4 ) { xil_printf("Transfer Processed Data\n\r"); }
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 1: //Enable or disable the system
			xil_printf("\n\r Disable: Enter 0 <return>\n\r");
			xil_printf(" Enable: Enter 1 <return>\n\r");
			ReadCommandPoll();
			sscanf(RecvBuffer,"%01d",&enable_state);
			if (enable_state != 0 && enable_state != 1) { xil_printf("Invalid Command\n\r"); break; }
			Xil_Out32(XPAR_AXI_GPIO_18_BASEADDR, ((u32)enable_state));
			// Register 18 Out enabled, In Disabled
			if ( enable_state == 1 ) { xil_printf("DAQ Enabled\n\r"); }
			if ( enable_state == 0 ) { xil_printf("DAQ Disabled\n\r"); }
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 2: //Continuously Read of Processed Data
			xil_printf("\n\r ********Data Acquisition:\n\r");
			xil_printf(" Press 'q' to Stop or Press Hardware USR reset button  \n\r");
			xil_printf(" Press <return> to Start");
			ReadCommandPoll();
			DAQ();
			sw = 0;   // broke out of the read loop, stop swith reset to 0
			break;

		case 3: //Set Threshold
			xil_printf("\n\r Existing Threshold = %d \n\r",Xil_In32(XPAR_AXI_GPIO_10_BASEADDR));
			xil_printf(" Enter Threshold (6144 to 10240) <return> \n\r");
			ReadCommandPoll();
			sscanf(RecvBuffer,"%04d",&thres);
			Xil_Out32(XPAR_AXI_GPIO_10_BASEADDR, ((u32)thres));
			xil_printf("New Threshold = %d \n\r",Xil_In32(XPAR_AXI_GPIO_10_BASEADDR));
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 4: //Set Integration Times
			xil_printf("\n\r Existing Integration Times \n\r");
			xil_printf(" Time = 0 ns is when the Pulse Crossed Threshold \n\r");
			xil_printf(" Baseline Integral Window \t [-200ns,%dns] \n\r",-52 + ((int)Xil_In32(XPAR_AXI_GPIO_0_BASEADDR))*4 );
			xil_printf(" Short Integral Window \t [-200ns,%dns] \n\r",-52 + ((int)Xil_In32(XPAR_AXI_GPIO_1_BASEADDR))*4 );
			xil_printf(" Long Integral Window  \t [-200ns,%dns] \n\r",-52 + ((int)Xil_In32(XPAR_AXI_GPIO_2_BASEADDR))*4 );
			xil_printf(" Full Integral Window  \t [-200ns,%dns] \n\r",-52 + ((int)Xil_In32(XPAR_AXI_GPIO_3_BASEADDR))*4 );

			xil_printf(" Change: (Y)es (N)o <return>\n\r");
			ReadCommandPoll();
			sscanf(RecvBuffer,"%c",&updateint);
			if (updateint == 'N' || updateint == 'n') { break; }
			if (updateint == 'Y' || updateint == 'y') { SetIntegrationTimes(0); }
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s

			break;

		case 5: //Perform a DMA transfer
			xil_printf("\n\r Perform DMA Transfer of Waveform Data\n\r");
			xil_printf(" Press 'q' to Exit Transfer  \n\r");
			Xil_Out32 (XPAR_AXI_DMA_0_BASEADDR + 0x48, 0xa000000);
			Xil_Out32 (XPAR_AXI_DMA_0_BASEADDR + 0x58 , 65536);
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			PrintData();		// Display data to console.
			sw = 0;   // broke out of the read loop, stop swith reset to 0
			break;

		case 6: //Perform a DMA transfer of Processed data
			xil_printf("\n\r ********Perform DMA Transfer of Processed Data \n\r");
			xil_printf(" Press 'q' to Exit Transfer  \n\r");
			//Xil_Out32 (XPAR_AXI_GPIO_18_BASEADDR, 0);	// Disable : GPIO Reg Capture Module
			Xil_Out32 (XPAR_AXI_GPIO_15_BASEADDR, 1);	// Enable: GPIO Reg to Readout Data MUX
			//sleep(1);				// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			Xil_Out32 (XPAR_AXI_DMA_0_BASEADDR + 0x48, 0xa000000); // Transfer from BRAM to DRAM, start address 0xa000000, 16-bit length
			Xil_Out32 (XPAR_AXI_DMA_0_BASEADDR + 0x58 , 65536);
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			Xil_Out32 (XPAR_AXI_GPIO_15_BASEADDR, 0); 	// Disable: GPIO Reg turn off Readout Data MUX
			ClearBuffers();
			PrintData();								// Display data to console.
			//Xil_Out32 (XPAR_AXI_GPIO_18_BASEADDR, 1);	// Enable : GPIO Reg Capture Module
			sw = 0;   // broke out of the read loop, stop swith reset to 0
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 7: //Check the Size of the Data Buffers
			databuff = Xil_In32 (XPAR_AXI_GPIO_11_BASEADDR);
			xil_printf("\n\r BRAM Data Buffer Size = %d \n\r",databuff);
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 8: //Clear the processed data buffers
			xil_printf("\n\r Clear the Data Buffers\n\r");
			ClearBuffers();
			sleep(1); 			// Built in Latency ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 s
			break;

		case 9: //Print DMA Data
			xil_printf("\n\r Print Data\n\r");
			PrintData();
			break;

		default :
			break;
		} // End Switch-Case Menu Select

	}	// ******************* POLLING LOOP *******************//


    cleanup_platform();  // Clean up the platform, which is ...

    return 0;
}
示例#19
0
/**
*
* This function does a minimal test on the GPIO device configured as OUTPUT.
*
* @param	None.
*
* @return	- XST_SUCCESS if the example has completed successfully.
*		- XST_FAILURE if the example has failed.
*
* @note		None.
*
****************************************************************************/
static int GpioOutputExample(void)
{
	u32 Data;
	volatile int Delay;
	u32 LedLoop;

	/*
	 * Set the direction for the pin to be output and
	 * Enable the Output enable for the LED Pin.
	 */
	XGpioPs_SetDirectionPin(&Gpio, OUTPUT_PIN, 1);
	XGpioPs_SetOutputEnablePin(&Gpio, OUTPUT_PIN, 1);

	/*
	 * Set the GPIO output to be low.
	 */
	XGpioPs_WritePin(&Gpio, OUTPUT_PIN, 0x0);


	for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop ++) {


#ifndef __SIM__
		/*
		 * Wait a small amount of time so the LED is visible.
		 */
		for (Delay = 0; Delay < LED_DELAY; Delay++);

#endif
		/*
		 * Set the GPIO Output to High.
		 */
		XGpioPs_WritePin(&Gpio, OUTPUT_PIN, 0x1);

		/*
		 * Read the state of the data and verify. If the data
		 * read back is not the same as the data written then
		 * return FAILURE.
		 */
		Data = XGpioPs_ReadPin(&Gpio, OUTPUT_PIN);
		if (Data != 1 ) {
			return XST_FAILURE;
		}

#ifndef __SIM__
		/*
		 * Wait a small amount of time so the LED is visible.
		 */
		for (Delay = 0; Delay < LED_DELAY; Delay++);

#endif

		/*
		 * Clear the GPIO Output.
		 */
		XGpioPs_WritePin(&Gpio, OUTPUT_PIN, 0x0);

		/*
		 * Read the state of the data and verify. If the data
		 * read back is not the same as the data written then
		 * return FAILURE.
		 */
		Data = XGpioPs_ReadPin(&Gpio, OUTPUT_PIN);
		if (Data != 0) {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
int main()
{

	XSpiPs_Config *SpiConfig_EMIO;
	XGpioPs_Config *GPIOConfigPtr;    //gpio config

	int delay;
	u8 cmd[1];
	int byte_i, temp;
	int loop;
    init_platform();

    printf("SPI Demo MicroZed Chronicles\n\r");

    SpiConfig_EMIO = XSpiPs_LookupConfig((u16)SPI_EMIO);
    XSpiPs_CfgInitialize(&SpiInstance_EMIO, SpiConfig_EMIO,SpiConfig_EMIO->BaseAddress);
    XSpiPs_SetOptions(&SpiInstance_EMIO,XSPIPS_MASTER_OPTION |  XSPIPS_FORCE_SSELECT_OPTION);
    XSpiPs_SetClkPrescaler(&SpiInstance_EMIO, XSPIPS_CLK_PRESCALE_256);

    GPIOConfigPtr = XGpioPs_LookupConfig(XPAR_XGPIOPS_0_DEVICE_ID);
    XGpioPs_CfgInitialize(&Gpio, GPIOConfigPtr,GPIOConfigPtr->BaseAddr);

    //set direction and enable output
    XGpioPs_SetDirectionPin(&Gpio, sig, 1);
    XGpioPs_SetOutputEnablePin(&Gpio, sig, 1);

    XGpioPs_SetDirectionPin(&Gpio, res, 1);
    XGpioPs_SetOutputEnablePin(&Gpio, res, 1);

    XGpioPs_SetDirectionPin(&Gpio, vdd, 1);
    XGpioPs_SetOutputEnablePin(&Gpio, vdd, 1);

    XGpioPs_SetDirectionPin(&Gpio, bat, 1);
    XGpioPs_SetOutputEnablePin(&Gpio, bat, 1);

    XGpioPs_SetDirectionPin(&Gpio, dc, 1);
    XGpioPs_SetOutputEnablePin(&Gpio, dc, 1);

    XGpioPs_WritePin(&Gpio, sig, 0);
    XGpioPs_WritePin(&Gpio, res, 0);
    XGpioPs_WritePin(&Gpio, vdd, 1);
    XGpioPs_WritePin(&Gpio, bat, 1);
    XGpioPs_WritePin(&Gpio, dc, 1);

    XGpioPs_WritePin(&Gpio, vdd, 0);
	for( delay = 0; delay < DELAY; delay++)//wait
	{}
    XGpioPs_WritePin(&Gpio, res, 1);
    config_oled();
    XGpioPs_WritePin(&Gpio, bat, 0);
    blank_oled();//clear screen


//output page 1
 for(loop=0;loop<16;loop++){
    	temp = (line_1[loop] * 8);
    	for(byte_i=0;byte_i<8;byte_i++){
    		data_conv[byte_i] = font[temp+byte_i];
    	}
    	conv_alg(data_conv); //convert to array
    	for(byte_i=0;byte_i<8;byte_i++){
    		page_0[(line_start-(char_size*loop))-byte_i] = results[byte_i];
    	}
 }
    cmd[0] = (u8) 0xB0;
    XGpioPs_WritePin(&Gpio, dc, 0);
    XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance_EMIO, cmd, NULL, 1);
    XGpioPs_WritePin(&Gpio, dc, 1);
    XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance_EMIO, page_0, NULL, 128);

//output page 2
    for(loop=0;loop<16;loop++){
    //loop =0;
       	temp = (line_2[loop] * 8);
       	for(byte_i=0;byte_i<8;byte_i++){
       		data_conv[byte_i] = font[temp+byte_i];
       	}
       	conv_alg(data_conv); //convert to array
       	for(byte_i=0;byte_i<8;byte_i++){
       		page_1[(line_start-(char_size*loop))-byte_i] = results[byte_i];
       	}
    }
       cmd[0] = (u8) 0xB1;
       XGpioPs_WritePin(&Gpio, dc, 0);
       XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
       XSpiPs_PolledTransfer(&SpiInstance_EMIO, cmd, NULL, 1);
       XGpioPs_WritePin(&Gpio, dc, 1);
       XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
       XSpiPs_PolledTransfer(&SpiInstance_EMIO, page_1, NULL, 128);

//output page 3
   for(loop=0;loop<16;loop++){
   //loop =0;
		temp = (line_3[loop] * 8);
		for(byte_i=0;byte_i<8;byte_i++){
			data_conv[byte_i] = font[temp+byte_i];
		}
		conv_alg(data_conv); //convert to array
		for(byte_i=0;byte_i<8;byte_i++){
			page_2[(line_start-(char_size*loop))-byte_i] = results[byte_i];
		}
   }
	  cmd[0] = (u8) 0xB2;
	  XGpioPs_WritePin(&Gpio, dc, 0);
	  XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
	  XSpiPs_PolledTransfer(&SpiInstance_EMIO, cmd, NULL, 1);
	  XGpioPs_WritePin(&Gpio, dc, 1);
	  XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
	  XSpiPs_PolledTransfer(&SpiInstance_EMIO, page_2, NULL, 128);

//output page 4
  for(loop=0;loop<16;loop++){
  //loop =0;
		temp = (line_4[loop] * 8);
		for(byte_i=0;byte_i<8;byte_i++){
			data_conv[byte_i] = font[temp+byte_i];
		}
		conv_alg(data_conv); //convert to array
		for(byte_i=0;byte_i<8;byte_i++){
			page_3[(line_start-(char_size*loop))-byte_i] = results[byte_i];
		}
  }
	 cmd[0] = (u8) 0xB3;
	 XGpioPs_WritePin(&Gpio, dc, 0);
	 XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
	 XSpiPs_PolledTransfer(&SpiInstance_EMIO, cmd, NULL, 1);
	 XGpioPs_WritePin(&Gpio, dc, 1);
	 XSpiPs_SetSlaveSelect(&SpiInstance_EMIO, 0x01);
	 XSpiPs_PolledTransfer(&SpiInstance_EMIO, page_3, NULL, 128);

    return 0;
}