⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interrupts.c

📁 blackfin处理器系统代码,对dma,中断,标志位的设置都有很大的帮助.
💻 C
字号:
/*********************************************************************************

Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved. 

This software is proprietary and confidential.  By using this software you agree
to the terms of the associated Analog Devices License Agreement.  
			
*********************************************************************************/


/*********************************************************************

Include files

*********************************************************************/

#include <services/services.h>		// system service includes



/*********************************************************************

Function prototypes

*********************************************************************/

static void InitSystemServices(void);                          // system services initialization
static ADI_INT_HANDLER_RESULT RTC_Handler(void *ClientHandle); // RTC interrupt handler




/*********************************************************************

	Function:		main

	Description:	Installs an interrupt handler for the RTC and 
	                configures the RTC to generate an interrupt every
	                minute.

*********************************************************************/


void main()	
{

	ADI_INT_RESULT Result; 
	u32 IVG;
	
	// initialize the system services
	InitSystemServices();
	
	// set the prescaler, clear any pending interrupts and set to generate
	// an interrupt every minute
	*pRTC_PREN = 0x1;
	*pRTC_ISTAT = 0x3FFF;
	*pRTC_ICTL = 0x0008;
	
	// get the IVG level to which the RTC is mapped, parameters are
	//      interrupt ID
	//      address where the IVG level will be stored
	Result = adi_int_SICGetIVG(ADI_INT_RTC, 
	                           &IVG);
	
	// hook our handler into this IVG, parameters are
	//      IVG to hook into
	//      interrupt handler address
	//      client handle
	//      nesting enable flag
	Result = adi_int_CECHook(IVG, 
	                         RTC_Handler, 
	                         (void *)0x12345678, 
	                         FALSE);
	
	// enable RTC interrupts through the SIC, parameters are
	//      interrupt ID
	Result = adi_int_SICEnable(ADI_INT_RTC);

	while(1);
}



/*********************************************************************

	Function:		RTC Interrupt Handler

	Description:	Processes interrupts from the RTC
	                    ClientHandle - client handle that was supplied when hooked

*********************************************************************/

static ADI_INT_HANDLER_RESULT RTC_Handler(void *ClientHandle)
{
	
	// make sure it's an RTC interrupt, parameters are
	//      interrupt ID
	if (adi_int_SICInterruptAsserted(ADI_INT_RTC) != ADI_INT_RESULT_ASSERTED) {
		return (ADI_INT_RESULT_NOT_PROCESSED);
	}
		
	// clear Interrupt
	*pRTC_ISTAT = 0x0008;
	
	// return indicating that we processed the interrupt
	return (ADI_INT_RESULT_PROCESSED);		
	
}



/*********************************************************************

	Function:		InitSystemServices

	Description:	Initializes the necessary system services.  

*********************************************************************/

void InitSystemServices(void) {
    
    u32 i;
    u32 Result;

    ADI_EBIU_SDRAM_BANK_VALUE bank_size;
	ADI_EBIU_SDRAM_BANK_VALUE bank_width;
	u32                       cl_threshold = 100;                                        // set cl threshold to 100 Mhz
	ADI_EBIU_TIMING_VALUE     twrmin       = {1,{7500, ADI_EBIU_TIMING_UNIT_PICOSEC}};   // set min TWR to 1 SCLK cycle + 7.5ns	
	ADI_EBIU_TIMING_VALUE     refresh      = {8192,{64, ADI_EBIU_TIMING_UNIT_MILLISEC}}; // set refresh period to 8192 cycles in 64ms
	ADI_EBIU_TIME             trasmin      = {44, ADI_EBIU_TIMING_UNIT_NANOSEC};         // set min TRAS to 44ns
	ADI_EBIU_TIME             trpmin       = {20, ADI_EBIU_TIMING_UNIT_NANOSEC};	     // set min TRP to 20ns
	ADI_EBIU_TIME             trcdmin      = {20, ADI_EBIU_TIMING_UNIT_NANOSEC}; 	     // set min TRCD to 20ns
	bank_size.value.size                   = ADI_EBIU_SDRAM_BANK_64MB; 	                 // set bank size to 64MB
	bank_width.value.width                 = ADI_EBIU_SDRAM_BANK_COL_10BIT;	             // set column address width to 10-Bit

	ADI_EBIU_COMMAND_PAIR ezkit_sdram[] = { 
		{ ADI_EBIU_CMD_SET_SDRAM_BANK_SIZE,     (void*)&bank_size   },
       	{ ADI_EBIU_CMD_SET_SDRAM_BANK_COL_WIDTH,(void*)&bank_width  },
       	{ ADI_EBIU_CMD_SET_SDRAM_CL_THRESHOLD,  (void*)cl_threshold },
      	{ ADI_EBIU_CMD_SET_SDRAM_TRASMIN,       (void*)&trasmin     }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TRPMIN,        (void*)&trpmin      }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TRCDMIN,       (void*)&trcdmin     }, 
       	{ ADI_EBIU_CMD_SET_SDRAM_TWRMIN,        (void*)&twrmin      },
       	{ ADI_EBIU_CMD_SET_SDRAM_REFRESH,       (void*)&refresh     },
      	{ ADI_EBIU_CMD_END,                     0                   }
	};

	ADI_PWR_COMMAND_PAIR ezkit_power[] = { 
    	{ ADI_PWR_CMD_SET_PROC_VARIANT,(void*)ADI_PWR_PROC_BF537SKBC1600 }, // 600Mhz ADSP-BF533 variant 
    	{ ADI_PWR_CMD_SET_PACKAGE,     (void*)ADI_PWR_PACKAGE_MBGA       }, // in MBGA packaging, as on all EZ-KITS
    	{ ADI_PWR_CMD_SET_VDDEXT,      (void*)ADI_PWR_VDDEXT_330         }, // external voltage supplied to the voltage regulator is 3.3V
    	{ ADI_PWR_CMD_SET_CLKIN,       (void*)ADI_PWR_CLKIN_EZKIT_BF537  },	// the CLKIN frequency 25 Hz
    	{ ADI_PWR_CMD_END,             0                                 } 
	}; 


    // initialize the interrupt manager, parameters are
    //      pointer to memory for interrupt manager to use
    //      memory size (in bytes)
    //      location where the number of secondary handlers that can be supported will be stored
   	//      parameter for adi_int_EnterCriticalRegion (always NULL for VDK and standalone systems)
    Result = adi_int_Init(NULL, 
                          0, 
                          &i, 
                          NULL);
    
	// initialize the EBIU, parameters are
	//      address of table containing SDRAM parameters
	//      0 - always 0 when EBIU initialized before power service
	Result = adi_ebiu_Init(ezkit_sdram, 
	                       0);
	
    // initialize power, parameters are
    //      address of table containing processor information
    Result = adi_pwr_Init( ezkit_power );

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -