📄 target.c
字号:
/****************************************Copyright (c)**************************************************
** 北京东方信联
** 石家庄东方信联通信研究所
** 直放站外挂监控
** http://www.telestone.com
**--------------文件信息--------------------------------------------------------------------------------
**文 件 名: tatget.c
**最后修改日期: 2007年08月15日
**最后的版本号: V1.0
**描 述: 目标板初始化
**--------------历史版本信息----------------------------------------------------------------------------
** 创建人: 崔敬军
** 版 本: V1.0
** 日 期: 2007年08月15日
** 描 述: 原始版本
**
**------------------------------------------------------------------------------------------------------
**--------------当前版本修订----------------------------------------------------------------------------
** 修改人:
** 日 期:
** 描 述:
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#define IN_TARGET
#include "config.h"
extern struct UART uart[SYS_COM_NUM];
/*********************************************************************************************************
** 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: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void IRQ_Exception(void)
{
}
/*********************************************************************************************************
** 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: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void FIQ_Exception(void)
{
}
/*********************************************************************************************************
** Function name: Timer0_Exception
**
** Descriptions: Timer0 interrupt service function
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer0_Exception(void)
{
T0IR = 0x01; // 清除中断标志
VICVectAddr = 0; // interrupt close 通知中断控制器中断结束
OSTimeTick(); // OS心跳,10ms一个tick
}
/*********************************************************************************************************
** Function name: Timer1_Exception
**
** Descriptions: Timer1 interrupt service function
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer1_Exception(void)
{
T1IR = 0x01; // 清除中断标志
VICVectAddr = 0; // interrupt close 通知中断控制器中断结束
}
/*********************************************************************************************************
** Function name: Timer0Init
**
** Descriptions: Initialize the Time0
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer0Init(void)
{
T0IR = 0xffffffff;
T0TC = 0; // 定时器设置为0
T0TCR = 0x01; // 启动定时器
T0MCR = 0x03; // 设置T0MR0匹配后复位T0TC,并产生中断标志
T0MR0 = (Fpclk / OS_TICKS_PER_SEC); // 10ms中断一次
}
/*********************************************************************************************************
** Function name: Timer1Init
**
** Descriptions: Initialize the Time1
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Timer1Init(void)
{
T1IR = 0xffffffff; // 清除全部匹配中断和捕获中断
T1TC = 0; // 清除T1定时器计数器
T1TCR = 0x01; // T1计数器使能
T1MCR = 0x03; // 设置T1MR0匹配后复位T1TC,并产生中断标志
T1MR0 = (Fpclk / OS_TICKS_PER_SEC); // 10ms中断一次
}
/*********************************************************************************************************
** Function name: Uart0_Exception
**
** Descriptions: Uart0 interrupt service function
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Uart0_Exception(void)
{
uint8 IIR;
uint32 temp;
while(((IIR=U0IIR)&0x01)==0)
{
switch(IIR&0x0e)
{
case 0x02://THRE中断
if(uart[0].sendend!=uart[0].sendhead)
{
U0THR=uart[0].send[uart[0].sendend++];
uart[0].sendend=(uart[0].sendend%UART_FIFO_SIZE);
}
break;
case 0x04://接受数据可用
if((uart[0].rechead+1)!=uart[0].recend)
{
uart[0].rec[uart[0].rechead++]=U0RBR;
uart[0].rechead=(uart[0].rechead%UART_FIFO_SIZE);
}
temp=U0RBR;
break;
case 0x06://RX线状态
temp=U0LSR;//清楚中断标志
break;
case 0x0c://字符超时中断
temp=U0RBR;
break;
default:
break;
}
}
VICVectAddr=0x00;
}
/*********************************************************************************************************
** Function name: Uart1_Exception
**
** Descriptions: Uart1 interrupt service function
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Uart1_Exception(void)
{
uint8 IIR;
uint32 temp;
while(((IIR=U1IIR)&0x01)==0)
{
switch(IIR&0x0e)
{
case 0x02://THRE中断
if(uart[1].sendend!=uart[1].sendhead)
{
U1THR=uart[1].send[uart[1].sendend++];
uart[1].sendend=(uart[1].sendend%UART_FIFO_SIZE);
}
break;
case 0x04://接受数据可用
if((uart[1].rechead+1)!=uart[1].recend)
{
uart[1].rec[uart[1].rechead++]=U1RBR;
uart[1].rechead=(uart[1].rechead%UART_FIFO_SIZE);
}
temp=U1RBR;
break;
case 0x06://RX线状态
temp=U1LSR;//清楚中断标志
break;
case 0x0c://字符超时中断
temp=U1RBR;
break;
default:
break;
}
}
VICVectAddr=0x00;
}
/*********************************************************************************************************
** Function name: VICInit
**
** Descriptions: Initialize the Interrupt Vevtor Controller
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: cuijingjun
** Created Date: 2007/08/15
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void VICInit(void)
{
extern void IRQ_Handler(void);
extern void Timer0_Handler(void);
extern void Timer1_Handler(void);
extern void Uart1_Handler(void);
extern void Uart0_Handler(void);
extern void I2c_Handler(void);
VICIntEnClr = 0xffffffff; // 禁止所有中断
VICDefVectAddr = (uint32)IRQ_Handler;
// 设置定时器0中断IRQ
VICVectAddr0 = (uint32)Timer0_Handler;
VICVectCntl0 = (0x20 | 0x04);
VICIntEnable = (1 << 0x04);
// 设置定时器1中断IRQ
VICVectAddr1 = (uint32)Timer1_Handler; // 设置中断服务程序地址
VICVectCntl1 = (0x20|0x05); // 设置定时器1中断通道分配最高优先级
VICIntEnable = (1 << 0x05); // 使能定时器1中断
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -