//1bit stop, normal mode //----for UMR2----//
/** CAUTION!!! UMR1 and UMR2 share a common address,
** so it is a must to read or written when the mode register pointer points to it,
** which occurs after any access to UMR1. And UMR2 accesses do not update the pointer.
**/
MCF_UART_UMR(channel) |= (0
| MCF_UART_UMR_CM_NORMAL
| MCF_UART_UMR_SB_STOP_BITS_1);
void uart_putchar(uint8 channel, char c)
{
//Wait until space is available in the FIFO
while (!(MCF_UART_USR(channel) & MCF_UART_USR_TXRDY))
{;}
//Send the character
MCF_UART_UTB(channel) = (unsigned char) c;
}
unsigned char uart_getchar(uint8 channel)
{
//Wait until character has been received
while (!(MCF_UART_USR(channel) & MCF_UART_USR_RXRDY))
{;}
return MCF_UART_URB(channel);
}
/***********************
* 查询指定通道是否已经收到一个字符
* 未收到——————返回0
* 收 到——————返回1
************************/
int uart_getchar_present(uint8 channel)
{
return(MCF_UART_USR(channel) & MCF_UART_USR_RXRDY);
}