亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uart.c

?? lm3s6916上keil編譯的"hello world"程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// uart.c - Driver for the UART.
//
// Copyright (c) 2005-2007 Luminary Micro, Inc.  All rights reserved.
// 
// Software License Agreement
// 
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  Any use in violation
// of the foregoing restrictions may subject the user to criminal sanctions
// under applicable laws, as well as to civil liability for the breach of the
// terms and conditions of this license.
// 
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 1234-conf of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup uart_api
//! @{
//
//*****************************************************************************

#include <hw_ints.h>
#include <hw_memmap.h>
#include <hw_types.h>
#include <hw_uart.h>
#include "debug.h"
#include "interrupt.h"
#include "sysctl.h"
#include "uart.h"

//*****************************************************************************
//
//! Sets the type of parity.
//!
//! \param ulBase is the base address of the UART port.
//! \param ulParity specifies the type of parity to use.
//!
//! Sets the type of parity to use for transmitting and expect when receiving.
//! The \e ulParity parameter must be one of \b UART_CONFIG_PAR_NONE,
//! \b UART_CONFIG_PAR_EVEN, \b UART_CONFIG_PAR_ODD, \b UART_CONFIG_PAR_ONE,
//! or \b UART_CONFIG_PAR_ZERO.  The last two allow direct control of the
//! parity bit; it will always be either be one or zero based on the mode.
//!
//! \return None.
//
//*****************************************************************************
void
UARTParityModeSet(unsigned long ulBase, unsigned long ulParity)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));
    ASSERT((ulParity == UART_CONFIG_PAR_NONE) ||
           (ulParity == UART_CONFIG_PAR_EVEN) ||
           (ulParity == UART_CONFIG_PAR_ODD) ||
           (ulParity == UART_CONFIG_PAR_ONE) ||
           (ulParity == UART_CONFIG_PAR_ZERO));

    //
    // Set the parity mode.
    //
    HWREG(ulBase + UART_O_LCR_H) = ((HWREG(ulBase + UART_O_LCR_H) &
                                     ~(UART_LCR_H_SPS | UART_LCR_H_EPS |
                                       UART_LCR_H_PEN)) | ulParity);
}

//*****************************************************************************
//
//! Gets the type of parity currently being used.
//!
//! \param ulBase is the base address of the UART port.
//!
//! \return The current parity settings, specified as one of
//! \b UART_CONFIG_PAR_NONE, \b UART_CONFIG_PAR_EVEN, \b UART_CONFIG_PAR_ODD,
//! \b UART_CONFIG_PAR_ONE, or \b UART_CONFIG_PAR_ZERO.
//
//*****************************************************************************
unsigned long
UARTParityModeGet(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Return the current parity setting.
    //
    return(HWREG(ulBase + UART_O_LCR_H) &
           (UART_LCR_H_SPS | UART_LCR_H_EPS | UART_LCR_H_PEN));
}

//*****************************************************************************
//
//! Sets the configuration of a UART.
//!
//! \param ulBase is the base address of the UART port.
//! \param ulBaud is the desired baud rate.
//! \param ulConfig is the data format for the port (number of data bits,
//! number of stop bits, and parity).
//!
//! This function will configure the UART for operation in the specified data
//! format.  The baud rate is provided in the \e ulBaud parameter and the
//! data format in the \e ulConfig parameter.
//!
//! The \e ulConfig parameter is the logical OR of three values: the number of
//! data bits, the number of stop bits, and the parity.  \b UART_CONFIG_WLEN_8,
//! \b UART_CONFIG_WLEN_7, \b UART_CONFIG_WLEN_6, and \b UART_CONFIG_WLEN_5
//! select from eight to five data bits per byte (respectively).
//! \b UART_CONFIG_STOP_ONE and \b UART_CONFIG_STOP_TWO select one or two stop
//! bits (respectively).  \b UART_CONFIG_PAR_NONE, \b UART_CONFIG_PAR_EVEN,
//! \b UART_CONFIG_PAR_ODD, \b UART_CONFIG_PAR_ONE, and \b UART_CONFIG_PAR_ZERO
//! select the parity mode (no parity bit, even parity bit, odd parity bit,
//! parity bit always one, and parity bit always zero, respectively).
//!
//! The baud rate is dependent upon the system clock rate returned by
//! SysCtlClockGet(); if it does not return the correct system clock rate then
//! the baud rate will be incorrect.
//!
//! \return None.
//
//*****************************************************************************
void
UARTConfigSet(unsigned long ulBase, unsigned long ulBaud,
              unsigned long ulConfig)
{
    unsigned long ulUARTClk, ulInt, ulFrac;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Stop the UART.
    //
    UARTDisable(ulBase);

    //
    // Determine the UART clock rate.
    //
    ulUARTClk = SysCtlClockGet();

    //
    // Compute the fractional baud rate divider.
    //
    ulInt = ulUARTClk / (16 * ulBaud);
    ulFrac = ulUARTClk % (16 * ulBaud);
    ulFrac = ((((2 * ulFrac * 4) / ulBaud) + 1) / 2);

    //
    // Set the baud rate.
    //
    HWREG(ulBase + UART_O_IBRD) = ulInt;
    HWREG(ulBase + UART_O_FBRD) = ulFrac;

    //
    // Set parity, data length, and number of stop bits.
    //
    HWREG(ulBase + UART_O_LCR_H) = ulConfig;

    //
    // Clear the flags register.
    //
    HWREG(ulBase + UART_O_FR) = 0;

    //
    // Start the UART.
    //
    UARTEnable(ulBase);
}

//*****************************************************************************
//
//! Gets the current configuration of a UART.
//!
//! \param ulBase is the base address of the UART port.
//! \param pulBaud is a pointer to storage for the baud rate.
//! \param pulConfig is a pointer to storage for the data format.
//!
//! The baud rate and data format for the UART is determined.  The returned
//! baud rate is the actual baud rate; it may not be the exact baud rate
//! requested or an ``official'' baud rate.  The data format returned in
//! \e pulConfig is enumerated the same as the \e ulConfig parameter of
//! UARTConfigSet().
//!
//! The baud rate is dependent upon the system clock rate returned by
//! SysCtlClockGet(); if it does not return the correct system clock rate then
//! the baud rate will be computed incorrectly.
//!
//! \return None.
//
//*****************************************************************************
void
UARTConfigGet(unsigned long ulBase, unsigned long *pulBaud,
              unsigned long *pulConfig)

{
    unsigned long ulInt, ulFrac;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Compute the baud rate.
    //
    ulInt = HWREG(ulBase + UART_O_IBRD);
    ulFrac = HWREG(ulBase + UART_O_FBRD);
    *pulBaud = (SysCtlClockGet() * 4) / ((64 * ulInt) + ulFrac);

    //
    // Get the parity, data length, and number of stop bits.
    //
    *pulConfig = (HWREG(ulBase + UART_O_LCR_H) &
                  (UART_LCR_H_SPS | UART_LCR_H_WLEN | UART_LCR_H_STP2 |
                   UART_LCR_H_EPS | UART_LCR_H_PEN));
}

//*****************************************************************************
//
//! Enables transmitting and receiving.
//!
//! \param ulBase is the base address of the UART port.
//!
//! Sets the UARTEN, TXE, and RXE bits, and enables the transmit and receive
//! FIFOs.
//!
//! \return None.
//
//*****************************************************************************
void
UARTEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Enable the FIFO.
    //
    HWREG(ulBase + UART_O_LCR_H) |= UART_LCR_H_FEN;

    //
    // Enable RX, TX, and the UART.
    //
    HWREG(ulBase + UART_O_CTL) |= (UART_CTL_UARTEN | UART_CTL_TXE |
                                   UART_CTL_RXE);
}

//*****************************************************************************
//
//! Disables transmitting and receiving.
//!
//! \param ulBase is the base address of the UART port.
//!
//! Clears the UARTEN, TXE, and RXE bits, then waits for the end of
//! transmission of the current character, and flushes the transmit FIFO.
//!
//! \return None.
//
//*****************************************************************************
void
UARTDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Wait for end of TX.
    //
    while(HWREG(ulBase + UART_O_FR) & UART_FR_BUSY)
    {
    }

    //
    // Disable the FIFO.
    //
    HWREG(ulBase + UART_O_LCR_H) &= ~(UART_LCR_H_FEN);

    //
    // Disable the UART.
    //
    HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_UARTEN | UART_CTL_TXE |
                                    UART_CTL_RXE);
}

//*****************************************************************************
//
//! Enables SIR (IrDA) mode on specified UART.
//!
//! \param ulBase is the base address of the UART port.
//! \param bLowPower indicates if SIR Low Power Mode is to be used.
//!
//! Enables the SIREN control bit for IrDA mode on the UART.  If the
//! \e bLowPower flag is set, then SIRLP bit will also be set.
//!
//! \note SIR (IrDA) operation is supported only on UART2.
//!
//! \return None.
//
//*****************************************************************************
void
UARTEnableSIR(unsigned long ulBase, tBoolean bLowPower)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART2_BASE));

    //
    // Return if UART2 is not specified.
    //
    if(ulBase != UART2_BASE)
    {
        return;
    }

    //
    // Enable SIR and SIRLP (if appropriate).
    //
    if(bLowPower)
    {
        HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN | UART_CTL_SIRLP);
    }
    else
    {
        HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN);
    }
}

//*****************************************************************************
//
//! Disables SIR (IrDA) mode on the specified UART.
//!
//! \param ulBase is the base address of the UART port.
//!
//! Clears the SIREN (IrDA) and SIRLP (Low Power) bits.
//!
//! \note SIR (IrDA) operation is supported only on UART2.
//!
//! \return None.
//
//*****************************************************************************
void
UARTDisableSIR(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART2_BASE));

    //
    // Return if UART2 is not specified.
    //
    if(ulBase != UART2_BASE)
    {
        return;
    }

    //
    // Disable SIR and SIRLP (if appropriate).
    //
    HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_SIREN | UART_CTL_SIRLP);
}

//*****************************************************************************
//
//! Determines if there are any characters in the receive FIFO.
//!
//! \param ulBase is the base address of the UART port.
//!
//! This function returns a flag indicating whether or not there is data
//! available in the receive FIFO.
//!
//! \return Returns \b true if there is data in the receive FIFO, and \b false
//! if there is no data in the receive FIFO.
//
//*****************************************************************************
tBoolean
UARTCharsAvail(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Return the availability of characters.
    //
    return((HWREG(ulBase + UART_O_FR) & UART_FR_RXFE) ? false : true);
}

//*****************************************************************************
//
//! Determines if there is any space in the transmit FIFO.
//!
//! \param ulBase is the base address of the UART port.
//!
//! This function returns a flag indicating whether or not there is space
//! available in the transmit FIFO.
//!
//! \return Returns \b true if there is space available in the transmit FIFO,
//! and \b false if there is no space available in the transmit FIFO.
//
//*****************************************************************************
tBoolean
UARTSpaceAvail(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
           (ulBase == UART2_BASE));

    //
    // Return the availability of space.
    //
    return((HWREG(ulBase + UART_O_FR) & UART_FR_TXFF) ? false : true);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av在线不卡网| 成人免费一区二区三区在线观看| 欧美一级片在线看| 久久你懂得1024| 亚洲人成小说网站色在线| 天堂成人国产精品一区| 国产伦精品一区二区三区免费迷| 国产精品99久久久久久似苏梦涵 | 精品国产一区二区三区久久久蜜月 | 中文字幕av资源一区| 亚洲三级在线免费观看| 首页国产丝袜综合| 国产福利不卡视频| 在线精品视频免费播放| 欧美不卡视频一区| 亚洲蜜臀av乱码久久精品 | 欧美精品一区二区三区蜜桃视频| 国产精品三级电影| 婷婷一区二区三区| 成人网在线播放| 在线电影一区二区三区| 国产精品久久久爽爽爽麻豆色哟哟 | 国产一本一道久久香蕉| 色婷婷亚洲婷婷| 久久久精品人体av艺术| 亚洲777理论| a亚洲天堂av| 精品免费日韩av| 一级特黄大欧美久久久| 国产精品系列在线观看| 91麻豆精品国产自产在线观看一区| 亚洲国产高清在线| 毛片基地黄久久久久久天堂| 色哟哟一区二区在线观看| 久久久久综合网| 日韩精品乱码av一区二区| 91免费精品国自产拍在线不卡| 欧美精品一区二| 图片区小说区国产精品视频| 91丨porny丨首页| 国产午夜亚洲精品羞羞网站| 日韩中文字幕麻豆| 在线观看日产精品| 国产精品激情偷乱一区二区∴| 精品亚洲aⅴ乱码一区二区三区| 欧美日韩一区二区三区免费看| 国产精品欧美极品| 精品一区二区免费在线观看| 7777精品伊人久久久大香线蕉的| 亚洲精品五月天| av高清不卡在线| 国产欧美日韩激情| 国产精品一区二区视频| 欧美成人精品3d动漫h| 亚洲国产成人av| 欧美在线一二三| 亚洲欧美日韩在线| 91原创在线视频| 成人免费一区二区三区在线观看| 国产成人免费视频精品含羞草妖精 | 国产精品―色哟哟| 国产白丝精品91爽爽久久| 久久婷婷色综合| 国产专区欧美精品| 欧美v日韩v国产v| 日本成人在线不卡视频| 7777精品伊人久久久大香线蕉完整版| 亚洲午夜久久久久| 欧美中文一区二区三区| 一区二区三区在线免费播放| 一本久久精品一区二区 | 91久久国产综合久久| 亚洲人吸女人奶水| 91久久国产综合久久| 亚洲国产精品一区二区www在线| 日本韩国一区二区三区视频| 亚洲伦理在线精品| 欧美体内she精高潮| 亚洲电影第三页| 欧美一区永久视频免费观看| 肉肉av福利一精品导航| 欧美剧情片在线观看| 日本亚洲视频在线| 久久美女高清视频| 成人一区二区三区视频在线观看| 国产精品女同一区二区三区| 91香蕉视频污| 午夜精品一区在线观看| 欧美一区二区三区白人| 精品亚洲成av人在线观看| 国产欧美一区二区三区沐欲| 成人av免费网站| 亚洲午夜激情av| 欧美成人一区二区三区| 国产精品一区免费视频| 综合电影一区二区三区| 欧美亚洲高清一区| 免费不卡在线观看| 国产精品污网站| 91福利在线播放| 免播放器亚洲一区| 日本一区二区三区四区在线视频| 99久久久国产精品| 亚洲成在线观看| 久久久精品欧美丰满| 99精品黄色片免费大全| 日韩成人一区二区| 国产亚洲一区字幕| 色妞www精品视频| 免费在线成人网| 午夜精品久久久久影视| 欧美xxxxxxxxx| 91视频免费观看| 青青草91视频| 日本一区二区视频在线| 欧美日韩日本视频| 国产成人综合在线播放| 夜夜爽夜夜爽精品视频| 欧美岛国在线观看| 色综合久久天天| 麻豆精品精品国产自在97香蕉 | 99re8在线精品视频免费播放| 亚洲国产一区视频| 国产欧美日韩综合| 欧美偷拍一区二区| 国产成人精品免费在线| 亚洲国产日韩一级| 国产精品女同互慰在线看| 56国语精品自产拍在线观看| 成人免费看视频| 日本va欧美va精品发布| 综合激情成人伊人| 精品成人一区二区| 欧美人与性动xxxx| 972aa.com艺术欧美| 韩国成人福利片在线播放| 亚洲伊人伊色伊影伊综合网| 日本一区二区三区久久久久久久久不| 欧美三级午夜理伦三级中视频| 国产成人高清在线| 美国欧美日韩国产在线播放| 亚洲综合图片区| 国产精品视频在线看| 日韩三级免费观看| 欧美亚日韩国产aⅴ精品中极品| 大白屁股一区二区视频| 麻豆免费看一区二区三区| 亚洲一区免费观看| 中文字幕在线视频一区| 精品国产乱码久久久久久蜜臀| 欧美在线|欧美| 成人动漫视频在线| 久久精品国产精品青草| 亚洲6080在线| 亚洲国产欧美在线| 亚洲啪啪综合av一区二区三区| 久久精品男人天堂av| 日韩精品中文字幕在线不卡尤物| 在线观看日韩一区| 91国内精品野花午夜精品| av在线一区二区| 成人av在线一区二区三区| 国产一区二区三区精品视频| 日韩黄色片在线观看| 亚洲一区二区三区免费视频| 亚洲欧美日本在线| 国产精品久久久久四虎| 国产欧美一区二区精品仙草咪| 久久综合色8888| 2014亚洲片线观看视频免费| 欧美xxxxxxxxx| 精品精品欲导航| 精品欧美一区二区久久| 欧美成人伊人久久综合网| 日韩欧美一区二区三区在线| 欧美人狂配大交3d怪物一区| 日本精品视频一区二区三区| 色94色欧美sute亚洲线路二| 色欧美日韩亚洲| 在线观看91视频| 欧美性受xxxx| 在线观看视频欧美| 欧美日韩精品一区二区天天拍小说 | www日韩大片| 国产日韩亚洲欧美综合| 国产日韩欧美精品综合| 中文字幕+乱码+中文字幕一区| 久久久不卡网国产精品一区| 国产亚洲女人久久久久毛片| 久久精品视频在线看| 国产日韩欧美精品综合| 国产精品久线在线观看| 亚洲日本一区二区| 一个色综合av| 日本欧美久久久久免费播放网| 麻豆91精品视频| 国产另类ts人妖一区二区| 国产不卡视频在线观看| 91色综合久久久久婷婷| 欧美丝袜丝交足nylons图片|