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

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

?? comm.c

?? 串口通信構件
?? C
字號:
/*
*********************************************************************************************************
*                                     Embedded Systems Building Blocks
*                                  Complete and Ready-to-Use Modules in C
*串行口通信程序
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                               INCLUDES
*********************************************************************************************************
*/

#include "..\includes\INCLUDES.H"
extern bit SemTIbusy;
/*
*********************************************************************************************************
*                                               DATA TYPES
*********************************************************************************************************
*/
    idata INT8U   RingBufRxCtr;                   /* Number of characters in the Rx ring buffer              */
    idata INT8U  *RingBufRxInPtr;                 /* Pointer to where next character will be inserted        */
    idata INT8U  *RingBufRxOutPtr;                /* Pointer from where next character will be extracted     */
    idata INT8U   RingBufRx[COMM_RX_BUF_SIZE];    /* Ring buffer character storage (Rx)                      */
    idata INT8U   RingBufTxCtr;                   /* Number of characters in the Tx ring buffer              */
    idata INT8U  *RingBufTxInPtr;                 /* Pointer to where next character will be inserted        */
    idata INT8U  *RingBufTxOutPtr;                /* Pointer from where next character will be extracted     */
    idata INT8U   RingBufTx[COMM_TX_BUF_SIZE];    /* Ring buffer character storage (Tx)                      */

/*
*********************************************************************************************************
*                                            GLOBAL VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*                                    REMOVE CHARACTER FROM RING BUFFER
*
*從接收緩沖區取數,應用中取數
* Description : This function is called by your application to obtain a character from the communications
*               channel.
* Arguments                 'err'   is a pointer to where an error code will be placed:
*                           *err is set to COMM_NO_ERR   if a character is available
*                           *err is set to COMM_RX_EMPTY if the Rx buffer is empty
*                           *err is set to COMM_BAD_CH   if you have specified an invalid channel
* Returns     : The character in the buffer (or NUL if the buffer is empty)
*********************************************************************************************************
*/
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    extern OS_CPU_SR  cpu_sr;
#endif

INT8U  CommGetChar (INT8U *err)
{
    INT8U          c;
    OS_ENTER_CRITICAL();
    if (RingBufRxCtr > 0) {                          /* See if buffer is empty                   */
        RingBufRxCtr--;                              /* No, decrement character count            */
        c = *RingBufRxOutPtr++;                      /* Get character from buffer                */
        if (RingBufRxOutPtr == &RingBufRx[COMM_RX_BUF_SIZE]) {     /* Wrap OUT pointer     */
            RingBufRxOutPtr = &RingBufRx[0];
        }
        OS_EXIT_CRITICAL();
        *err = COMM_NO_ERR;
        return (c);
    } else {
        OS_EXIT_CRITICAL();
        *err = COMM_RX_EMPTY;
        c    = NUL;                                        /* Buffer is empty, return NUL              */
        return (c);
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                  GET TX CHARACTER FROM RING BUFFER
*
*從發送緩沖區取數,中斷中發數調用
* Description : This function is called by the Tx ISR to extract the next character from the Tx buffer.
*               The function returns FALSE if the buffer is empty after the character is extracted from
*               the buffer.  This is done to signal the Tx ISR to disable interrupts because this is the
*               last character to send.
* Arguments                 'err'   is a pointer to where an error code will be deposited:
*                           *err is set to COMM_NO_ERR         if at least one character was left in the
*                                                              buffer.
*                           *err is set to COMM_TX_EMPTY       if the Tx buffer is empty.
*                           *err is set to COMM_BAD_CH         if you have specified an incorrect channel
* Returns     : The next character in the Tx buffer or NUL if the buffer is empty.
*********************************************************************************************************
*/

INT8U  CommGetTxChar (INT8U *err)
{
    INT8U          c;
    if (RingBufTxCtr > 0) {                          /* See if buffer is empty                   */
        RingBufTxCtr--;                              /* No, decrement character count            */
        c = *RingBufTxOutPtr++;                      /* Get character from buffer                */
        if (RingBufTxOutPtr == &RingBufTx[COMM_TX_BUF_SIZE]) {     /* Wrap OUT pointer     */
            RingBufTxOutPtr = &RingBufTx[0];
        }
        *err = COMM_NO_ERR;
        return (c);                                        /* Characters are still available           */
    } else {
        *err = COMM_TX_EMPTY;
        return (NUL);                                      /* Buffer is empty                          */
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                  INITIALIZE COMMUNICATIONS MODULE
*
*
* Description : This function is called by your application to initialize the communications module.  You
*               must call this function before calling any other functions.
* Arguments   : none
*********************************************************************************************************
*/

void  CommInit(void)
{
    RingBufRxCtr    = 0;
    RingBufRxInPtr  = &RingBufRx[0];
    RingBufRxOutPtr = &RingBufRx[0];
    RingBufTxCtr    = 0;
    RingBufTxInPtr  = &RingBufTx[0];
    RingBufTxOutPtr = &RingBufTx[0];
}
void  CommRxInit(void)
{
    RingBufRxCtr    = 0;
    RingBufRxInPtr  = &RingBufRx[0];
    RingBufRxOutPtr = &RingBufRx[0];
}
/*
void  CommTxInit(void)
{
    RingBufTxCtr    = 0;
    RingBufTxInPtr  = &RingBufTx[0];
    RingBufTxOutPtr = &RingBufTx[0];
}
*/
/*$PAGE*/
/*
*********************************************************************************************************
*                                  SEE IF RX CHARACTER BUFFER IS EMPTY
*測試接收緩沖區是否為空
*
* Description : This function is called by your application to see if any character is available from the
*               communications channel.  If at least one character is available, the function returns
*               FALSE otherwise, the function returns TRUE.
* Returns     : TRUE    if the buffer IS empty.
*               FALSE   if the buffer IS NOT empty or you have specified an incorrect channel
*********************************************************************************************************
*/

BOOLEAN  CommIsEmpty ()
{
    BOOLEAN        empty;
    OS_ENTER_CRITICAL();
    if (RingBufRxCtr > 0) {                          /* See if buffer is empty                   */
        empty = FALSE;                                     /* Buffer is NOT empty                      */
    } else {
        empty = TRUE;                                      /* Buffer is empty                          */
    }
    OS_EXIT_CRITICAL();
    return (empty);
}


/*
*********************************************************************************************************
*                                   SEE IF TX CHARACTER BUFFER IS FULL
*測試發送緩區是否滿?
*
* Description : This function is called by your application to see if any more characters can be placed
*               in the Tx buffer.  In other words, this function check to see if the Tx buffer is full.
*               If the buffer is full, the function returns TRUE otherwise, the function returns FALSE.
* Returns     : TRUE    if the buffer IS full.
*               FALSE   if the buffer IS NOT full or you have specified an incorrect channel
*********************************************************************************************************
*/

BOOLEAN  CommIsFull ()
{
    BOOLEAN        full;

    OS_ENTER_CRITICAL();
    if (RingBufTxCtr < COMM_TX_BUF_SIZE) {           /* See if buffer is full                    */
        full = FALSE;                                      /* Buffer is NOT full                       */
    } else {
        full = TRUE;                                       /* Buffer is full                           */
    }
    OS_EXIT_CRITICAL();
    return (full);
}


/*
*********************************************************************************************************
*                                            OUTPUT CHARACTER
*
*向發送緩沖區放數
* Description : This function is called by your application to send a character on the communications
*               channel.  The character to send is first inserted into the Tx buffer and will be sent by
*               the Tx ISR.  If this is the first character placed into the buffer, the Tx ISR will be
*               enabled.  If the Tx buffer is full, the character will not be sent (i.e. it will be lost)
* Arguments     'c'     is the character to send.
* Returns     : COMM_NO_ERR   if the function was successful (the buffer was not full)
*               COMM_TX_FULL  if the buffer was full
*               COMM_BAD_CH   if you have specified an incorrect channel
*********************************************************************************************************
*/

INT8U  CommPutChar (INT8U c)
{
    if(RingBufTxCtr == 0) {
        while(SemTIbusy);    
    }
    OS_ENTER_CRITICAL();
    if (RingBufTxCtr < COMM_TX_BUF_SIZE) {           /* See if buffer is full                    */
        RingBufTxCtr++;                              /* No, increment character count            */
        *RingBufTxInPtr++ = c;                       /* Put character into buffer                */
        if (RingBufTxInPtr == &RingBufTx[COMM_TX_BUF_SIZE]) { /* Wrap IN pointer           */
            RingBufTxInPtr = &RingBufTx[0];
        }
        if (RingBufTxCtr == 1) {                     /* See if this is the first character       */
            CommTxIntEn();                    /* Yes, Enable Tx interrupts                */
            OS_EXIT_CRITICAL();
        } else {
            OS_EXIT_CRITICAL();
        }
        return (COMM_NO_ERR);
    } else {
        OS_EXIT_CRITICAL();
        return (COMM_TX_FULL);
    }
}

/*
*********************************************************************************************************
*                                    INSERT CHARACTER INTO RING BUFFER
*
*向接收緩沖區放數(接收中斷調用)
* Description : This function is called by the Rx ISR to insert a character into the receive ring buffer.
* Arguments   : 'c'     is the character to insert into the ring buffer.  If the buffer is full, the
*                       character will not be inserted, it will be lost.
*********************************************************************************************************
*/

void  CommPutRxChar (INT8U c)
{
    if (RingBufRxCtr < COMM_RX_BUF_SIZE) {           /* See if buffer is full                    */
        RingBufRxCtr++;                              /* No, increment character count            */
        *RingBufRxInPtr++ = c;                       /* Put character into buffer                */
        if (RingBufRxInPtr == &RingBufRx[COMM_RX_BUF_SIZE]) { /* Wrap IN pointer           */
            RingBufRxInPtr = &RingBufRx[0];
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区在线免费观看| 亚洲欧洲三级电影| 欧美日韩综合在线| av高清久久久| 91在线观看一区二区| 国产成人免费视频网站高清观看视频| 日本成人在线网站| 日本伊人午夜精品| 激情五月激情综合网| 国产伦理精品不卡| 懂色一区二区三区免费观看 | 亚洲欧美一区二区三区孕妇| 久久久久久久久久电影| 欧美激情在线看| 亚洲日本在线天堂| 婷婷久久综合九色综合绿巨人 | 亚洲一区二区美女| 亚洲影视在线播放| 日本女优在线视频一区二区| 天天做天天摸天天爽国产一区| 日韩av电影免费观看高清完整版| 日本少妇一区二区| 国产成人在线视频网址| 99re热这里只有精品视频| 一本到一区二区三区| 正在播放一区二区| 久久精品人人做人人爽97| 国产精品久久久久久久蜜臀| 一区二区三区四区中文字幕| 日精品一区二区| 粉嫩aⅴ一区二区三区四区| 在线观看www91| 日韩精品一区二区三区蜜臀| 中文字幕在线一区二区三区| 爽爽淫人综合网网站 | 国产亚洲欧美中文| 亚洲美女视频在线| 精品一二三四在线| 91麻豆6部合集magnet| 欧美一区午夜精品| 国产精品国产三级国产aⅴ中文| 亚洲国产美女搞黄色| 国产一区二区三区在线观看精品| 在线免费视频一区二区| 久久久高清一区二区三区| 亚洲一区二区三区精品在线| 国产乱码一区二区三区| 欧美日精品一区视频| 国产精品国产三级国产有无不卡 | 自拍视频在线观看一区二区| 美女网站视频久久| 色偷偷成人一区二区三区91| 久久日一线二线三线suv| 一区二区三区av电影| 国产美女精品在线| 欧美一区二区在线看| 亚洲精品v日韩精品| 国产激情一区二区三区四区 | 亚洲精品成人悠悠色影视| 韩国av一区二区三区在线观看| 在线精品视频免费播放| 国产精品白丝在线| 福利一区福利二区| 久久综合色一综合色88| 青青草一区二区三区| 欧美图片一区二区三区| 亚洲欧美日韩一区二区| 99久久亚洲一区二区三区青草| 精品日韩99亚洲| 久久se精品一区精品二区| 制服丝袜中文字幕一区| 亚洲动漫第一页| 欧美三级电影在线看| 亚洲国产日日夜夜| 欧美群妇大交群的观看方式| 亚洲精品中文在线| 欧美天天综合网| 亚洲超碰97人人做人人爱| 欧美少妇性性性| 亚洲国产va精品久久久不卡综合| 在线视频一区二区免费| 亚洲一区二区精品视频| 欧美日韩成人在线| 秋霞影院一区二区| 久久亚洲精品小早川怜子| 国产麻豆精品95视频| 国产精品美女久久久久av爽李琼| 国产精品538一区二区在线| 久久午夜国产精品| 不卡一卡二卡三乱码免费网站 | 97se亚洲国产综合自在线观| 久久久美女艺术照精彩视频福利播放 | 日本韩国一区二区| 亚洲精品美国一| 欧美电影在哪看比较好| 美女视频黄频大全不卡视频在线播放| 精品国产一区二区三区不卡| 国产成人久久精品77777最新版本| 精品福利一二区| 成人一区二区在线观看| 亚洲老司机在线| 欧美裸体一区二区三区| 久久99久久99精品免视看婷婷| 精品国产一区二区亚洲人成毛片| 国产福利不卡视频| 亚洲在线视频网站| 日韩精品一区二区三区在线观看| 菠萝蜜视频在线观看一区| 亚洲成人中文在线| 国产午夜精品久久久久久久| 99精品视频中文字幕| 青青青伊人色综合久久| 亚洲天堂av一区| 欧美一区二区三区啪啪| 成人免费高清在线| 婷婷综合五月天| 中文字幕高清一区| 欧美一区二区三区在线看| 成人午夜视频在线观看| 日韩vs国产vs欧美| 国产精品伦理在线| 欧美一区二区女人| 99r国产精品| 久久精品国产99久久6| 亚洲愉拍自拍另类高清精品| 精品福利视频一区二区三区| 欧美亚洲国产一卡| 国产99久久久国产精品免费看| 天堂蜜桃91精品| 亚洲欧美日韩久久| 国产欧美一区二区精品性色超碰| 欧美日韩国产a| 一本大道久久a久久精品综合| 国产美女在线精品| 奇米精品一区二区三区四区| 亚洲欧美成人一区二区三区| 国产午夜亚洲精品午夜鲁丝片| 欧美精品在线观看播放| 日本伦理一区二区| 91亚洲精品久久久蜜桃网站| 国内成人自拍视频| 免费在线观看视频一区| 亚洲成人资源在线| 亚洲自拍偷拍欧美| 亚洲成在线观看| 亚洲宅男天堂在线观看无病毒| 国产精品国产三级国产aⅴ入口| 久久久影院官网| 久久先锋影音av| 久久亚洲二区三区| 久久久久久免费网| 国产欧美日韩另类视频免费观看 | 欧美国产精品一区| 欧美国产日韩精品免费观看| 久久综合久久综合亚洲| 亚洲精品一区二区在线观看| 日韩午夜电影av| 日韩一区二区精品在线观看| 制服丝袜一区二区三区| 日韩欧美在线观看一区二区三区| 欧美精品日日鲁夜夜添| 69堂成人精品免费视频| 欧美成人免费网站| 久久精品网站免费观看| 中文字幕在线不卡国产视频| 日韩理论片网站| 亚洲自拍另类综合| 美女性感视频久久| 国产suv精品一区二区6| av一区二区三区四区| 日本韩国一区二区三区视频| 这里只有精品电影| 久久久亚洲午夜电影| 亚洲品质自拍视频| 美女一区二区视频| 波多野结衣在线一区| 在线亚洲精品福利网址导航| 欧美日韩一卡二卡| 久久久蜜臀国产一区二区| 亚洲欧美一区二区久久 | 欧美一级二级三级乱码| 久久综合久久99| 中文字幕一区二区三区四区| 一区二区三区毛片| 男人操女人的视频在线观看欧美| 国产精品伊人色| 色爱区综合激月婷婷| 日韩一二三区视频| 国产精品毛片大码女人| 日韩电影在线看| 成人自拍视频在线| 制服丝袜亚洲播放| 亚洲品质自拍视频网站| 蜜臀久久久久久久| 色综合久久久久综合体| 欧美一个色资源| 一区二区不卡在线视频 午夜欧美不卡在| 日韩和的一区二区| 欧美军同video69gay| 亚洲日本va午夜在线影院|