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

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

?? uart.c

?? FreeRTOS V4.2.1,增加了AVR32 UC3 和 LPC2368 的支持
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// uart.c - Driver for the UART.
//
// Copyright (c) 2005,2006 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 Stellaris Family of 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 991 of the Stellaris 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.
//
//*****************************************************************************
#if defined(GROUP_paritymodeset) || defined(BUILD_ALL) || defined(DOXYGEN)
void
UARTParityModeSet(unsigned long ulBase, unsigned long ulParity)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_paritymodeget) || defined(BUILD_ALL) || defined(DOXYGEN)
unsigned long
UARTParityModeGet(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_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));
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_configset) || defined(BUILD_ALL) || defined(DOXYGEN)
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));

    //
    // 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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_configget) || defined(BUILD_ALL) || defined(DOXYGEN)
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));

    //
    // 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));
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_enable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
UARTEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_disable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
UARTDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_charsavail) || defined(BUILD_ALL) || defined(DOXYGEN)
tBoolean
UARTCharsAvail(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE));

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

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_spaceavail) || defined(BUILD_ALL) || defined(DOXYGEN)
tBoolean
UARTSpaceAvail(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE));

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

//*****************************************************************************
//
//! Receives a character from the specified port.
//!
//! \param ulBase is the base address of the UART port.
//!
//! Gets a character from the receive FIFO for the specified port.
//!
//! \return Returns the character read from the specified port, cast as a
//! \e long.  A \b -1 will be returned if there are no characters present in
//! the receive FIFO.  The UARTCharsAvail() function should be called before
//! attempting to call this function.
//
//*****************************************************************************
#if defined(GROUP_charnonblockingget) || defined(BUILD_ALL) || defined(DOXYGEN)
long
UARTCharNonBlockingGet(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE));

    //
    // See if there are any characters in the receive FIFO.
    //
    if(!(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE))
    {
        //
        // Read and return the next character.
        //
        return(HWREG(ulBase + UART_O_DR));
    }
    else
    {
        //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品丝袜91| 国产二区国产一区在线观看| 美女在线一区二区| 91视频xxxx| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 日韩一级二级三级| 亚洲日穴在线视频| 国产剧情一区在线| 欧美一级理论片| 亚洲综合在线电影| 成人国产一区二区三区精品| 精品成人一区二区三区四区| 日本在线不卡视频| 欧美美女一区二区在线观看| 亚洲日本一区二区| 北条麻妃一区二区三区| 久久蜜臀中文字幕| 精品一区二区三区久久| 日韩一区二区精品在线观看| 亚洲国产成人精品视频| 日本乱码高清不卡字幕| 综合自拍亚洲综合图不卡区| 国产成人在线色| 国产亚洲综合色| 久久精品国产精品青草| 日韩欧美中文字幕公布| 免费看欧美美女黄的网站| 欧美视频一区二区| 亚洲成年人影院| 欧美狂野另类xxxxoooo| 亚洲va天堂va国产va久| 欧美日本免费一区二区三区| 图片区小说区区亚洲影院| 欧美丰满少妇xxxbbb| 亚洲成a人片在线不卡一二三区| 欧美日韩视频在线观看一区二区三区| 亚洲综合另类小说| 欧美日韩aaa| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美一区二区三区影视| 久久精品999| 欧美r级电影在线观看| 国产激情一区二区三区| 国产精品欧美极品| 日本韩国欧美国产| 午夜精品久久一牛影视| 日韩欧美黄色影院| 国产自产2019最新不卡| 国产精品国产三级国产| 欧美最新大片在线看| 奇米色777欧美一区二区| 日韩一区二区三区电影| 国产精品一区二区在线播放| 亚洲视频中文字幕| 欧美日韩黄色一区二区| 激情六月婷婷综合| 亚洲日本va在线观看| 欧美性一二三区| 久久精品久久综合| 中文幕一区二区三区久久蜜桃| 色综合天天性综合| 奇米影视一区二区三区小说| 亚洲国产高清不卡| 欧美视频日韩视频在线观看| 久久99精品国产| 中文字幕字幕中文在线中不卡视频| 欧美亚洲精品一区| 国产jizzjizz一区二区| 亚洲成人av中文| 国产精品入口麻豆原神| 在线播放一区二区三区| 成人免费观看av| 日本欧美一区二区在线观看| 亚洲素人一区二区| 26uuu亚洲| 欧美日本一区二区三区| 99免费精品视频| 久久精品国产亚洲一区二区三区| 亚洲欧美日韩中文播放| 精品99999| 欧美日韩一区二区三区四区| 国产91露脸合集magnet| 美女一区二区在线观看| 亚洲综合色丁香婷婷六月图片| 2022国产精品视频| 在线成人午夜影院| 在线观看国产一区二区| 成人高清视频在线观看| 久久99精品国产麻豆婷婷| 亚洲亚洲精品在线观看| 亚洲视频电影在线| 国产精品视频线看| 久久免费视频一区| 欧美一级日韩一级| 欧美色倩网站大全免费| 91浏览器在线视频| av动漫一区二区| 国产91清纯白嫩初高中在线观看| 久久爱另类一区二区小说| 日本中文字幕一区| 亚洲国产成人tv| 一区二区三区中文免费| 亚洲欧美怡红院| 中文字幕一区二区三区色视频| 精品88久久久久88久久久| 欧美大肚乱孕交hd孕妇| 日韩欧美在线网站| 91精品国产手机| 欧美一级日韩一级| 日韩精品一区二区三区在线播放| 538在线一区二区精品国产| 欧美日韩成人综合天天影院 | 成人激情视频网站| 国产经典欧美精品| 国产福利一区二区三区视频在线 | www.欧美亚洲| 国产成人精品www牛牛影视| 蜜臀va亚洲va欧美va天堂 | 欧美一区二区网站| 91精品国产综合久久久久久久久久 | 欧美天堂一区二区三区| 色8久久人人97超碰香蕉987| 在线观看三级视频欧美| 欧美欧美欧美欧美| 日韩视频在线观看一区二区| 久久综合一区二区| 国产拍揄自揄精品视频麻豆| 国产精品三级av在线播放| 综合激情成人伊人| 亚洲一区电影777| 美脚の诱脚舐め脚责91 | 蜜臀av国产精品久久久久| 美女尤物国产一区| 国产风韵犹存在线视精品| 99久久伊人网影院| 欧美性一二三区| 精品欧美一区二区久久| 国产精品毛片久久久久久久| 亚洲精品福利视频网站| 日本欧美一区二区三区| 国产一区二区三区免费在线观看| 成人小视频在线观看| 欧美亚洲尤物久久| 欧美mv日韩mv| 一区二区三区av电影| 伦理电影国产精品| 99久久精品免费观看| 欧美性videosxxxxx| 亚洲精品一区二区三区福利| 国产精品久久毛片av大全日韩| 亚洲国产日日夜夜| 国产精品一区二区久久不卡| 91成人国产精品| 精品国产免费视频| 亚洲国产日韩综合久久精品| 国产酒店精品激情| 在线播放亚洲一区| 亚洲人成伊人成综合网小说| 久久99深爱久久99精品| 在线观看日产精品| 亚洲国产成人在线| 麻豆国产精品一区二区三区 | 99视频精品全部免费在线| 91麻豆精品国产91久久久资源速度| 中文字幕免费观看一区| 日韩av高清在线观看| 99re视频这里只有精品| 欧美成人vps| 亚洲成人你懂的| 色一情一伦一子一伦一区| 久久嫩草精品久久久精品| 午夜欧美电影在线观看| 91亚洲精品一区二区乱码| 欧美白人最猛性xxxxx69交| 亚洲一线二线三线久久久| 国产成人免费视频| 精品日本一线二线三线不卡| 午夜精品成人在线| 一本久久a久久免费精品不卡| 欧美高清在线精品一区| 国产麻豆欧美日韩一区| 日韩女优视频免费观看| 三级在线观看一区二区| 欧美色图天堂网| 一区二区三区日韩欧美| 91在线无精精品入口| 国产精品视频一二三| 国产成人精品三级麻豆| 精品电影一区二区三区 | 久久人人爽人人爽| 久久激情综合网| 日韩视频免费观看高清完整版 | 激情综合网最新| 日韩视频一区二区在线观看| 日本不卡一区二区| 日韩三级在线免费观看| 久久国产尿小便嘘嘘| 91麻豆精品久久久久蜜臀| 日本强好片久久久久久aaa| 91精品国产综合久久久久久漫画 |