/*
*********************************************************************************************************
* 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_uart1InitTarget (INT32U baud_rate)
{
INT32U div;
INT8U divlo;
INT8U divhi;
INT32U pClkFreq;
INT32U cClkFreq;
/* 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 = (((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 */
// OS_ENTER_CRITICAL();
PCLKSEL0 &= ~(3 << 6); //外设时钟 /* Clear the UART 0 clock divider bits such that div = 4 */