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

📄 target.c

📁 SmartARM2400系列开发板全套资料
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************Copyright (c)****************************************************
**                         Guangzhou ZHIYUAN electronics Co.,LTD.                               
**                                     
**                               http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name:           target.c
** Last modified Date:  2004-09-17
** Last Version:        1.0
** Descriptions:        header file of the specific codes for LPC2200 target boards
**                      Every project should include a copy of this file, user may modify it as needed
**--------------------------------------------------------------------------------------------------------
** Created by:          Chenmingji
** Created date:        2004-02-02
** Version:             1.0
** Descriptions:        The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:         Chenmingji
** Modified date:       2004-09-17
** Version:             1.01
** Descriptions:        Renewed the template, added more compiler supports
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#define IN_TARGET
#include "config.h"

extern OS_EVENT *Sem1;               /* 信号量1 */
/*********************************************************************************************************
** Function name:			Timer1_Exception
**
** Descriptions:			Timer1 interrupt service function
**
** input parameters:		None
** Returned value:			None
**         
** Used global variables:	None
** Calling modules:			None
**
** Created by:				Chenmingji
** Created Date:			2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer1_Exception(void)
{
	T1IR = 0x01;
    VICVectAddr = 0;            //interrupt close 通知中断控制器中断结束
    OSSemPost(Sem1);
}

/*********************************************************************************************************
* Function name:       sysDelayNS
* Descriptions:        长软件延时
* input parameters:    idly	延时参数,值越大,延时越久
* output parameters:   none
* Returned value:      none
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void  sysDelayNS(INT32U  uiDly)
{  
    INT32U  i;
    for(; uiDly > 0; uiDly--){
        for(i = 0; i < 5000; i++);
    }
}

/*********************************************************************************************************
** Function name:           Timer0_Exception
**
** Descriptions:            Timer0 interrupt service function
**
** input parameters:        None
** output parameters:       None
** Returned value:          None
**
** Created by:              Chenmingji
** Created Date:            2004/02/02
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void Timer0_Exception (void)
{
    T0IR = 0x01;
    VICVectAddr = 0;                                                    /*  通知中断控制器中断结束      */
    OSTimeTick();
}

/*********************************************************************************************************
** Function name:           Timer0Init
**
** Descriptions:            Initialize the Time0
**
** input parameters:        None
** output parameters:       None
** Returned value:          None
**
** Created by:              Chenmingji
** Created Date:            2004/02/02
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void Timer0Init (void)
{
    T0IR = 0xffffffff;
    T0TCR = 0x03;
    T0TC = 0;
    T0MCR = 0x03;
    T0MR0 = (Fpclk / OS_TICKS_PER_SEC);
    T0TCR = 0x01;
    vicIrqFuncSet(4,0,(INT32U)Timer0_Exception);
 }
 
/*********************************************************************************************************
** Function name:			Timer0Init
**
** Descriptions:			Initialize the Time0
**
** input parameters:		None
** Returned value:			None
**         
** Used global variables:	None
** Calling modules:			None
**
** Created by:				Chenmingji
** Created Date:			2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer1Init(void)
{
    T1CTCR = 0x00;                  //timer0 work in timer mode
    T1TCR = 0x02;					//stop timer0
    T1IR = 0xffffffff;		        //Clean all timer0 interrupt flag
    T1TC = 0;
    T1MCR = 0x03;
    T1MR0 = Fpclk * 2;
    T1TCR = 0x01;
 }
 
/*********************************************************************************************************
** Function name:			VICInit
**
** Descriptions:			Initialize the Interrupt Vevtor Controller
**
** input parameters:		None
** Returned value:			None
**         
** Used global variables:	None
** Calling modules:			None
**
** Created by:				Chenmingji
** Created Date:			2004/02/02
**-------------------------------------------------------------------------------------------------------
** Modified by:				LinEnqiang
** Modified date:			2007/05/15
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void VICInit(void)
{
	 while(!(SetVICIRQ(4,0,(uint32)Timer0_Exception)));
	 while(!(SetVICIRQ(5,1,(uint32)Timer1_Exception)));		
}

/*********************************************************************************************************
** Function name:           TargetInit
**
** Descriptions:            Initialize the target board; it is called in a necessary place, change it as
**                          needed
**
** input parameters:        None
** output parameters:       None
** Returned value:          None
**
** Created by:              Chenmingji
** Created Date:            2004/02/02
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void TargetInit (void)
{
   OS_ENTER_CRITICAL();
   srand((INT32U) TargetInit);    
   VICInit();
   Timer0Init();
   Timer1Init();
   OS_EXIT_CRITICAL();
}
/*********************************************************************************************************
** Function name:     SDRAMInit
** Descriptions:      初始化SDRAM
** input parameters:  none
** output parameters: none
**
** Created by:		  zhangzheng
** Created Date:	  2007.12.10
**-------------------------------------------------------------------------------------------------------
** Modified by:		  zhanghuping		
** Modified date:	  2008.04.25		
**-------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void  SDRAMInit( void )
{  
    uint32 i, dummy ;
    /* 
    * 使能SDRAM总线连接 
    */
    PINSEL4    = 0x50000000;
    PINSEL5    = 0x05050555;
    PINSEL6   |= 0x55555555;
    PINSEL8   |= 0x55555555;
    PINSEL9   |= 0x50555555;
    EMCControl = 0x00000001;		                                    /* Disable Address mirror       */
 
    /* 
     * 设置SDRAM访问时序. 
     */
    EMCDynamictRP   = 1;        
    EMCDynamictRAS  = 3;		
    EMCDynamictSREX = 1;		
    EMCDynamictAPR  = 1;		
    EMCDynamictDAL  = 5;		
    EMCDynamictWR   = 2;		
    EMCDynamictRC   = 3;		

⌨️ 快捷键说明

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