Example #1
0
/**
 *
 * Main function
 *
 * This function is the main entry of the interrupt test. It does the following:
 *	Initialize the audio
 *	Initialize the debug uart
 *	Enable the interrupts
 *
 * @param	None
 *
 * @return
 *		- XST_SUCCESS if example finishes successfully
 *		- XST_FAILURE if example fails.
 *
 * @note		None.
 *
 ******************************************************************************/
int main(void)
{
    init_platform();
    InitMotorBoard();

    xil_printf("\r\n--- Entering main() --- \r\n");

    int status = XST_SUCCESS;
    status |= initialize_audio(&sIic, &sAxiAudioDma);
    status |= fnInitInterruptController(&sIntc);
    status |= initialize_uart(&sUartLite);
    status |= initialize_video(&sVideoCapt, &sIntc);
    status |= initialize_targeting(&sAxiTargetingDma);
    status |= SetupSdGpio(&sGpio);

    if (status != XST_SUCCESS) {
        xil_printf("Failed to initialize system.\r\n");
        return XST_FAILURE;
    }

    // Initialize static variables.
    for (int i = 0; i < FILE_ID_MAX; i++) {
        sSdFileBoard[i].loaded = false;
    }
    sSdFileMemTip = (u32 *) AUDIO_BASE_ADDR;

    sButtonState = 0;

    sLoopSelect = DEFAULT_LOOP;
    fnEnableInterrupts(&sIntc, &ivt[0], sizeof(ivt)/sizeof(ivt[0]));

    register_uart_response("test", test_fcn);
    register_uart_response("record", uart_rec_audio);
    register_uart_response("play", uart_play_audio);
    register_uart_response("kill", end_fcn);
    register_uart_response("exit", end_fcn);
    register_uart_response("dump", dump_mem);

    // Commands to run self-tests
    register_uart_response("lowlevel", LowLevelTest);
    register_uart_response("highlevel", HighLevelTest);
    register_uart_response("lasertest", EnterLaserTest);
    register_uart_response("motortest", EnterMotorTest);
    register_uart_response("stop", stopTest);

    register_uart_response("load_sounds", loadSounds);
    register_uart_response("load_images", loadImages);

    register_uart_response("still_alive", playPortalSong);
    register_uart_response("gun", playGunSound);
    register_uart_response("portal_gun", playPortalGunSound);
    register_uart_response("target", playTargetAcquired);
    register_uart_response("playpos", playPos);
    register_uart_response("playneg", playNeg);

    register_uart_response("manual", EnterManualMainLoop);
    register_uart_response("auto", EnterAutomaticMainLoop);

    register_uart_response("passthrough", passthroughHdmi);
    register_uart_response("runip",       EnterIpTest);
    register_uart_response("videoinfo",   print_video_info);
    register_uart_response("df1",         df1);
    register_uart_response("df2",         df2);
    register_uart_response("df0",         df0);
    register_uart_response("vf1",         vf1);
    register_uart_response("vf2",         vf2);
    register_uart_response("vf0",         vf0);
    register_uart_response("ipinfo",      print_ip_info);
    register_uart_response("ipouttoggle", toggle_ip_output);
    register_uart_response("dummytarget", setDummyTarget);

    register_uart_response("lemon",       DisplayLemon);
    register_uart_response("heman",       DisplayHeman);
    register_uart_response("pass",        SetPassthroughMode);
    register_uart_response("gray",        SetGrayscaleMode);
    register_uart_response("sobel",        SetSobelMode);
    register_uart_response("thresh",        SetThresholdMode);
    register_uart_response("label",        SetLabelMode);
    register_uart_response("colour",        SetColourMode);
    register_uart_response("laser",        SetLaserMode);
    register_uart_response("flood1",        SetFlood1Mode);
    register_uart_response("flood2",        SetFlood2Mode);

    register_uart_response("laseron",        LaserOn);
    register_uart_response("laseroff",        LaserOff);

    register_uart_response("redthresh",        SetRedThreshold);
    register_uart_response("sobelthresh",   SetSobelThreshold);
    register_uart_response("f1thresh",   SetFlood1Threshold);
    register_uart_response("f2thresh",   SetFlood2Threshold);
    register_uart_response("setminsize",   SetSizeThreshold);


    register_uart_response("setobjid",   SetObjId);

    register_uart_response("test_args",   TestArgs);

    xil_printf("\r\n--- Done registering UART commands --- \r\n");

    initialSetup();
    xil_printf(PROMPT_STRING);
    while (do_run) {
        switch (sLoopSelect) {
            case MANUAL_MODE: ManualMainLoop(); break;
            case AUTOMATIC_MODE: AutoMainLoop(); break;
            case LASER_TEST: LaserTest(); break;
            case MOTOR_TEST: MotorPatternTest(); break;
            case IP_TEST: runImageProcessing(); sLoopSelect = DEFAULT_LOOP; break;
            default: MB_Sleep(100); break;
        }
    }

    xil_printf("\r\n--- Exiting main() --- \r\n");

    return XST_SUCCESS;
}
Example #2
0
void DemoInitialize()
{
	int Status;
	XAxiVdma_Config *vdmaConfig;
	int i;

	/*
	 * Initialize an array of pointers to the 3 frame buffers
	 */
	for (i = 0; i < DISPLAY_NUM_FRAMES; i++)
	{
		pFrames[i] = frameBuf[i];
	}

	/*
	 * Initialize VDMA driver
	 */
	vdmaConfig = XAxiVdma_LookupConfig(VGA_VDMA_ID);
	if (!vdmaConfig)
	{
		xil_printf("No video DMA found for ID %d\r\n", VGA_VDMA_ID);
		return;
	}
	Status = XAxiVdma_CfgInitialize(&vdma, vdmaConfig, vdmaConfig->BaseAddress);
	if (Status != XST_SUCCESS)
	{
		xil_printf("VDMA Configuration Initialization failed %d\r\n", Status);
		return;
	}

	/*
	 * Initialize the Display controller and start it
	 */
	Status = DisplayInitialize(&dispCtrl, &vdma, DISP_VTC_ID, DYNCLK_BASEADDR, pFrames, DEMO_STRIDE);
	if (Status != XST_SUCCESS)
	{
		xil_printf("Display Ctrl initialization failed during demo initialization%d\r\n", Status);
		return;
	}
	Status = DisplayStart(&dispCtrl);
	if (Status != XST_SUCCESS)
	{
		xil_printf("Couldn't start display during demo initialization%d\r\n", Status);
		return;
	}

	/*
	 * Initialize the Interrupt controller and start it.
	 */
	Status = fnInitInterruptController(&intc);
	if(Status != XST_SUCCESS) {
		xil_printf("Error initializing interrupts");
		return;
	}
	fnEnableInterrupts(&intc, &ivt[0], sizeof(ivt)/sizeof(ivt[0]));

	/*
	 * Initialize the Video Capture device
	 */
	Status = VideoInitialize(&videoCapt, &intc, &vdma, VID_GPIO_ID, VID_VTC_ID, VID_VTC_IRPT_ID, pFrames, DEMO_STRIDE, DEMO_START_ON_DET);
	if (Status != XST_SUCCESS)
	{
		xil_printf("Video Ctrl initialization failed during demo initialization%d\r\n", Status);
		return;
	}

	/*
	 * Set the Video Detect callback to trigger the menu to reset, displaying the new detected resolution
	 */
	VideoSetCallback(&videoCapt, DemoISR, &fRefresh);

	DemoPrintTest(dispCtrl.framePtr[dispCtrl.curFrame], dispCtrl.vMode.width, dispCtrl.vMode.height, dispCtrl.stride, DEMO_PATTERN_1);

	return;
}