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

📄 target.c

📁 在51上运行的小的OS系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.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 LPC2100 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"
//#include "..\src\user_config.h"


/*********************************************************************************************************
** Function name:            IRQ_Exception
**
** Descriptions:            interrupt exceptional handler , change it as needed
**
** 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 IRQ_Exception(void)
{
    while(1);                   // change it to your code  这一句替换为自己的代码
}

/*********************************************************************************************************
** Function name:            FIQ_Exception
**
** Descriptions:            Fast interrupt exceptional handler , change it as needed
**
** 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 FIQ_Exception(void)
{
    while(1);                   // change it to your code  这一句替换为自己的代码
}
/*********************************************************************************************************
** Function name:            Timer0_Exception
**
** Descriptions:            Timer0 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 Timer0_Exception(void)
{
    T0IR = 0x01;
    VICVectAddr = 0;            //interrupt close 通知中断控制器中断结束
    OSTimeTick();
}

/*********************************************************************************************************
** 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 Timer0Init(void)
{
    T0IR = 0xffffffff;
    T0TC = 0;
    T0TCR = 0x01;
    T0MCR = 0x03;
    T0MR0 = (Fpclk / OS_TICKS_PER_SEC);
 }
/*********************************************************************************************************
** 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:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
        void VICInit(void)
{
    extern void IRQ_Handler(void);
    extern void Timer0_Handler(void);
     extern void UART0_Handler(void);
    extern void I2C0_Handler(void);
    extern void SPI0_Handler(void);
    extern void EInt2_Handler(void);
    extern void Timer1_Handler(void);
    extern void SPI1_Handler(void);

    VICIntEnClr = 0xffffffff;
    VICDefVectAddr = (uint32)IRQ_Handler;

    VICVectAddr0 = (uint32)Timer0_Handler;
    VICVectCntl0 = (0x20 | 0x04);
    VICIntEnable = 1 << 4;

    VICVectCntl1 = 0x26;
    VICVectAddr1 = (uint32)UART0_Handler;
 /////    VICIntEnable=1<<0x06;        //    使能UART0中断
    
    VICVectCntl2=(0x20|0x09);//I2C 通道分配到IRQ Slot2
    //VICVectAddr2=(uint32)IRQ_I2C;//设置I2C中断向量
    VICVectAddr2 = (uint32)I2C0_Handler;
    VICIntEnable=(1<<9);//使能I2C中断
    
    VICVectCntl3 = (0x20 | 10);//SPI
    VICVectAddr3 = (uint32)SPI0_Handler;//
    
    VICVectCntl4 = (0x20|16);
    VICVectAddr4 = (uint32) EInt2_Handler;
    EXTPOLAR = 0;
    EXTMODE = 4;
    EXTINT = 4;
 /////    VICIntEnable = 1<<16;//外部中断2
    
    VICVectCntl5 = (0x20 | 5);
    VICVectAddr5 = (uint32) Timer1_Handler;
    T1TCR = 1;
////    VICIntEnable = 1 << 5;
    
    S0PINT = 1;//
////     VICIntEnable = (1 << 10);//

    SSPIMSC = 0;//DisableSPI1Interrupt();
    VICVectCntl6 = (0x20 | 11);
    VICVectAddr6 = (uint32) SPI1_Handler;
//    VICIntEnable = 1 << 11;

 }

/*********************************************************************************************************
** Function name:            TargetInit
**
** Descriptions:            Initialize the target board; it is called in a necessary place, change it as 
**                            needed
**
** 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 TargetInit(void)
{
    OS_ENTER_CRITICAL();
    PINSEL0 = 0;//0x00005555 //| (3<<14);        //设置管脚连接GPIO
              //  | (2<<18); //PWM6
    PINSEL1 = (2<<2)|(2<<6)|(2<<8)|(1<<10);        //PWM5
    IO0DIR  = 0xFFFFFFF0;            //方向控制位,0输入,1输出
    PINSEL2&=~(1<<3);
    IO1DIR=(1 << 16) | (1 << 17) | (1 << 18) | (1 << 19) | (1 << 20) | (1 << 21) | (1 << 22) | (1 << 23) | (1 << 24) | (1 << 25);
    VICInit();
    Timer0Init();    
    OS_EXIT_CRITICAL();
}
/*********************************************************************************************************
** Function name:            InitialiseUART0
**
** Descriptions:            Initialize the Uart0
**
** input parameters:        None
** Returned value:            None
**         
** Used global variables:    None
** Calling modules:            None
**

⌨️ 快捷键说明

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