📄 videoecho.c
字号:
// turn on first LED
ezTurnOnLED(EZ_FIRST_LED);
// enable the video decoder (7183)
ezEnableVideoDecoder();
// give the decoder time to sync
ezDelay(300);
// since we're doing input, have the PPI driver generate a callback when the buffer
// has completed processing. The pArg parameter to the callback function will be
// whatever we set the CallbackParameter value to.
pBuffer2D->CallbackParameter = pBuffer2D;
// open the PPI driver for input
ezErrorCheck(adi_dev_Open(DeviceManagerHandle, &ADIPPIEntryPoint, DECODER_PPI, NULL, &DeviceHandle, ADI_DEV_DIRECTION_INBOUND, DMAManagerHandle, DCBManagerHandle, Callback));
// configure the PPI driver with the values from the inbound configuration table
ezErrorCheck(adi_dev_Control(DeviceHandle, ADI_DEV_CMD_TABLE, InboundConfigurationTable));
// give the PPI driver the buffer to process
ezErrorCheck(adi_dev_Read(DeviceHandle, ADI_DEV_2D, (ADI_DEV_BUFFER *)pBuffer2D));
// tell the PPI driver to enable data flow
ezErrorCheck(adi_dev_Control(DeviceHandle, ADI_DEV_CMD_SET_DATAFLOW, (void *)TRUE));
// wait till the buffer has been processed
while (pBuffer2D->ProcessedFlag == FALSE) ;
// close the PPI driver
ezErrorCheck(adi_dev_Close(DeviceHandle));
// turn off first LED
ezTurnOffLED(EZ_FIRST_LED);
// return
}
/*********************************************************************
Function: DisplayFrame
Description: This function is called to display a frame of video
data on the video-out device. The function first
enables the AD7171 video encoder and gives it time
to sync. As we're going to display the data for a
second or two, this function opens the PPI driver
using the chained with loopback mode. This will
cause the PPI driver to continuously send the buffer
out the PPI so that we can see the image. As a result
we don't need to be notified by a callback that the
buffer has been processed, so the buffer that is sent
to the PPI driver is modified to not generate a
callback. We then open the PPI driver and configured
according to the parameters in the configuration
table, and then dataflow is enabled. The function
spins for a while, allowing the data to be seen on
the video monitor, then closes down the PPI driver.
The last LED is lit when this function is executing.
*********************************************************************/
void DisplayFrame(
ADI_DCB_HANDLE DCBManagerHandle,
ADI_DMA_MANAGER_HANDLE DMAManagerHandle,
ADI_DEV_MANAGER_HANDLE DeviceManagerHandle,
ADI_DEV_2D_BUFFER *pBuffer2D
){
// table of configuration values for the PPI on output
ADI_DEV_CMD_VALUE_PAIR OutboundConfigurationTable [] = {
{ ADI_DEV_CMD_SET_DATAFLOW_METHOD, (void *)ADI_DEV_MODE_CHAINED_LOOPBACK },
{ ADI_PPI_CMD_SET_CONTROL_REG, (void *)0x0082 },
{ ADI_PPI_CMD_SET_LINES_PER_FRAME_REG, (void *)ADI_ITU656_NTSC_HEIGHT },
{ ADI_DEV_CMD_END, NULL },
};
ADI_DEV_DEVICE_HANDLE DeviceHandle; // handle to the device driver
// turn on last LED
ezTurnOnLED(EZ_LAST_LED);
// enable video encoder (7171)
ezEnableVideoEncoder();
// give the decoder time to sync
ezDelay(300);
// since we're doing output, don't generate any callbacks
pBuffer2D->CallbackParameter = NULL;
// open the PPI driver for output
ezErrorCheck(adi_dev_Open(DeviceManagerHandle, &ADIPPIEntryPoint, ENCODER_PPI, NULL, &DeviceHandle, ADI_DEV_DIRECTION_OUTBOUND, DMAManagerHandle, DCBManagerHandle, Callback));
// configure the PPI driver with the values from the outbound configuration table
ezErrorCheck(adi_dev_Control(DeviceHandle, ADI_DEV_CMD_TABLE, OutboundConfigurationTable));
// give the PPI driver the buffer to process
ezErrorCheck(adi_dev_Write(DeviceHandle, ADI_DEV_2D, (ADI_DEV_BUFFER *)pBuffer2D));
// tell the PPI driver to enable dataflow
ezErrorCheck(adi_dev_Control(DeviceHandle, ADI_DEV_CMD_SET_DATAFLOW, (void *)TRUE));
// delay for a while so we can see the image
ezDelay(3000);
// close the PPI driver
ezErrorCheck(adi_dev_Close(DeviceHandle));
// turn off last LED
ezTurnOffLED(EZ_LAST_LED);
// return
}
/*********************************************************************
Function: main
Description: This function is the starting point of the example.
It first calls the EZ-Kit utility functions to
initialize the asynchronous and flash memories on
the board, then makes sure all LEDs are off. The
Interrupt Manager is then initialized and the
exception and hardware error events are hooked. If
deferred callbacks are enabled by the macro at the
top of the file, the Deferred Callback Manager is
then initialized with one service, running at IVG 14,
being created. The DMA Manager and then the Device
Manager are then initialized. The function then
populates a buffer that is used for both PPI input
and PPI output. The buffer is configured to process
a standard NTSC 480i frame. The function then enters
a loop, continually calling the capture function to
capture a frame of data and then a display function
to transmit the frame to a display device.
Should the last pushbutton switch ever be pressed, the loop
will exit and close down the Device Manager, DMA
Manager and, if it was enabled, the Deferred Callback
Manager.
*********************************************************************/
void main(void) {
ADI_DCB_HANDLE DCBManagerHandle; // handle to the callback service
ADI_DMA_MANAGER_HANDLE DMAManagerHandle; // handle to the DMA Manager
ADI_DEV_MANAGER_HANDLE DeviceManagerHandle; // handle to the Device Manager
ADI_DEV_2D_BUFFER Buffer2D; // buffer to be sent to PPI Driver
u32 ResponseCount; // response counter
u32 fcclk, fsclk, fvco; // frequencies
// clear any pending hardware error (Si anomaly 04-00-0066, TAR 24983)
*((u32 *)ILAT) = 0x20;
// initialize the EZ-Kit
#if defined(__ADSPBF561__)
ezInit(2);
#else
ezInit(1);
#endif
//Initialize first / last LED and last button
ezInitLED(EZ_FIRST_LED);
ezInitLED(EZ_LAST_LED);
ezInitButton(EZ_LAST_BUTTON);
// turn off all LEDs
ezTurnOffAllLEDs();
// initialize the Interrupt Manager and hook the exception and hardware error interrupts
ezErrorCheck(adi_int_Init(InterruptManagerStorage, sizeof(InterruptManagerStorage), &ResponseCount, NULL));
ezErrorCheck(adi_int_CECHook(3, ExceptionHandler, NULL, FALSE));
ezErrorCheck(adi_int_CECHook(5, HWErrorHandler, NULL, FALSE));
// initialize the Deferred Callback Manager and setup a queue
#if defined(USE_DEFERRED_CALLBACKS)
ezErrorCheck(adi_dcb_Init(&DCBMgrData[0], ADI_DCB_QUEUE_SIZE, &ResponseCount, NULL));
ezErrorCheck(adi_dcb_Open(14, &DCBMgrData[ADI_DCB_QUEUE_SIZE], (ADI_DCB_ENTRY_SIZE)*4, &ResponseCount, &DCBManagerHandle));
#else
DCBManagerHandle = NULL;
#endif
// initialize the DMA Manager
ezErrorCheck(adi_dma_Init(DMAMgrData, sizeof(DMAMgrData), &ResponseCount, &DMAManagerHandle, NULL));
// initialize the Device Manager
ezErrorCheck(adi_dev_Init(DevMgrData, sizeof(DevMgrData), &ResponseCount, &DeviceManagerHandle, NULL));
// populate the buffer that we'll use for the PPI input and output
Buffer2D.Data = Frame;
Buffer2D.ElementWidth = 2;
Buffer2D.XCount = (ADI_ITU656_NTSC_LINE_WIDTH/2);
Buffer2D.XModify = 2;
Buffer2D.YCount = ADI_ITU656_NTSC_HEIGHT;
Buffer2D.YModify = 2;
Buffer2D.CallbackParameter = NULL;
Buffer2D.pNext = NULL;
// WHILE (the last pushbutton is not pressed)
while (ezIsButtonPushed(EZ_LAST_BUTTON) == FALSE) {
// capture a frame of video
CaptureFrame(DCBManagerHandle, DMAManagerHandle, DeviceManagerHandle, &Buffer2D);
// display the frame of video
DisplayFrame(DCBManagerHandle, DMAManagerHandle, DeviceManagerHandle, &Buffer2D);
// ENDLOOP
}
// close the Device Manager
ezErrorCheck(adi_dev_Terminate(DeviceManagerHandle));
// close down the DMA Manager
ezErrorCheck(adi_dma_Terminate(DMAManagerHandle));
// close down the Deferred Callback Manager
#if defined(USE_DEFERRED_CALLBACKS)
ezErrorCheck(adi_dcb_Terminate());
#endif
// return
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -