int main()
{
    init_platform();

    XIOModule_Initialize(&gpo, XPAR_IOMODULE_0_DEVICE_ID); // Initialize the GPO module

	microblaze_register_handler(XIOModule_DeviceInterruptHandler,
			XPAR_IOMODULE_0_DEVICE_ID); // register the interrupt handler

	XIOModule_Start(&gpo); // start the GPO module

	XIOModule_Connect(&gpo, XIN_IOMODULE_FIT_1_INTERRUPT_INTR, timerTick,
			NULL); // register timerTick() as our interrupt handler
	XIOModule_Enable(&gpo, XIN_IOMODULE_FIT_1_INTERRUPT_INTR); // enable the interrupt

	microblaze_enable_interrupts(); // enable global interrupts

	u8 leds = 0;
	while (1){
		// write the LED value to port 1 (you can have up to 4 ports)
		XIOModule_DiscreteWrite(&gpo, 1, leds++);
		xil_printf("%d", leds);
		xil_printf(",");
		delay(500); // delay one half second
	}
    return 0;
}
Exemplo n.º 2
1
int main()
{

	init_platform();
		u32 data,data2;
		unsigned int empty_L;
		unsigned int full_E;
		unsigned int i;

		XIOModule iomodule;
		data = XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
		data = XIOModule_Start(&iomodule);

		DIR_FIFO_ESCRITURA_DT = (u32) 'H';
		DIR_FIFO_ESCRITURA_DT = (u32) 'O';
		DIR_FIFO_ESCRITURA_DT = (u32) 'L';
		DIR_FIFO_ESCRITURA_DT = (u32) 'A';
		DIR_FIFO_ESCRITURA_DT = (u32) '\n';


		while (1) {
			do{
				data = DIR_FIFO_LECTURA_ST;
				empty_L = (unsigned int) data;
			}while(empty_L != 0);
			data2 = DIR_FIFO_LECTURA_DT;

			do{
				data = DIR_FIFO_ESCRITURA_ST;
				full_E = (unsigned int) data;
			}while(full_E != 0);

			DIR_FIFO_ESCRITURA_DT = data2;

			data = DIR_SWITCHES;
			DIR_LEDS = data;
		}

		cleanup_platform();
		return 0;
/*	init_platform();
	u32 data;

	XIOModule iomodule;
	xil_printf("Reading switches and writing to LED port\n\r");
	data = XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
	data = XIOModule_Start(&iomodule);

	while (1)
	{
		data = DIRSWIT;
		xil_printf("Valor: %x\n\r",data);
		DIRLEDS = data;
	}
	cleanup_platform();
	return 0;*/
}
Exemplo n.º 3
0
/**
*
* This function connects the interrupt handler of the IO Module to the
* processor.  This function is separate to allow it to be customized for each
* application.  Each processor or RTOS may require unique processing to connect
* the interrupt handler.
*
* @param    None.
*
* @return   None.
*
* @note     None.
*
****************************************************************************/
XStatus SetUpInterruptSystem(XIOModule *XIOModuleInstancePtr)
{
    XStatus Status;

    /*
     * Connect a device driver handler that will be called when an interrupt
     * for the device occurs, the device driver handler performs the specific
     * interrupt processing for the device
     */
    Status = XIOModule_Connect(XIOModuleInstancePtr, IOMODULE_DEVICE_ID,
                               (XInterruptHandler) DeviceDriverHandler,
                               (void *)0);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Start the IO Module such that interrupts are enabled for all devices
     * that cause interrupts.
     */
    Status = XIOModule_Start(XIOModuleInstancePtr);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Enable interrupts for the device and then cause interrupts so the
     * handlers will be called.
     */
    XIOModule_Enable(XIOModuleInstancePtr, IOMODULE_DEVICE_ID);

    /*
     * Initialize the exception table.
     */
    Xil_ExceptionInit();

    /*
     * Register the IO module interrupt handler with the exception table.
     */
    Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
		 (Xil_ExceptionHandler)XIOModule_DeviceInterruptHandler,
		 (void*) 0);

    /*
     * Enable exceptions.
     */
    Xil_ExceptionEnable();

    return XST_SUCCESS;
}
Exemplo n.º 4
0
int main()
{
	init_platform();
	XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
	XIOModule_Start(&iomodule);
	XIOModule_CfgInitialize(&iomodule, NULL, 1);

	xil_printf ("\n\r\n\rRobot Console v0.01\n\r\n\r");

	Xil_Out32 (MX_LIMIT_LO, -14400);	// gripper rotate
	Xil_Out32 (MX_LIMIT_HI,  14400);
	Xil_Out32 (MX_POSITION,      0);

	Xil_Out32 (MY_LIMIT_LO,  -2800);	// wrist
	Xil_Out32 (MY_LIMIT_HI,   3960);
	Xil_Out32 (MY_POSITION,   3960);

	Xil_Out32 (MZ_LIMIT_LO,  -7200);	// lower arm rotate
	Xil_Out32 (MZ_LIMIT_HI,   7200);
	Xil_Out32 (MZ_POSITION,      0);

	Xil_Out32 (MA_LIMIT_LO,  -9257);	// elbow
	Xil_Out32 (MA_LIMIT_HI,  12750);
	Xil_Out32 (MA_POSITION,  12750);

	Xil_Out32 (MB_LIMIT_LO,  -5520);	// shoulder
	Xil_Out32 (MB_LIMIT_HI,   6900);
	Xil_Out32 (MB_POSITION,  -5520);

	Xil_Out32 (MC_LIMIT_LO,  -2823);	// base
	Xil_Out32 (MC_LIMIT_HI,   2823);
	Xil_Out32 (MC_POSITION,      0);

	Xil_Out32 (MOTION_ALARM, 0x3f);

	InitCommandProcessing ();

	for (;;) {
		if (GetCommand ()) {
			ProcessCommand ();
		}
	}
}
Exemplo n.º 5
0
/**
*
* This function is used by the TestAppGen generated application to setup
* the IO Module interrupts.
*
* @param    IOModuleInstancePtr is the reference to the IO Module instance.
* @param    DeviceId is device ID of the IO Module Device , typically
*           XPAR_<IOMODULE_instance>_DEVICE_ID value from xparameters.h
*
* @return   XST_SUCCESS to indicate success, otherwise XST_FAILURE
*
* @note     None.
*
******************************************************************************/
XStatus IOModuleInterruptSetup(XIOModule *IOModuleInstancePtr,
			       u16 DeviceId)
{
    XStatus Status;

    /*
     * Initialize the IO Module driver so that it is ready to use.
     */
    Status = XIOModule_Initialize(IOModuleInstancePtr, DeviceId);
    if (Status != XST_SUCCESS)
    {
	return XST_FAILURE;
    }

    /*
     * Perform a self-test to ensure that the hardware was built correctly.
     */
    Status = XIOModule_SelfTest(IOModuleInstancePtr);
    if (Status != XST_SUCCESS)
    {
	return XST_FAILURE;
    }

    /*
     * Initialize and enable interrupts in the processor.
     */
    IOModuleSetupIntrSystem(IOModuleInstancePtr);

    /*
     * Start the IO Module such that interrupts are enabled for all
     * internal interrupts.
     */
    Status = XIOModule_Start(IOModuleInstancePtr);
    if (Status != XST_SUCCESS)
    {
	return XST_FAILURE;
    }

    return XST_SUCCESS;
}