コード例 #1
2
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;
}
コード例 #2
1
ファイル: helloworld.c プロジェクト: MasterInformatica/chs
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;*/
}
コード例 #3
0
/**
*
* This function is an example of how to use the IO Module driver component
* (XIOModule) and the hardware device.  This function is designed to work
* without external hardware devices to cause interrupts.  It may not return if
* the IO Module is not properly connected to the processor in either software
* or hardware.
*
* @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 IOModuleExample(u16 DeviceId)
{
    XStatus Status;

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

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

    /*
     * Setup the Interrupt System.
     */
    Status = SetUpInterruptSystem(&IOModule);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Generate the interrupts.
     */
    Status = XOModule_GenerateIntr(&IOModule);
    if (Status != XST_SUCCESS)
    {
        return XST_FAILURE;
    }

    /*
     * Wait for the interrupts to be processed, if no interrupt occurs this
     * loop will wait forever.
     */
    while (1)
    {
        /*
         * If the interrupts occurred which is indicated by the global
         * variable which is set in the device driver handler, then
         * stop waiting
         */
        if (InterruptProcessed)
        {
            break;
        }
    }

    return XST_SUCCESS;
}
コード例 #4
0
ファイル: hello.c プロジェクト: aomtoku/hdmi-ts-old
int main()
{
    u32 uDevId = XPAR_IOMODULE_0_DEVICE_ID;
    XIOModule mcsIOMdule;
    init_platform();
    //MicroBlaze MCS IOModule Initialize
    XIOModule_Initialize(&mcsIOMdule, uDevId);
    //set GPO1
    XIOModule_DiscreteWrite(&mcsIOMdule, 1,2);
    //UART
    print("Hello World\n\r");
    cleanup_platform();
    return 0;
}
コード例 #5
0
ファイル: helloworld.c プロジェクト: bikerglen/robot-arm-v01
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 ();
		}
	}
}
コード例 #6
0
ファイル: helloworld.c プロジェクト: shohei/papilio-book
int main()
{
    u32 uDevId = XPAR_IOMODULE_0_DEVICE_ID;
    XIOModule mcsIOMdule;
    u8 read_data_8;
    u8 read_data_8_old;
    init_platform();
    XIOModule_Initialize(&mcsIOMdule, uDevId);
    print("Hello World + GPIO \n\r");
    while(1){
      read_data_8 = XIOModule_DiscreteRead(&mcsIOMdule, 1);
      if( read_data_8 !=  read_data_8_old){
        XIOModule_DiscreteWrite(&mcsIOMdule, 1, read_data_8);
        xil_printf("sw %02x\n\r",read_data_8);
        read_data_8_old = read_data_8;
      }
    }
    return 0;
}
コード例 #7
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;
}
コード例 #8
0
/**
* This function does a minimal test on the IO Module device and driver as a
* design example.  The purpose of this function is to illustrate how to use the
* IO Module component.  It initializes the Programmable Interval Timers and
* then sets it up in compare mode with auto reload such that a periodic
* interrupt is generated.
*
* This function uses interrupt driven mode of the IO Module.
*
* @param	IOModuleInstancePtr is a pointer to the IO Module driver
*		Instance
* @param	DeviceId is the XPAR_<IOModule_instance>_DEVICE_ID value from
*		xparameters.h
*
* @return	XST_SUCCESS if the Test is successful, otherwise XST_FAILURE
*
* @note		This function contains an infinite loop such that if interrupts
*		are not working it may never return.
*
*****************************************************************************/
XStatus IOModuleIntrExample(XIOModule *IOModuleInstancePtr, u16 DeviceId)
{
    int Status;
    u8 Timer;
    XIOModule_Config *CfgPtr = IOModuleInstancePtr->CfgPtr;

    /*
     * Initialize the IO Module so that it's ready to use, specify the device
     * ID that is generated in xparameters.h
     */
    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);

    /*
     * Setup the handler for the IO Module handler that will be called from
     * the interrupt context when an interrupt occurs, specify a pointer to
     * the IO Module driver instance as the callback reference so the
     * handler is able to access the instance data.
     */
    XIOModule_SetHandler(IOModuleInstancePtr,
			 IOModuleHandler,
			 IOModuleInstancePtr);

    for (Timer = 0; Timer < XTC_DEVICE_TIMER_COUNT; Timer++)
    {
	/*
	 * Skip unused timers,timers with prescaler (since they may
	 * have very long expiration times), timers without readable
	 * counters, and timers with small size (since the counter
	 * may not change when sampled).
	 */
	if (!  (CfgPtr->PitUsed[Timer] &&
		CfgPtr->PitPrescaler[Timer] == XTC_PRESCALER_NONE &&
		CfgPtr->PitReadable[Timer] &&
		CfgPtr->PitSize[Timer] > MIN_TIMER_BITS)) {
	    TimerExpired[Timer] = MAX_INTR_COUNT;
	    continue;
	}

	/*
	 * Use auto reload mode such that the Programmable Interval Timers will
	 * reload automatically and continue repeatedly, without this option
	 * they would expire once only
	 */
	XIOModule_Timer_SetOptions(IOModuleInstancePtr, Timer,
			   XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION);

	/*
	 * Set a reset value for the Programmable Interval Timers such that
	 * they will expire earlier than letting them roll over from 0, the
	 * reset value is loaded into the Programmable Interval Timers when
	 * they are started.
	 */
	XIOModule_SetResetValue(IOModuleInstancePtr, Timer, RESET_VALUE);

	/*
	 * Enable the interrupt for the Programmable Interval Timers.
	 */
	XIOModule_Enable(IOModuleInstancePtr,
			 Timer + XIN_IOMODULE_PIT_1_INTERRUPT_INTR);

	/*
	 * Start the Programmable Interval Timers such that they are
	 * decrementing by default, then wait for them to timeout a number of
	 * times.
	 */
	XIOModule_Timer_Start(IOModuleInstancePtr, Timer);
    }

    while (1) {
	int TotalExpiredCount = 0;

	/*
	 * Wait for the Programmable Interval Timers to expire as indicated by
	 * the shared variable which the handler will increment, and stop each
	 * timer when it has reached the expected number of times.
	 */
	for (Timer = 0; Timer < XTC_DEVICE_TIMER_COUNT; Timer++) {
	    if (TimerExpired[Timer] >= MAX_INTR_COUNT)
		XIOModule_Timer_Stop(IOModuleInstancePtr, Timer);
	    TotalExpiredCount += TimerExpired[Timer];
	}

	/*
	 * If all timers have expired the expected number of times, then stop
	 * this example.
	 */
	if (TotalExpiredCount == MAX_INTR_COUNT * XTC_DEVICE_TIMER_COUNT) {
	    break;
	}
    }

    IOModuleDisableIntr(IOModuleInstancePtr);

    return XST_SUCCESS;
}
コード例 #9
0
int main()
{
    init_platform();

    XIOModule_Initialize(&iomod_inst, 0);

    wait_ms(&iomod_inst,1000);

    codec_init(&iomod_inst);

    wait_ms(&iomod_inst,1000);
    print("Codec Initialized\r\n");
    print("Reading back registers\r\n");

    int i;
    uint8_t regData;
    for(i = 1; i < 9; i++)
    {
    	regData = codec_read(&iomod_inst,i);
    	print("Address ");
    	print_u32_hex((u32)i);
    	print(" ");
    	print_u32_hex((u32)regData);
    	print("\r\n");
    }

    print("Waiting 5 seconds for codec HPF to stabilize...\r\n");

    wait_ms(&iomod_inst,5000);

    u8 numCharsRet;

    clearInpBuffer();

    while(1)
    {
    	print("Please select the channel (L/R)\r\n> ");
    	numCharsRet = serial_read_line(serialInputBuffer,SERIAL_INPUT_BUFFER_LEN);

    	if(numCharsRet > 0)
    	{
    		if((serialInputBuffer[0] == 'l') || (serialInputBuffer[0] == 'L'))
    		{
    			selectedChannel = Left;
    			break;
    		}
    		else if((serialInputBuffer[0] == 'r') || (serialInputBuffer[0] == 'R'))
    		{
    			selectedChannel = Right;
    			break;
    		}
    	}

    	print("Invalid channel selection.\r\n");
    }
    clearInpBuffer();

    RunSineTest();


    for(i = 0; i < MAX_INPUT_LEN; i++)
    {
    	xil_printf("%d\r\n",input_buffer[i]);
    }

    print("End of samples\r\n");


    return 0;
}