⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcf5xxx_uart.c

📁 飞思卡尔的MC5271的写flash软件。
💻 C
字号:
/*
 * File:        mcf5xxx_uart.c
 * Purpose:     Provide common ColdFire UART initialization
 *
 * Notes:       This file provides an initialization routine to enable
 *              the specified UART to be used for as a terminal in 
 *              dBUG. The settings are 8 bits, no parity, 1 stop
 *              bit, polled mode (no interrupts).
 */

#include "src/include/dbug.h"

/********************************************************************/
/*
 * Initialize the UART for 8N1 operation, interrupts disabled, and
 * no hardware flow-control
 *
 * Parameters:
 *  uartch      UART channel to initialize
 *  baud        UART baud rate
 */
void 
mcf5xxx_uart_init (int uartch, int baud)
{
    register uint16 ubgs;

    /* 
     * Reset Transmitter 
     */
    MCF_UART_UCR(uartch) = MCF_UART_UCR_RESET_TX;

    /* 
     * Reset Receiver 
     */
    MCF_UART_UCR(uartch) = MCF_UART_UCR_RESET_RX;

    /* 
     * Reset Mode Register 
     */
    MCF_UART_UCR(uartch) = MCF_UART_UCR_RESET_MR;

    /* 
     * No parity, 8-bits per character 
     */
    MCF_UART_UMR(uartch) = (0
        | MCF_UART_UMR_PM_NONE
        | MCF_UART_UMR_BC_8);

    /* 
     * No echo or loopback, 1 stop bit 
     */
    MCF_UART_UMR(uartch) = (0
        | MCF_UART_UMR_CM_NORMAL
        | MCF_UART_UMR_SB_STOP_BITS_1);

    /* 
     * Set Rx and Tx baud by timer 
     */
    MCF_UART_UCSR(uartch) = (0
        | MCF_UART_UCSR_RCS_SYS_CLK
        | MCF_UART_UCSR_TCS_SYS_CLK);

    /* 
     * Mask all UART interrupts 
     */
    MCF_UART_UIMR(uartch) = 0;
                 
    /* 
     * Calculate baud settings 
     */
    ubgs = (uint16)((SYSTEM_CLOCK*1000000)/(baud * 32));

    MCF_UART_UBG1(uartch) = (uint8)((ubgs & 0xFF00) >> 8);
    MCF_UART_UBG2(uartch) = (uint8)(ubgs & 0x00FF);

    /* 
     * Enable receiver and transmitter 
     */
    MCF_UART_UCR(uartch) = (0
        | MCF_UART_UCR_TX_ENABLED
        | MCF_UART_UCR_RX_ENABLED);
}
/********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -