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

📄 flagswithcallbacks.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 void Callback(void *ClientHandle, u32 Event, void *pArg); // callback function




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

	Function:		main

	Description:	Creates a callback when button 1 on the EZ-Kit
	                is pressed.  
	                
	                Flag mappings on the BF537 EZ-Kit:
	                     Buttons 1 thru 4 correspond to PF2 thru PF5
	                     LEDs 6 thru 10 correspond to PF6 thru PF11

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

void main()	
{

	ADI_FLAG_RESULT Result;
		
	//Initialize system services
	InitSystemServices();

	// open PF2, parameters are
	//      flag ID
	Result = adi_flag_Open(ADI_FLAG_PF2);
	
	// set direction to input, parameters are
	//      flag ID
	//      flag direction
	Result = adi_flag_SetDirection(ADI_FLAG_PF2, 
	                               ADI_FLAG_DIRECTION_INPUT);
	
	// install callback, parameters are
	//      flag ID
	//      flag interrupt ID
	//      trigger condition
	//      wakeup flag
	//      client handle
	//      deferred callback service handle (NULL = live callbacks)
	//      callback function
	Result = adi_flag_InstallCallback(ADI_FLAG_PF2, 
	                                  ADI_INT_PORTFG_A, 
	                                  ADI_FLAG_TRIGGER_RISING_EDGE, 
	                                  TRUE, 
	                                  (void*)0x12345678, 
	                                  NULL, 
	                                  Callback);
	
	// spin
	while(1);
}






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

	Function:		Callback

	Description:	Called whenever the flag triggers.
	                    ClientHandle = 0x12345678
	                    Event = Event ID that occurred
	                    pArg = Event specific parameter

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

void static Callback(void *ClientHandle, u32 Event, void *pArg){

	ADI_FLAG_ID FlagID;     // flag that triggered the callback
	
	// get the flag ID
	FlagID = (ADI_FLAG_ID)pArg;

}








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

	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                                 } 
	}; 

	static u8 FlagServiceData[ADI_FLAG_CALLBACK_MEMORY *  1];	// memory for 1 callback

    // 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 );

   	// initialize the flag manager, parameters are
   	//      pointer to memory for the flag service to use
   	//      memory size (in bytes)
   	//      location where the number of flags that can be supported will be stored
   	//      parameter for adi_int_EnterCriticalRegion (always NULL for VDK and standalone systems)
	Result = adi_flag_Init(FlagServiceData, 
	                       sizeof(FlagServiceData), 
	                       &i, 
	                       NULL);
	
}

⌨️ 快捷键说明

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