/**
* This function is the main function of the GPIO example.  It is responsible
* for initializing the GPIO device, setting up interrupts and providing a
* foreground loop such that interrupt can occur in the background.
*
* @param	None.
*
* @return
*		- XST_SUCCESS to indicate success.
*		- XST_FAILURE to indicate Failure.
*
* @note		None.
*
*
*****************************************************************************/
int main(void)
{
	int Status;

	/* Initialize the GPIO driver. If an error occurs then exit */

	Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Perform a self-test on the GPIO.  This is a minimal test and only
	 * verifies that there is not any bus error when reading the data
	 * register
	 */
	XGpio_SelfTest(&Gpio);

	/*
	 * Setup direction register so the switch is an input and the LED is
	 * an output of the GPIO
	 */
	XGpio_SetDataDirection(&Gpio, BUTTON_CHANNEL, GPIO_ALL_BUTTONS);
	XGpio_SetDataDirection(&Gpio, LED_CHANNEL, ~GPIO_ALL_LEDS);

	/* Sequence the LEDs to show this example is starting to run */

	SequenceLeds();

	/*
	 * Setup the interrupts such that interrupt processing can occur. If
	 * an error occurs then exit
	 */
	Status = SetupInterruptSystem();
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Loop forever while the button changes are handled by the interrupt
	 * level processing
	 */
	while (1) {
	}

	return XST_SUCCESS;
}
示例#2
0
static int SetupSdGpio(XGpio *sGpio) {
    int Status;

    // Initialize the GPIO driver. If an error occurs then exit.
    Status = XGpio_Initialize(sGpio, SD_GPIO_DEVICE_ID);
    if (Status != XST_SUCCESS) {
        xil_printf("Failed to initialize SD GPIO driver: %d\n\r", Status);
        return XST_FAILURE;
    }

    // Set the direction for all signals to be inputs.
    XGpio_SetDataDirection(sGpio, SD_GPIO_CHANNEL, SD_GPIO_CARD_PRESENT_MASK);
    XGpio_SetDataDirection(sGpio, 1, ~0);

    XGpio_InterruptEnable(sGpio, XGPIO_IR_CH1_MASK);
    XGpio_InterruptGlobalEnable(sGpio);

    XGpio_SelfTest(sGpio);

    // TODO: add Interrupt configuration code.

    return XST_SUCCESS;
}
示例#3
0
int main()
{
    int i;
    init_platform();
    print("--Starting...--\n\r");

    /*for (i = 0; i < n_memory_ranges; i++) {
        test_memory_range(&memory_ranges[i]);
    }*/

	int Status;
	/* Initialize the GPIO driver. If an error occurs then exit */
	Status = XGpio_Initialize(&gpio_btn, XPAR_GPIO_BTN_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Initialize the GPIO driver. If an error occurs then exit */
	Status = XGpio_Initialize(&gpio_led, XPAR_GPIO_LED_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Perform a self-test on the GPIO.  This is a minimal test and only
	 * verifies that there is not any bus error when reading the data
	 * register
	 */
	XGpio_SelfTest(&gpio_btn);
	XGpio_SelfTest(&gpio_led);

	XGpio_SetDataDirection(&gpio_btn, XGPIO_IR_CH1_MASK, 0x1);
	XGpio_SetDataDirection(&gpio_led, XGPIO_IR_CH1_MASK, 0x0);

	XGpio_DiscreteClear(&gpio_led, XGPIO_IR_CH1_MASK, 0xffff);

	param_setup();
	XMcml_Initialize(&mcml, XPAR_MCML_0_DEVICE_ID);
    print("--Starting Kernel--\n\r");
	XMcml_Start(&mcml);

    //cleanup_platform();
    while (1)
    {
    	if(XMcml_IsDone(&mcml)) break;
    }

    print("NOTE: MCML kernel is done.\n\r");
	XGpio_DiscreteSet(&gpio_led, XGPIO_IR_CH1_MASK, 0x1);

	float * ar_z = (float *)memory_ranges[ARZ_CTRL].base;
	for(i=0; i< 10000; i++)
	{
		int whole, thousandths;
		float fval = *(ar_z++);
		whole = fval;
		thousandths = (fval - whole) * 1000;
		if(i % 100 == 0)
			xil_printf("\n\r");

		xil_printf("%d.%3d *", whole, thousandths);

	}
	XGpio_DiscreteSet(&gpio_led, XGPIO_IR_CH1_MASK, 0x3);
    print("--DONE-- \n\r");
    return 0;
}