📄 main.c
字号:
/*=============================================================================
=
= Name: QVGA Display and Timer Verification and Example Code
=
===============================================================================
=
= (C) Copyright 2006 - Analog Devices, Inc. All rights reserved.
=
= File Name : main.c
=
= Date : 12/21/06
=
= Target : ADSP-BF537
=
= Version : 1.0
=
= Purpose : Test the display with a bitmap
=
=
=
==============================================================================*/
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
#include <setjmp.h>
#include <services/services.h>
#include "debug.h"
#include "timers.h"
#include "lcd.h"
#include "ezkitsettings.h"
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
// Blackfin specific datas for interrupt, dma and device management
#define MAX_NB_DMA_CHANNEL 6
#define MAX_NB_DEVICE 4
#define MAX_NB_DCB_QUEUE 1
#define MAX_NB_DCB_CALLBACK 16
// Programmable Flag service
u8 FlagServiceData [ADI_FLAG_CALLBACK_MEMORY * 1];
// Interrupt Manager (base memory + memory for secondary interrupt handlers)
u8 IntManagerData[0 + (ADI_INT_SECONDARY_MEMORY * 4)];
// DMA Manager data (base memory + memory for MAX_NB_DMA_CHANNEL DMA channels)
u8 DMAManagerData[ADI_DMA_BASE_MEMORY + (ADI_DMA_CHANNEL_MEMORY * MAX_NB_DMA_CHANNEL)];
// Device Manager data (base memory + memory for MAX_NB_DEVICE devices)
u8 DeviceManagerData[ADI_DEV_BASE_MEMORY + (ADI_DEV_DEVICE_MEMORY * MAX_NB_DEVICE)];
// Deferred Callback Manager data (base memory + memory for MAX_NB_QUEUE queue servers
u8 DeferredCallbackManagerData[0 + (ADI_DCB_QUEUE_SIZE * MAX_NB_DCB_QUEUE)];
// Deferred Callback Queue data (memory for MAX_NB_CALLBACK posted callbacks per queue)
u8 DeferredCallbackQueueData[ADI_DCB_ENTRY_SIZE * MAX_NB_DCB_CALLBACK];
// handle to the callback service
ADI_DCB_HANDLE DeferredCallbackManagerHandle;
// handle to the DMA Manager
ADI_DMA_MANAGER_HANDLE DMAManagerHandle;
// handle to the Device Manager
ADI_DEV_MANAGER_HANDLE DeviceManagerHandle;
volatile u32 BF537_EZKIT_idle = TRUE;
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
// Exceptions raised here are caught in main()
extern jmp_buf CatchContext;
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
// Function: ExceptionHandler
// HWErrorHandler
//
// Description: We should never get an exception or hardware error,
// but just in case we'll catch them should one ever occur.
static ADI_INT_HANDLER(ExceptionHandler) // exception handler
{
BF537_EZKIT_Throw ("ExceptionHandler error\n");
return (ADI_INT_RESULT_PROCESSED);
}
static ADI_INT_HANDLER(HWErrorHandler) // hardware error handler
{
BF537_EZKIT_Throw ("HWErrorHandler error\n");
return (ADI_INT_RESULT_PROCESSED);
}
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
int main (int argc, char** argv)
{
//----------------------------------------------------------
int ret;
unsigned long response;
//----------------------------------------------------------
// Catch exceptions raised by BF537_EZKIT_Throw()
int e = setjmp (CatchContext);
if (e)
return e;
//----------------------------------------------------------
// initialize SDRAM
if (InitSDRAM () != ADI_INT_RESULT_SUCCESS)
BF537_EZKIT_Throw ("ConfigSDRAM error\n");
//----------------------------------------------------------
// initialize PLL
if (InitPower () != ADI_INT_RESULT_SUCCESS)
BF537_EZKIT_Throw ("ConfigPower error\n");
//----------------------------------------------------------
// initialize EBIU SRAM
ConfigureAsync ();
//----------------------------------------------------------
// initialize the Interrupt Manager
ret = adi_int_Init (IntManagerData, sizeof(IntManagerData), &response, NULL);
if (ret != 0)
BF537_EZKIT_Throw("adi_int_Init error\n");
// hook the exception interrupt
if(adi_int_CECHook(3, ExceptionHandler, NULL, FALSE) != ADI_INT_RESULT_SUCCESS)
BF537_EZKIT_Throw("adi_int_CECHook_ExceptionHandler error\n");
// hook the hardware error
if(adi_int_CECHook(5, HWErrorHandler, NULL, FALSE) != ADI_INT_RESULT_SUCCESS)
BF537_EZKIT_Throw("adi_int_CECHook_HWErrorHandler error\n");
//------------------------------------------------------------------------
// initialize the DMA Manager
ret = adi_dma_Init(DMAManagerData, sizeof(DMAManagerData), &response, &DMAManagerHandle, NULL);
if ((ret != 0) || (response != MAX_NB_DMA_CHANNEL))
BF537_EZKIT_Throw("adi_dma_Init error\n");
//------------------------------------------------------------------------
// initialize the Device Manager
ret = adi_dev_Init(DeviceManagerData, sizeof(DeviceManagerData), &response, &DeviceManagerHandle, NULL);
if ((ret != 0) || (response != MAX_NB_DEVICE))
BF537_EZKIT_Throw("adi_dev_Init error\n");
//------------------------------------------------------------------------
// initialize the Deferred Callback Manager and setup a queue
ret = adi_dcb_Init(&DeferredCallbackManagerData, sizeof(DeferredCallbackManagerData), &response, NULL);
if ((ret != 0) || (response != MAX_NB_DCB_QUEUE))
BF537_EZKIT_Throw("adi_dcb_Init error\n");
ret = adi_dcb_Open(14, &DeferredCallbackQueueData, sizeof(DeferredCallbackQueueData), &response, &DeferredCallbackManagerHandle);
if ((ret != 0) || (response != MAX_NB_DCB_CALLBACK))
BF537_EZKIT_Throw("adi_dcb_Open error\n");
//------------------------------------------------------------------------
// Initialize the timer services
InitTimers ();
//------------------------------------------------------------------------
// Initialize the timer services
ret = adi_flag_Init (FlagServiceData, sizeof(FlagServiceData), &response, NULL);
if (ret != 0)
BF537_EZKIT_Throw("adi_flag_Init error\n");
//------------------------------------------------------------------------
// Open the LCD interface
OpenLCD (DeviceManagerHandle, DMAManagerHandle, DeferredCallbackManagerHandle);
// Start sending data to the LCD
StartLCD ();
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
while (BF537_EZKIT_idle);
CloseLCD ();
adi_flag_Terminate ();
CloseTimers ();
return 0;
//----------------------------------------------------------
}
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -