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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? uart.c

?? STR7 USB Library Source code
?? C
字號:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : uart.c
* Author             : MCD Application Team
* Date First Issued  : 08/06/2003
* Description        : This file provides all the UART software functions
********************************************************************************
* History:
*  08/06/2003 : Created
*******************************************************************************/

#include "uart.h"

/*******************************************************************************
* Function Name  : UART_Init
* Description    : This function initializes the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Output         : None
* Return         : None
*******************************************************************************/
void UART_Init(UART_TypeDef *UARTx)
{
  UARTx->IER = 0x00;
  UARTx->CR = 0x00;
  (void)UARTx->RBR;
  UARTx->RRR = 0xFFFF;
  UARTx->TRR = 0xFFFF;
}

/*******************************************************************************
* Function Name  : UART_BaudRateConfig
* Description    : This function configures the baud rate of the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : The baudrate value
* Output         : None
* Return         : None
*******************************************************************************/
void UART_BaudRateConfig(UART_TypeDef *UARTx, u32 BaudRate)
{
  UARTx->BRR = (u16)(RCCU_FrequencyValue(RCCU_FCLK)/(16*BaudRate));
}

/*******************************************************************************
* Function Name  : UART_Config
* Description    : This function configures the baudrate, the mode, the data
*                  parity and the number of stop bits of the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : The baudrate value
* Input 3        : The parity type
* Input 4        : The number of stop bits
* Input 5        : The UART mode
* Output         : None
* Return         : None
*******************************************************************************/
void UART_Config(UART_TypeDef *UARTx, u32 BaudRate, UARTParity_TypeDef Parity,
                 UARTStopBits_TypeDef StopBits, UARTMode_TypeDef Mode)
{
  UART_ModeConfig(UARTx, Mode);
  UART_BaudRateConfig(UARTx, BaudRate);
  UART_ParityConfig(UARTx, Parity);
  UART_StopBitsConfig(UARTx, StopBits);
}

/*******************************************************************************
* Function Name  : UART_ItConfig
* Description    : This function enables or disables the interrupts of the
*                  selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : The new interrupt flag
* Input 3        : ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void UART_ItConfig(UART_TypeDef *UARTx, u16 UART_Flag, functionalstate NewStatus)
{
  if (NewStatus==ENABLE) UARTx->IER|=UART_Flag; else UARTx->IER&=~UART_Flag;
}

/*******************************************************************************
* Function Name  : UART_FifoConfig
* Description    : This function enables or disables the Rx and Tx FIFOs of
*                  the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void UART_FifoConfig(UART_TypeDef *UARTx, functionalstate NewStatus)
{
  if (NewStatus==ENABLE) UARTx->CR|=0x0400; else UARTx->CR&=~0x0400;
}

/*******************************************************************************
* Function Name  : UART_FifoReset
* Description    : This function resets the Rx and the Tx FIFOs of the
*                  selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : UART_RxFIFO or UART_TxFIFO
* Output         : None
* Return         : None
*******************************************************************************/
void UART_FifoReset(UART_TypeDef *UARTx, UARTFIFO_TypeDef FIFO)
{
  if (FIFO==UART_RxFIFO) UARTx->RRR=0xFFFF; else UARTx->TRR=0xFFFF;
}

/*******************************************************************************
* Function Name  : UART_LoopBackConfig
* Description    : This function enables or disables the loop back mode of
*                  the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void UART_LoopBackConfig(UART_TypeDef *UARTx, functionalstate NewStatus)
{
  if (NewStatus==ENABLE) UARTx->CR|=0x0040; else UARTx->CR&=~0x0040;
}

/*******************************************************************************
* Function Name  : UART_RxConfig
* Description    : This function enables or disables the UART data reception.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void UART_RxConfig(UART_TypeDef *UARTx, functionalstate NewStatus)
{
  if (NewStatus==ENABLE) UARTx->CR|=0x0100; else UARTx->CR&=~0x0100;
}

/*******************************************************************************
* Function Name  : UART_OnOffConfig
* Description    : This function sets On/Off the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void UART_OnOffConfig(UART_TypeDef *UARTx, functionalstate NewStatus)
{
  if (NewStatus==ENABLE) UARTx->CR|=0x0080; else UARTx->CR&=~0x0080;
}

/*******************************************************************************
* Function Name  : UART_ByteSend
* Description    : This function sends a data byte to the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the data byte to send
* Output         : None
* Return         : None
*******************************************************************************/
void UART_ByteSend(UART_TypeDef *UARTx, u8 *Data)
{
  if (UARTx->CR & (0x0001<<UART_FIFOEnableBit))// if FIFO ENABLED
    while((UARTx->SR & UART_TxFull)); // while the UART_TxFIFO contain 16 characters.
  else                  // if FIFO DISABLED
    while (!(UARTx->SR & UART_TxEmpty)); // while the transmit shift register not empty
  UARTx->TBR = *Data;
}

/*******************************************************************************
* Function Name  : UART_9BitByteSend
* Description    : This function sends a 9 bits data byte to the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the data to send
* Output         : None
* Return         : None
*******************************************************************************/
void UART_9BitByteSend(UART_TypeDef *UARTx, u16 *Data)
{
  if(UARTx->CR & (0x0001<<UART_FIFOEnableBit))// if FIFO ENABLED
    while((UARTx->SR & UART_TxFull)); // while the UART_TxFIFO contain 16 characters.
  else                  // if FIFO DISABLED
    while (!(UARTx->SR & UART_TxEmpty)); // while the transmit shift register not empty
  UARTx->TBR = *Data;
}

/*******************************************************************************
* Function Name  : UART_DataSend
* Description    : This function sends several data bytes to the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the data to send
* Input 3        : The data length in bytes
* Output         : None
* Return         : None
*******************************************************************************/
void UART_DataSend(UART_TypeDef *UARTx, u8 *Data, u8 DataLength)
{
  while(DataLength--)
  {
    UART_ByteSend(UARTx,Data);
    Data++;
  }
}

/*******************************************************************************
* Function Name  : UART_9BitDataSend
* Description    : This function sends several 9 bits data bytes to the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the data to send
* Input 3        : The data length
* Output         : None
* Return         : None
*******************************************************************************/
void UART_9BitDataSend(UART_TypeDef *UARTx, u16 *Data, u8 DataLength)
{
  while(DataLength--)
  {
    UART_9BitByteSend(UARTx,Data);
    Data++;
  }
}

/*******************************************************************************
* Function Name  : UART_StringSend
* Description    : This function sends a string to the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the string to send
* Output         : None
* Return         : None
*******************************************************************************/
void UART_StringSend(UART_TypeDef *UARTx, u8 *String)
{
  u8 *Data=String;
  while(*Data != '\0')
    UART_ByteSend(UARTx, Data++);
  *Data='\0';
  UART_ByteSend(UARTx, Data);
}

/*******************************************************************************
* Function Name  : UART_ByteReceive
* Description    : This function gets a data byte from the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the buffer where the data will be stored
* Input 3        : The time-out period
* Output         : The received data
* Return         : The UARTx.SR register contents
*******************************************************************************/
u16 UART_ByteReceive(UART_TypeDef *UARTx, u8 *Data, u8 TimeOut)
{
   u16 wStatus;
   UARTx->TOR=TimeOut;// reload the Timeout counter
   while (!((wStatus=UARTx->SR) & (UART_TimeOutIdle|UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
   *Data = (u8)UARTx->RBR; // then read the Receive Buffer Register
   return wStatus;
}

/*******************************************************************************
* Function Name  : UART_9BitByteReceive
* Description    : This function gets a 9 bits data byte from the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the buffer where the data will be stored
* Input 3        : The time-out period value
* Output         : The received data
* Return         : The UARTx.SR register contents
*******************************************************************************/
u16 UART_9BitByteReceive(UART_TypeDef *UARTx, u16 *Data, u8 TimeOut)
{
  u16 wStatus;
  UARTx->TOR=TimeOut;// reload the Timeout counter
  while (!((wStatus=UARTx->SR) & (UART_TimeOutIdle|UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
  *Data = (u16)UARTx->RBR; // then read the RBR
  return wStatus;
}

/*******************************************************************************
* Function Name  : UART_DataReceive
* Description    : This function gets 8 bits data bytes from the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the buffer where the data will be stored
* Input 3        : The data length
* Input 4        : The time-out period value
* Output         : The received data
* Return         : The UARTx.SR register contents
*******************************************************************************/
u16 UART_DataReceive(UART_TypeDef *UARTx, u8 *Data, u8 DataLength, u8 TimeOut)
{
  u16 wStatus;
  while(DataLength--)
    wStatus=UART_ByteReceive(UARTx,Data++,TimeOut);
  return wStatus;
}

/*******************************************************************************
* Function Name  : UART_9BitDataReceive
* Description    : This function gets 9 bits data bytes from the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the buffer where the data will be stored
* Input 3        : The data length
* Input 4        : The time-out value
* Output         : The received data
* Return         : The UARTx.SR register contents
*******************************************************************************/
u16 UART_9BitDataReceive(UART_TypeDef *UARTx, u16 *Data, u8 DataLength, u8 TimeOut)
{
  u16 wStatus;
  while(DataLength--)
    wStatus=UART_9BitByteReceive(UARTx,Data++,TimeOut);
  return wStatus;
}

/*******************************************************************************
* Function Name  : UART_StringReceive
* Description    : This function gets 8 bits data bytes from the selected UART.
* Input 1        : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2        : A pointer to the buffer where the string will be stored
* Output         : The received string
* Return         : The UARTx.SR register contents
*******************************************************************************/
u16 UART_StringReceive(UART_TypeDef *UARTx, u8 *Data)
{
  u8 *pSTRING=Data;
  u16 wStatus;
  do
  {
    while (!((wStatus=UARTx->SR) & (UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
    *(pSTRING++) = (u8)UARTx->RBR; // then read the RBR
  } while((*(pSTRING - 1)!=0x0D)&(*(pSTRING - 1)!='\0'));
  *(pSTRING - 1)='\0';
  return wStatus;
}

#ifdef USE_SERIAL_PORT
/*******************************************************************************
* Function Name  : sendchar
* Description    : This function sends a character to the selected UART.
* Input 1        : A pointer to the character to send.
* Output         : None
* Return         : None
*******************************************************************************/
void sendchar( char *ch )
{
   #ifdef USE_UART0
     #define  UARTx  UART0
   #endif /* Use_UART0 */

   #ifdef USE_UART1
     #define  UARTx  UART1
   #endif /* Use_UART1 */

   #ifdef USE_UART2
     #define  UARTx  UART2
   #endif /* Use_UART2 */

   #ifdef USE_UART3
     #define  UARTx  UART3
   #endif /* Use_UART3 */

   UART_ByteSend(UARTx,(u8 *)ch);
}
#endif /* USE_SERIAL_PORT */

/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线精品一区二区三区| 亚洲手机成人高清视频| 麻豆国产精品777777在线| 欧美精品在线一区二区| 麻豆国产精品777777在线| 久久久久9999亚洲精品| 日韩限制级电影在线观看| 日韩精品欧美精品| 精品久久人人做人人爽| 大美女一区二区三区| 国产精品动漫网站| 欧美三级三级三级| 美女视频一区在线观看| 久久久久久久久久久电影| 9i在线看片成人免费| 亚洲三级理论片| 欧美二区在线观看| 韩国三级电影一区二区| 亚洲图片激情小说| 欧美日韩的一区二区| 激情文学综合插| 亚洲三级在线播放| 日韩视频在线一区二区| 暴力调教一区二区三区| 亚洲图片欧美视频| 久久免费的精品国产v∧| 91在线观看地址| 日本va欧美va瓶| 欧美国产精品专区| 5566中文字幕一区二区电影| 国产精品白丝av| 午夜精品久久久久久久蜜桃app| 精品99一区二区三区| 白白色亚洲国产精品| 首页欧美精品中文字幕| 欧美mv和日韩mv国产网站| 97精品电影院| 亚洲一区二区不卡免费| 久久日一线二线三线suv| 在线观看国产日韩| 国产成人免费高清| 爽好多水快深点欧美视频| 国产精品麻豆久久久| 日韩理论片一区二区| www国产精品av| 欧美美女直播网站| 99久久综合精品| 国产美女在线精品| 青娱乐精品视频| 亚洲一区二区视频| 国产精品久久久久久亚洲伦| 日韩精品一区二区三区老鸭窝| 午夜日韩在线电影| 欧美激情综合五月色丁香| 6080yy午夜一二三区久久| 一本久久精品一区二区| 国产成人精品一区二区三区网站观看| 久久久99精品免费观看不卡| 欧美乱妇23p| 色久优优欧美色久优优| 成人一区二区三区视频在线观看| 久久亚洲一级片| 91精品久久久久久蜜臀| 欧美三级韩国三级日本三斤| 成人免费视频caoporn| 国产综合成人久久大片91| 亚洲国产精品人人做人人爽| 亚洲欧洲日产国码二区| 国产女主播视频一区二区| 精品国产精品一区二区夜夜嗨| 国产成人精品亚洲777人妖 | 欧美一区二区三区视频在线| 成人激情免费电影网址| 国产成人综合网站| 国产一区二区三区不卡在线观看| 亚洲欧洲美洲综合色网| 国产精品嫩草久久久久| 国产精品三级av| 国产精品福利av| 日本一区二区三区四区| 中文字幕高清一区| 亚洲桃色在线一区| 亚洲靠逼com| 亚洲午夜免费视频| 亚洲va韩国va欧美va精品| 午夜精品福利一区二区蜜股av| 国产日韩精品一区二区浪潮av| 97se亚洲国产综合自在线不卡| 亚洲韩国一区二区三区| 午夜影视日本亚洲欧洲精品| 天天av天天翘天天综合网| 丝袜美腿亚洲一区二区图片| 男女性色大片免费观看一区二区| 国产偷国产偷精品高清尤物| 国产亚洲欧美在线| 久久久午夜精品| 国产精品入口麻豆九色| 亚洲精品ww久久久久久p站| 一区二区三区久久久| 首页欧美精品中文字幕| 极品销魂美女一区二区三区| 国产ts人妖一区二区| 不卡的av网站| 欧美日本一区二区在线观看| 日韩欧美国产成人一区二区| 国产婷婷色一区二区三区 | 懂色av一区二区三区蜜臀| 国产一区二区免费看| fc2成人免费人成在线观看播放 | 久久久久久影视| 国产精品视频免费| 午夜久久久影院| 国产精品一区二区在线播放| 欧美中文一区二区三区| 日韩免费高清视频| 最新国产精品久久精品| 首页欧美精品中文字幕| 成人网在线播放| 欧美日本一道本在线视频| 久久久.com| 午夜精品福利一区二区三区蜜桃| 亚洲一区在线视频| 麻豆视频观看网址久久| 91色九色蝌蚪| 精品久久国产字幕高潮| 亚洲精品视频一区二区| 国产在线不卡视频| 欧美日韩亚洲高清一区二区| 国产午夜精品一区二区三区视频| 精品国产成人在线影院| 亚洲一区免费观看| 国产成人免费视频| 日韩亚洲欧美成人一区| 亚洲午夜久久久久| 成人理论电影网| 日韩欧美电影在线| 亚洲一区日韩精品中文字幕| 成人午夜av电影| 久久蜜桃香蕉精品一区二区三区| 欧美一区二区观看视频| 亚洲精品一二三四区| 成人综合婷婷国产精品久久蜜臀| 国产剧情一区在线| 欧美美女直播网站| 亚洲男人天堂一区| 成人自拍视频在线| wwwwxxxxx欧美| 麻豆精品国产传媒mv男同| 在线看国产日韩| 国产精品福利影院| 岛国精品在线观看| 久久久久久久久久久99999| 免费日本视频一区| 91精品国产欧美日韩| 亚洲一区二区欧美| 色欧美88888久久久久久影院| 欧美视频第二页| 亚洲色图欧洲色图婷婷| 9i在线看片成人免费| 国产亚洲综合av| 国产精品一区在线观看你懂的| 成人av电影在线网| 中文字幕第一区综合| 丁香一区二区三区| 久久久一区二区三区捆绑**| 免费精品视频在线| 日韩西西人体444www| 奇米在线7777在线精品| 正在播放亚洲一区| 奇米精品一区二区三区在线观看| 国产成人高清在线| 久久久国产精品麻豆| 国产麻豆视频一区二区| 欧美精品一区二区三区高清aⅴ | 一区二区三区中文在线| 91蝌蚪porny九色| 亚洲精品一二三四区| 欧美日韩免费不卡视频一区二区三区| 91麻豆精品国产自产在线观看一区| 欧美电影免费观看高清完整版在线| 国产亚洲欧洲997久久综合| 精品无人码麻豆乱码1区2区| 欧美变态tickling挠脚心| 日本欧美一区二区| 日韩免费高清av| 成人影视亚洲图片在线| 亚洲美女免费在线| 51午夜精品国产| 极品少妇一区二区三区精品视频 | 国产成a人亚洲| 国产精品系列在线| www.成人在线| 亚洲一区二区三区四区在线免费观看 | 国产欧美一区在线| 99久久综合精品| 亚洲第一精品在线| 精品乱人伦一区二区三区| 国产成人福利片| 亚洲国产精品久久久久婷婷884| 成人av网站大全|