📄 os_viewc.c
字号:
void OSView_InitTarget (void)
{
extern void OSView_RxTxISRHandler(void); //调用汇编宏 名字要改
OSView_TmrCntsPrev = 0L;
InitUart0(OS_VIEW_BAUDRATE);
VICVectAddr14 = (INT32U)OSView_RxTxISRHandler; //让OS管理中断调用
VICVectCntl14 = (0x20 | 0x06);
VICIntEnable = 1 << 6;
//OSView_RxIntEn(); /* Enable Rx interrupts */
}
/*$PAGE*/
/*
*********************************************************************************************************
* DISABLE RX INTERRUPTS
*
* Description : This function disables Rx interrupts.
*********************************************************************************************************
*/
void OSView_RxIntDis (void)
{
#if 1
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
U0IER &= 0xFE; //关接收中断
OS_EXIT_CRITICAL();
#endif
}
/*
*********************************************************************************************************
* ENABLE RX INTERRUPTS
*
* Description : This function enables the Rx interrupt.
*********************************************************************************************************
*/
void OSView_RxIntEn (void)
{
#if 1
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
U0IER |= 0x01; //使能接收中断
OS_EXIT_CRITICAL();
#endif
}
/*
*********************************************************************************************************
* Rx Communication handler for uC/OS-View
* (NOT USED for PC since OSView_RxTxHandler() handles this)
*********************************************************************************************************
*/
void OSView_RxISRHandler (void)
{
}
/*
*********************************************************************************************************
* Update 32-bits cycles counter
*
* Description: This function must be called by OSTimeTickHook() and is used to maintain a 32 bit counter
* of clock cycles.
*
* On the PC, Timer #2 is used but, Timer #2 is only a 16-bit counter. In order to get a
* 32-bit value, this function must be called at every tick which is assumed to be every
* 5 mS (200 Hz) on the PC. This function basically samples the current value of timer #2
* in order to avoid having to keep track of overflows.
* Timer #2 is feed by a 1,193,180 Hz clock source and thus, Timer #2 rolls over every
* 54.925 milliseconds.
*
* Returns : None
*
* Note(s) : Changes the global variable OSViewCyclesCtr
*********************************************************************************************************
*/
void OSView_TickHook (void)
{
INT32U cnts32;
INT32U delta;
cnts32 = OSView_TmrRd();
delta = cnts32 - OSView_TmrCntsPrev;
OSView_CyclesCtr += delta;
}
/*$PAGE*/
/*
*********************************************************************************************************
* Get time [cycles]
*
* Description: This routine is required for task execution time measurement. This function needs to
* return time as accurately as possible and in a 32-bit variable.
*
* On the PC, the cycles counter is actually updated by the tick ISR (see OSView_TickHook()).
* Because of this, this function only needs to return the value of the global counter
* OSView_CyclesCtr.
*
* Returns : A 32-bit representation of time.
*********************************************************************************************************
*/
INT32U OSView_TimeGetCycles (void)
{
INT32U cycles;
//OS_ENTER_CRITICAL();
cycles = OSView_CyclesCtr;
//OS_EXIT_CRITICAL();
return (cycles);
}
/*$PAGE*/
/*
*********************************************************************************************************
* Communication for uC/OS-View
*
* Description: Send 1 character to COM Port
*
* Note(s) : 1) Assumes UART #0
*********************************************************************************************************
*/
void OSView_Tx1 (INT8U c)
{
while((U0LSR & 0x00000020) == 0);
U0THR = c;
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntDis (void)
{
#if 1
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
U0IER &= 0xFD; //关发送中断
OS_EXIT_CRITICAL();
#endif
}
/*
*********************************************************************************************************
* Enable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntEn (void)
{
#if 1
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
U0IER |= 0x02; //开发送中断
OS_EXIT_CRITICAL();
#endif
}
/*$PAGE*/
/*
*********************************************************************************************************
* Tx Communication handler for uC/OS-View
* (NOT USED for PC since OSView_RxTxHandler() handles this)
*********************************************************************************************************
*/
void OSView_RxTxISR_Exception(void)
{
volatile INT8U IIR;
volatile INT8U temp;
OS_ENTER_CRITICAL();
while(((IIR = U0IIR) & 0x01) == 0)
{ // 有中断未处理完
switch (IIR & 0x0e)
{
case 0x02: // THRE中断
OSView_TxCtr++;
OSView_TxHandler();
break;
case 0x06: // 接收线状态
temp = U0LSR;
break;
case 0x04:
case 0x0c: // 字符超时指示
while ((temp = U0LSR) & 0x01)
{
OSView_RxCtr++;
temp = U0RBR; //Read A Char
OSView_RxHandler(temp);
}
break;
default :
break;
}
}
VICVectAddr = 0; // 通知中断控制器中断结束
OS_EXIT_CRITICAL();
}
void OSView_TxISRHandler (void)
{
}
#if OS_VIEW_MODULE > 0
void OSView_TmrInit (void)
{
}
#endif
#if OS_VIEW_MODULE > 0
INT32U OSView_TmrRd (void)
{
return ((INT32U)T0TC);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -