int main(void) { remove_pcap(); static XHwIcap HwIcap; XHwIcap_Config *CfgPtr = XHwIcap_LookupConfig(HWICAP_DEVICEID); if (CfgPtr == NULL) { return XST_FAILURE; } int Status = XHwIcap_custom_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } test(&HwIcap); xil_printf("End ROM test.\n\r\n\r"); return 0; }
/** * * This function reads a frame from the device as an example using polled mode. * * @param DeviceId is the XPAR_<HWICAP_INSTANCE>_DEVICE_ID value from * xparameters.h * * @return XST_SUCCESS if successful, otherwise XST_FAILURE * * @note None * ****************************************************************************/ int HwIcapReadFramePolledExample(u16 DeviceId) { int Status; u32 Index; XHwIcap_Config *CfgPtr; u32 FrameData[XHI_NUM_WORDS_FRAME_INCL_NULL_FRAME]; /* * Initialize the HwIcap instance. */ CfgPtr = XHwIcap_LookupConfig(DeviceId); if (CfgPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Read the Frame */ Status = XHwIcap_DeviceReadFrame(&HwIcap, HWICAP_EXAMPLE_TOP, HWICAP_EXAMPLE_BLOCK, HWICAP_EXAMPLE_HCLK, HWICAP_EXAMPLE_MAJOR, HWICAP_EXAMPLE_MINOR, (u32 *) &FrameData[0]); if (Status != XST_SUCCESS) { printf("Failed to Read Frame: %d \r\n", Status); return XST_FAILURE; } /* * Print Frame contents */ for (Index = XHI_NUM_FRAME_WORDS; Index < (XHI_NUM_FRAME_WORDS << 1) ; Index++) { printf("Frame Word %d -> \t %x \r\n", (Index - XHI_NUM_FRAME_WORDS) , FrameData[Index]); } printf("\r\nHwIcapReadFramePolledExample Passed Successfully.\r\n\r\n"); return XST_SUCCESS; }
/** * * The purpose of this function is to illustrate the usage of the HwIcap driver. * * @param HwIcapDeviceId is device ID of the XHwIcap Device, typically * XPAR_<HWICAP_instance>_DEVICE_ID value from xparameters.h * * @return XST_SUCCESS to indicate success, otherwise XST_FAILURE. * * @note None. * ****************************************************************************/ int HwIcapTestAppExample(u16 HwIcapDeviceId) { int Status; XHwIcap_Config *ConfigPtr; u32 ConfigRegData; /* * Initialize the HwIcap driver. */ ConfigPtr = XHwIcap_LookupConfig(HwIcapDeviceId); if (ConfigPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, ConfigPtr, ConfigPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Read the ID Code register inside the FPGA. */ Status = XHwIcap_GetConfigReg(&HwIcap, XHI_IDCODE, &ConfigRegData); if (Status != XST_SUCCESS) { return XST_FAILURE; } return XST_SUCCESS; }
/// /// Initialize the ICAP /// void icap_init(void){ CYG_REPORT_FUNCTION(); XStatus Status; icap_config = XHwIcap_LookupConfig(HWICAP_DEVICEID); Status = XHwIcap_CfgInitialize(&HwIcap, &icap_config, icap_config->BaseAddress); if (Status != XST_SUCCESS) { switch (Status) { case XST_INVALID_PARAM: diag_printf("HWICAP: invalid parameter\n"); break; case XST_FAILURE: diag_printf("HWICAP: failure\n"); break; case XST_DEVICE_IS_STARTED: diag_printf("HWICAP: device already started\n"); break; case XST_DEVICE_NOT_FOUND: diag_printf("HWICAP: device not found\n"); break; default: diag_printf("HWICAP: failed with return value %d\n", Status); } CYG_FAIL("failed to initialize icap\naborting\n"); } // Run self test Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { CYG_FAIL("HWICAP: self-test failed\n"); } cyg_mutex_init(&icap_mutex); CYG_REPORT_RETURN(); }
/** * * This function does a minimal test on the HwIcap device and driver as a * design example. The purpose of this function is to illustrate how to use * the XHwIcap component using the interrupt mode. * * This function sends data and expects to receive the same data. * * * @param IntcInstancePtr is a pointer to the instance of the INTC component. * @param HwIcapInstancePtr is a pointer to the instance of HwIcap component. * @param HwIcapDeviceId is the Device ID of the HwIcap Device and is the * XPAR_<HWICAP_instance>_DEVICE_ID value from xparameters.h. * @param HwIcapIntrId is the interrupt Id and is typically * XPAR_<INTC_instance>_<HWICAP_instance>_IP2INTC_IRPT_INTR * value from xparameters.h . * * @return XST_SUCCESS if successful, otherwise XST_FAILURE. * * @note * * This function contains an infinite loop such that if interrupts are not * working it may never return. * ******************************************************************************/ int HwIcapIntrExample(XIntc *IntcInstancePtr, XHwIcap *HwIcapInstancePtr, u16 HwIcapDeviceId, u16 HwIcapIntrId) { int Status; u32 Count; u8 Test; XHwIcap_Config *ConfigPtr; /* * Initialize the HwIcap driver. */ ConfigPtr = XHwIcap_LookupConfig(HwIcapDeviceId); if (ConfigPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(HwIcapInstancePtr, ConfigPtr, ConfigPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XHwIcap_SelfTest(HwIcapInstancePtr); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Connect the HwIcap device to the interrupt subsystem such that * interrupts can occur. This function is application specific. */ Status = HwIcapSetupInterruptSystem(IntcInstancePtr, HwIcapInstancePtr, HwIcapIntrId); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Setup the handler for the HwIcap that will be called from the * interrupt context when an HwIcap status occurs, specify a pointer * to the HwIcap driver instance as the callback reference so the * handler is able to access the instance data. */ XHwIcap_SetInterruptHandler(HwIcapInstancePtr, HwIcapInstancePtr, (XHwIcap_StatusHandler)HwIcapIntrHandler); /* * Initialize the write buffer with pattern to write. */ for (Count = 0; Count < TEST_WRITE_BUFFER_SIZE;) { WriteBuffer[Count++] = XHI_DUMMY_PACKET; WriteBuffer[Count++] = XHI_SYNC_PACKET; WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_IDCODE) | 1; WriteBuffer[Count++] = XHI_NOOP_PACKET; WriteBuffer[Count++] = XHI_NOOP_PACKET; WriteBuffer[Count++] = XHI_DUMMY_PACKET; WriteBuffer[Count++] = XHI_SYNC_PACKET; WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_COR) | 1; WriteBuffer[Count++] = XHI_NOOP_PACKET; WriteBuffer[Count++] = XHI_NOOP_PACKET; } /* * Enable the Write FIFO Half Full Interrupt. */ XHwIcap_IntrEnable(HwIcapInstancePtr, XHI_IPIXR_WRP_MASK); /* * Write the the data to the device. */ TransferInProgress = TRUE; Status = XHwIcap_DeviceWrite(HwIcapInstancePtr, (u32 *) &WriteBuffer[0], TEST_WRITE_BUFFER_SIZE); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Wait for the data to be written to the device. */ while (TransferInProgress); return XST_SUCCESS; }
/** * * This function reads the configuration registers inside the FPGA. * * @param DeviceId is the XPAR_<HWICAP_INSTANCE>_DEVICE_ID value from * xparameters.h. * * @return XST_SUCCESS if successful, otherwise XST_FAILURE. * * @note None. * ******************************************************************************/ int HwIcapReadConfigRegExample(u16 DeviceId) { int Status; XHwIcap_Config *CfgPtr; u32 ConfigRegData; /* * Initialize the HwIcap instance. */ CfgPtr = XHwIcap_LookupConfig(DeviceId); if (CfgPtr == NULL) { return XST_FAILURE; } Status = XHwIcap_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress); if (Status != XST_SUCCESS) { return XST_FAILURE; } /* * Run the Self test. */ Status = XHwIcap_SelfTest(&HwIcap); if (Status != XST_SUCCESS) { return XST_FAILURE; } printf("Value of the Configuration Registers. \r\n\r\n"); if (XHwIcap_GetConfigReg(&HwIcap, XHI_CRC, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CRC -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FAR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FAR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FDRI, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FDRI -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_FDRO, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" FDRO -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CMD, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CMD -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CTL, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CTL -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_MASK, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" MASK -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_STAT, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" STAT -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_LOUT, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" LOUT -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_COR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" COR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_MFWR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" MFWR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CBC, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CBC -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_AXSS, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" AXSS -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_IDCODE, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" IDCODE -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_COR_1, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" COR_1 -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CSOB, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CSOB -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_WBSTAR, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" WBSTAR -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_TIMER, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" TIMER -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_BOOTSTS, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" BOOTSTS -> \t %x \t\r\n", ConfigRegData); } if (XHwIcap_GetConfigReg(&HwIcap, XHI_CTL_1, (u32 *)&ConfigRegData) == XST_SUCCESS) { printf(" CTL_1 -> \t %x \t\r\n", ConfigRegData); } printf("\r\n HwIcapReadConfigRegExample Passed Successfully.\r\n\r\n"); return XST_SUCCESS; }