?? os_viewc.c
字號:
/*
*********************************************************************************************************
* uC/OS-View
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
* NXP LPC2888 (ARM7)
* IAR C Compiler
*
*
* Filename : os_viewc.c
* Version : V1.20
* Programmer : Jean J. Labrosse
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80
/*$PAGE*/
/*
*********************************************************************************************************
* EXIT uC/OS-View
*
* Description: This function is called if your target needs to 'uninstall' uC/OS-View.
*
* Note(s) :
*********************************************************************************************************
*/
void OSView_Exit (void)
{
}
/*
*********************************************************************************************************
* Obtain CPU name
*********************************************************************************************************
*/
void OSView_GetCPUName (INT8U *s)
{
INT8U cpu_clk_freq;
cpu_clk_freq = (INT8U)(BSP_CPU_ClkFreq() / 1000);
(void)OS_StrCopy(s, "NXP LPC2888 (xx MHz)");
s[13] = cpu_clk_freq / 10 + '0';
s[14] = cpu_clk_freq % 10 + '0';
}
/*
*********************************************************************************************************
* Obtain Interrupt Stack information
*********************************************************************************************************
*/
INT32U OSView_GetIntStkBase (void)
{
return (0); /* We are not using an ISR stack */
}
INT32U OSView_GetIntStkSize (void)
{
return (0); /* We are not using an ISR stack */
}
/*$PAGE*/
/*
*********************************************************************************************************
* INITIALISE uC/OS-View COM PORT
*
* Description: Initialize the hardware required for the OS to run. This will work on any target hardware,
* but may have to be tailored a little (regarding the clock frequency). Of course the same
* holds true if for some reason you choose to use another timer.
*
* Note(s) : 1) This function assumes that a free running timer has been initialized. The timer can
* either be a 16 bits or 32 bits timer. Your application needs to provide a function
* called OSView_TmrRd() that reads the current counts of this timer. The free running
* timer is initialized by the BSP function OSView_TmrInit().
*********************************************************************************************************
*/
void OSView_InitTarget (INT32U baud_rate)
{
INT16U div; /* Baud rate divisor */
INT8U divlo;
INT8U divhi;
INT8U lcr; /* Line Control Register */
INT32U clk_freq;
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
OSView_TmrInit(); /* Initialize the free running timer */
/* Compute divisor for desired baud rate */
clk_freq = BSP_CPU_ClkFreq() * 1000; /* Convert KHz to Hz */
div = (INT16U)(clk_freq/(16 * baud_rate));
divlo = div & 0x00FF; /* Split divisor into LOW and HIGH bytes */
divhi = (div >> 8) & 0x00FF;
lcr = 0x03; /* 8 Bits, 1 Stop, No Parity */
OS_ENTER_CRITICAL();
LCR = BIT7; /* Set divisor access bit */
DLL = divlo; /* Load divisor */
DLM = divhi;
LCR = lcr; /* Set line control register */
IER = 0x00; /* Disable both Rx and Tx interrupts */
FCR = 0x05; /* Enable FIFO, flush Rx & Tx ** */
OS_EXIT_CRITICAL();
/* VIC UART #0 Initialization */
OSView_IntInit(); /* Store handler location in VIC table */
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Rx Interrupts
*********************************************************************************************************
*/
void OSView_RxIntDis (void)
{
IER = 0;
}
/*
*********************************************************************************************************
* Enable Rx Interrupts
*********************************************************************************************************
*/
void OSView_RxIntEn (void)
{
IER = BIT0;
}
/*
*********************************************************************************************************
* Rx Communication handler for uC/OS-View
*
* Description: This function is called by OSView_RxISR (see OS_VIEWa.ASM) to process a received
* character interrupt.
*
* Note(s) : This adaptation of uC/OS-View assumes that a 'combined' interrupt is generated by the UART
* and thus this function is not needed.
*********************************************************************************************************
*/
void OSView_RxISRHandler (void)
{
}
/*
*********************************************************************************************************
* Rx/Tx Communication handler for uC/OS-View
*
* Description: This function is NOT called because the M16C has a separate Rx and Tx ISR.
*********************************************************************************************************
*/
void OSView_RxTxISRHandler (void)
{
volatile INT8U rx_data;
volatile INT8U lsr;
volatile INT8U iir;
iir = IIR & 0x0F;
while (iir != 1) {
switch (iir) {
case 0: /* Modem interrupt? */
break;
case 2: /* Transmitted character? */
OSView_TxHandler();
break;
case 4: /* Received a character? */
lsr = LSR;
rx_data = RBR;
OSView_RxHandler(rx_data); /* Call the generic Rx handler */
break;
case 6: /* Receive Line Status interrupt? */
break;
case 12: /* CTI interrupt? */
break;
}
iir = IIR & 0x0F;
}
}
/*$PAGE*/
/*
*********************************************************************************************************
* Communication for uC/OS-View
*
* Description: Send 1 character to COM Port
*********************************************************************************************************
*/
void OSView_Tx1 (INT8U c)
{
THR = c;
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntDis (void)
{
IER = BIT0; /* Just enable the receive interrupts */
}
/*
*********************************************************************************************************
* Enable Tx Interrupts
*********************************************************************************************************
*/
void OSView_TxIntEn (void)
{
IER = BIT1 | BIT0;
}
/*
*********************************************************************************************************
* Tx Communication handler for uC/OS-View
* (PORT SPECIFIC)
*
* Description: Handle transmission of a character
*
* Note(s) : 1) This function is called by OSView_RxISR (see OS_VIEWa.ASM)
* 2) This adaptation of uC/OS-View assumes that a 'combined' interrupt is generated by the
* UART and thus this function is not needed.
*********************************************************************************************************
*/
void OSView_TxISRHandler (void)
{
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -