📄 os_viewc.c
字号:
/*
*********************************************************************************************************
* uC/OS-View
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
* NXP LPC2000 (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() / 1000000L);
(void)OS_StrCopy(s, "NXP LPC2378 (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().
* 2) The peripheral clock divider is set to 4 under the initialization for the specific
* UART. A divider of 4 is assumed during general purpose initialization when the baud rate
* divider is calculated.
*********************************************************************************************************
*/
void OSView_InitTarget (INT32U baud_rate)
{
INT16U div; /* Baud rate divisor */
INT8U divlo;
INT8U divhi;
INT8U lcr; /* Line Control Register */
INT32U pinsel;
INT32U pClkFreq;
INT32U cClkFreq;
#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 */
cClkFreq = BSP_CPU_ClkFreq(); /* Get the CPU clock frequency */
pClkFreq = cClkFreq / 4; /* Determine the peripheral clock frequency, see Note 2) */
div = (INT16U)(((2 * pClkFreq / 16 / baud_rate) + 1) / 2);
divlo = div & 0x00FF; /* Split divisor into LOW and HIGH bytes */
divhi = (div >> 8) & 0x00FF;
lcr = 0x03; /* 8 Bits, 1 Stop, No Parity */
#if OS_VIEW_COMM_SEL == OS_VIEW_UART_0
OS_ENTER_CRITICAL();
PCLKSEL0 &= ~(3 << 6); /* Clear the UART 0 clock divider bits such that div = 4 */
pinsel = PINSEL0; /* Enable UART0 I/Os */
pinsel &= 0xFFFFFF0F;
pinsel |= 0x00000050;
PINSEL0 = pinsel;
U0LCR = BIT7; /* Set divisor access bit */
U0DLL = divlo; /* Load divisor */
U0DLM = divhi;
U0LCR = lcr; /* Set line control register (Bit 8 is 0) */
U0IER = 0x00; /* Disable both Rx and Tx interrupts */
U0FCR = 0x01; /* Enable FIFO, flush Rx & Tx */
OS_EXIT_CRITICAL();
/* VIC UART #0 Initialization */
VICIntSelect &= ~(1 << VIC_UART0); /* Enable interrupts */
VICVectAddr6 = (INT32U)OSView_RxTxISRHandler; /* Set the vector address */
VICIntEnable = (1 << VIC_UART0); /* Enable Interrupts */
#endif
#if OS_VIEW_COMM_SEL == OS_VIEW_UART_1
OS_ENTER_CRITICAL();
PCLKSEL0 &= ~(3 << 8); /* Clear the UART 1 clock divider bits such that div = 4 */
pinsel = PINSEL0; /* Enable UART1 I/Os */
pinsel &= 0x3FFFFFFF;
pinsel |= 0x40000000;
PINSEL0 = pinsel;
pinsel = PINSEL1; /* Enable UART1 I/Os */
pinsel &= 0xFFFFFFFC;
pinsel |= 0x00000001;
PINSEL1 = pinsel;
U1LCR = BIT7; /* Set divisor access bit */
U1DLL = divlo; /* Load divisor */
U1DLM = divhi;
U1LCR = lcr; /* Set line control register (Bit 8 is 0) */
U1IER = 0x00; /* Disable both Rx and Tx interrupts */
U1FCR = 0x01; /* Enable FIFO, flush Rx & Tx */
OS_EXIT_CRITICAL();
/* VIC UART #1 Initialization */
VICIntSelect &= ~(1 << VIC_UART1); /* Enable interrupts */
VICVectAddr7 = (INT32U)OSView_RxTxISRHandler; /* Set the vector address */
VICIntEnable = (1 << VIC_UART1); /* Enable Interrupts */
#endif
}
/*$PAGE*/
/*
*********************************************************************************************************
* Disable Rx Interrupts
*********************************************************************************************************
*/
void OSView_RxIntDis (void)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -