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

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

?? comm_pc.c

?? 一些ucos的外圍接口原代碼,如鍵盤LCDLED
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                     Embedded Systems Building Blocks
*                                  Complete and Ready-to-Use Modules in C
*
*                                    Asynchronous Serial Communications
*                                    IBM-PC Serial I/O Low Level Driver
*
*                            (c) Copyright 1999, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* Filename   : COMM_PC.C
* Programmer : Jean J. Labrosse
*
* Notes      : 1) The code in this file assumes that you are using a National Semiconductor NS16450 (most
*                 PCs do or, an Intel i82C50) serial communications controller.
*
*              2) The functions (actually macros) OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() are used to
*                 disable and enable interrupts, respectively.  If using the Borland C++ compiler V3.1,
*                 all you need to do is to define these macros as follows:
*
*                     #define OS_ENTER_CRITICAL()  disable()
*                     #define OS_EXIT_CRITICAL()   enable()
*
*              3) You will need to define the following constants:
*                     COMM1_BASE    is the base address of COM1 on your PC (typically 0x03F8)
*                     COMM2_BASE    is the base address of COM2 on your PC (typically 0x02F8)
*                     COMM_MAX_RX   is the number of characters buffered by the UART
*                                        2 for the NS16450
*                                       16 for the NS16550
*
*              4) COMM_BAD_CH, COMM_NO_ERR and COMM_TX_EMPTY,
*                 COMM_NO_PARITY, COMM_ODD_PARITY and COMM_EVEN_PARITY
*                     are all defined in other modules (i.e. COMM1.H, COMM2.H or COMM3.H)
*********************************************************************************************************
*/

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

#include "includes.h"

/*$PAGE*/
/*
*********************************************************************************************************
*                                               CONSTANTS
*********************************************************************************************************
*/

#define  BIT0                       0x01
#define  BIT1                       0x02
#define  BIT2                       0x04
#define  BIT3                       0x08
#define  BIT4                       0x10
#define  BIT5                       0x20
#define  BIT6                       0x40
#define  BIT7                       0x80

#define  PIC_INT_REG_PORT         0x0020
#define  PIC_MSK_REG_PORT         0x0021

#define  COMM_UART_RBR                 0
#define  COMM_UART_THR                 0
#define  COMM_UART_DIV_LO              0
#define  COMM_UART_DIV_HI              1
#define  COMM_UART_IER                 1
#define  COMM_UART_IIR                 2
#define  COMM_UART_LCR                 3
#define  COMM_UART_MCR                 4
#define  COMM_UART_LSR                 5
#define  COMM_UART_MSR                 6
#define  COMM_UART_SCR                 7

/*
*********************************************************************************************************
*                                         LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/

static  void   (*Comm1ISROld)(void);
static  void   (*Comm2ISROld)(void);

/*$PAGE*/
/*
*********************************************************************************************************
*                                            CONFIGURE PORT
*
* Description : This function is used to configure a serial I/O port.  This code is for IBM-PCs and
*               compatibles and assumes a National Semiconductor NS16450.
*
* Arguments   : 'ch'          is the COMM port channel number and can either be:
*                                 COMM1
*                                 COMM2
*               'baud'        is the desired baud rate (anything, standard rates or not)
*               'bits'        defines the number of bits used and can be either 5, 6, 7 or 8.
*               'parity'      specifies the 'parity' to use:
*                                 COMM_PARITY_NONE
*                                 COMM_PARITY_ODD
*                                 COMM_PARITY_EVEN
*               'stops'       defines the number of stop bits used and can be either 1 or 2.
*
* Returns     : COMM_NO_ERR   if the channel has been configured.
*               COMM_BAD_CH   if you have specified an incorrect channel.
*
* Notes       : 1) Refer to the NS16450 Data sheet
*               2) The constant 115200 is based on a 1.8432 MHz crystal oscillator and a 16 x Clock.
*               3) 'lcr' is the Line Control Register and is define as:
*
*                        B7  B6  B5  B4  B3  B2  B1  B0
*                                                ------ #Bits  (00 = 5, 01 = 6, 10 = 7 and 11 = 8)
*                                            --         #Stops (0 = 1 stop, 1 = 2 stops)
*                                        --             Parity enable (1 = parity is enabled)
*                                    --                 Even parity when set to 1.
*                                --                     Stick parity (see 16450 data sheet)
*                            --                         Break control (force break when 1)
*                        --                             Divisor access bit (set to 1 to access divisor)
*               4) This function enables Rx interrupts but not Tx interrupts.
*********************************************************************************************************
*/
INT8U  CommCfgPort (INT8U ch, INT16U baud, INT8U bits, INT8U parity, INT8U stops)
{
    INT16U  div;                                      /* Baud rate divisor                             */
    INT8U   divlo;
    INT8U   divhi;
    INT8U   lcr;                                      /* Line Control Register                         */
    INT16U  base;                                     /* COMM port base address                        */


    switch (ch) {                                     /* Obtain base address of COMM port              */
        case COMM1:
             base = COMM1_BASE;
             break;

        case COMM2:
             base = COMM2_BASE;
             break;

        default:
             return (COMM_BAD_CH);
    }
    div   = (INT16U)(115200L / (INT32U)baud);         /* Compute divisor for desired baud rate         */
    divlo =  div & 0x00FF;                            /* Split divisor into LOW and HIGH bytes         */
    divhi = (div >> 8) & 0x00FF;
    lcr   = ((stops - 1) << 2) + (bits - 5);
    switch (parity) {
        case COMM_PARITY_ODD: 
             lcr |= 0x08;                             /* Odd  parity                                   */
             break;

        case COMM_PARITY_EVEN: 
             lcr |= 0x18;                             /* Even parity                                   */
             break;
    }
    OS_ENTER_CRITICAL();
    outp(base + COMM_UART_LCR, BIT7);                 /* Set divisor access bit                        */
    outp(base + COMM_UART_DIV_LO, divlo);             /* Load divisor                                  */
    outp(base + COMM_UART_DIV_HI, divhi);
    outp(base + COMM_UART_LCR, lcr);                  /* Set line control register (Bit 8 is 0)        */
    outp(base + COMM_UART_MCR, BIT3 | BIT1 | BIT0);   /* Assert DTR and RTS and, allow interrupts      */
    outp(base + COMM_UART_IER, 0x00);                 /* Disable both Rx and Tx interrupts             */
    OS_EXIT_CRITICAL();
    CommRxFlush(ch);                                  /* Flush the Rx input                            */
    return (COMM_NO_ERR);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           COMM ISR HANDLER
*
* Description : This function processes an interrupt from a COMM port.  The function verifies whether the
*               interrupt comes from a received character, the completion of a transmitted character or
*               both.
* Arguments   : 'ch'    is the COMM port channel number and can either be:
*                           COMM1
*                           COMM2
* Notes       : 'switch' statements are used for expansion.
*********************************************************************************************************
*/
void  CommISRHandler (INT8U ch)
{
    INT8U   c;
    INT8U   iir;                                          /* Interrupt Identification Register (IIR)   */
    INT8U   stat;
    INT16U  base;                                         /* COMM port base address                    */
    INT8U   err;
    INT8U   max;                                          /* Max. number of interrupts serviced        */


    switch (ch) {                                         /* Obtain pointer to communications channel  */
        case COMM1:
             base = COMM1_BASE;
             break;

        case COMM2:
             base = COMM2_BASE;
             break;

        default:
             base = COMM1_BASE;
             break;
    }
    max = COMM_MAX_RX;
    iir = (INT8U)inp(base + COMM_UART_IIR) & 0x07;        /* Get contents of IIR                       */
    while (iir != 1 && max > 0) {                         /* Process ALL interrupts                    */
        switch (iir) {
            case 0:                                       /* See if we have a Modem Status interrupt   */
                 c = (INT8U)inp(base + COMM_UART_MSR);    /* Clear interrupt (do nothing about it!)    */
                 break;

            case 2:                                       /* See if we have a Tx interrupt             */
                 c = CommGetTxChar(ch, &err);             /* Get next character to send.               */
                 if (err == COMM_TX_EMPTY) {              /* Do we have anymore characters to send ?   */
                                                          /* No,  Disable Tx interrupts                */
                     stat = (INT8U)inp(base + COMM_UART_IER) & ~BIT1; 
                     outp(base + COMM_UART_IER, stat);
                 } else {
                     outp(base + COMM_UART_THR, c);       /* Yes, Send character                       */
                 }
                 break;

            case 4:                                       /* See if we have an Rx interrupt            */
                 c  = (INT8U)inp(base + COMM_UART_RBR);   /* Process received character                */
                 CommPutRxChar(ch, c);                    /* Insert received character into buffer     */
                 break;

            case 6:                                       /* See if we have a Line Status interrupt    */
                 c   = (INT8U)inp(base + COMM_UART_LSR);  /* Clear interrupt (do nothing about it!)    */
                 break;
        }
        iir = (INT8U)inp(base + COMM_UART_IIR) & 0x07;    /* Get contents of IIR                       */
        max--;
    }
    switch (ch) {
        case COMM1:
        case COMM2:
             outp(PIC_INT_REG_PORT, 0x20);                /* Reset interrupt controller                */
             break;

        default:
             outp(PIC_INT_REG_PORT, 0x20);
             break;
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                    RESTORE OLD INTERRUPT VECTOR
*
* Description : This function restores the old interrupt vector for the desired communications channel.
* Arguments   : 'ch'    is the COMM port channel number and can either be:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲少妇30p| 欧美一级午夜免费电影| 久久激情五月激情| 日本v片在线高清不卡在线观看| 中文字幕一区二区三区色视频| 久久精品在线免费观看| 91精品视频网| 91精品久久久久久久91蜜桃| 欧美精品一二三区| 欧美美女一区二区三区| 欧美日韩一区二区三区不卡| 欧美这里有精品| 欧洲另类一二三四区| 欧洲中文字幕精品| 欧美日韩精品三区| 91精品国产麻豆| www精品美女久久久tv| 欧美成人午夜电影| 国产亚洲成av人在线观看导航| 久久综合狠狠综合久久综合88 | 亚洲最新视频在线播放| 亚洲精品va在线观看| 亚洲国产欧美日韩另类综合| 午夜av电影一区| 九九热在线视频观看这里只有精品| 韩国v欧美v日本v亚洲v| 国产成人精品一区二区三区四区| www.亚洲在线| 日本道精品一区二区三区| 欧美日韩国产美| 精品国产百合女同互慰| 《视频一区视频二区| 午夜一区二区三区在线观看| 狠狠色丁香久久婷婷综合_中| 粉嫩一区二区三区在线看| 色悠悠久久综合| 日韩午夜激情电影| 成人欧美一区二区三区黑人麻豆 | 成人性生交大片免费看中文| 色国产综合视频| 666欧美在线视频| 国产精品无圣光一区二区| 午夜精品123| 成人免费视频视频| 8x8x8国产精品| 一区在线观看免费| 欧美96一区二区免费视频| 成人激情免费电影网址| 91精品国产综合久久蜜臀 | eeuss鲁片一区二区三区| 欧美性大战久久久| 国产午夜久久久久| 日韩专区欧美专区| 99热这里都是精品| 久久久亚洲综合| 五月天激情综合| 不卡高清视频专区| 26uuu久久天堂性欧美| 亚洲国产视频一区二区| 国产91富婆露脸刺激对白| 日韩一区二区在线免费观看| 亚洲美女视频在线| 成人av在线资源网站| 精品久久人人做人人爰| 亚欧色一区w666天堂| 91小视频在线免费看| 国产无遮挡一区二区三区毛片日本| 欧美aⅴ一区二区三区视频| 在线观看亚洲成人| 亚洲天堂福利av| 岛国一区二区三区| 久久精品男人天堂av| 久久97超碰国产精品超碰| 在线播放中文字幕一区| 亚洲国产精品久久久男人的天堂 | 伊人一区二区三区| jlzzjlzz亚洲日本少妇| 久久婷婷一区二区三区| 久久国产生活片100| 日韩欧美在线网站| 六月婷婷色综合| 欧美一级日韩免费不卡| 日韩电影一区二区三区| 欧美一区二区三区四区五区| 午夜av电影一区| 欧美年轻男男videosbes| 五月天激情综合| 欧美日韩不卡视频| 男女视频一区二区| 日韩欧美你懂的| 国产久卡久卡久卡久卡视频精品| 欧美电影免费观看高清完整版| 久久国产精品无码网站| 精品国产电影一区二区| 国产大陆精品国产| 国产精品久线在线观看| 91丨九色丨尤物| 亚洲福利一区二区| 欧美一区二区三区日韩视频| 黄色资源网久久资源365| 久久久91精品国产一区二区精品 | 亚洲欧美欧美一区二区三区| 91国产免费观看| 美女诱惑一区二区| 中文幕一区二区三区久久蜜桃| 91蜜桃网址入口| 亚洲成av人片一区二区梦乃| 精品国产一二三区| 91视频观看视频| 蜜桃视频在线一区| 国产精品久久久久7777按摩| 欧美日韩中文字幕一区二区| 国产乱理伦片在线观看夜一区| 亚洲免费在线视频一区 二区| 91麻豆精品国产91久久久久| jvid福利写真一区二区三区| 污片在线观看一区二区| 欧美国产精品v| 欧美日韩日日骚| 国产成人亚洲综合a∨婷婷| 亚洲欧美乱综合| 日韩一区二区中文字幕| 九色综合国产一区二区三区| 亚洲一区二区三区免费视频| 91麻豆精品国产91久久久使用方法| 韩国成人福利片在线播放| 国产精品毛片无遮挡高清| 日韩一区二区在线看| 波多野结衣精品在线| 亚洲www啪成人一区二区麻豆| 精品日韩一区二区三区免费视频| 国产成人综合网| 美女视频黄a大片欧美| 国产精品入口麻豆原神| 欧美三级电影在线看| 国产精品456| 亚洲小说春色综合另类电影| 专区另类欧美日韩| 日韩午夜电影av| 一本久久a久久精品亚洲| 欧美一区二区视频在线观看2022| 欧美理论在线播放| 欧美成人激情免费网| 欧美国产亚洲另类动漫| 成人免费黄色在线| 国产一区在线看| 性做久久久久久久久| 国产亚洲精久久久久久| 678五月天丁香亚洲综合网| 国产一区二区在线视频| 美腿丝袜亚洲综合| 亚洲成av人片在线观看| 中文字幕亚洲视频| 久久久久国产一区二区三区四区| 在线免费观看日本欧美| 国产99久久久国产精品潘金| 日韩高清不卡一区二区三区| 一区二区在线免费观看| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲精品一区二区三区蜜桃下载 | 免费视频一区二区| 无码av免费一区二区三区试看| 成人深夜在线观看| 亚洲天堂中文字幕| 国产精品免费视频网站| 欧美精品一区二区久久久| 日韩一区国产二区欧美三区| 欧美视频一二三区| 成人免费高清视频在线观看| 美国十次了思思久久精品导航| 夜夜嗨av一区二区三区| 一区二区三区在线看| 日韩毛片精品高清免费| 精品人伦一区二区色婷婷| 久久久亚洲精品一区二区三区| 精品国产露脸精彩对白| 精品粉嫩aⅴ一区二区三区四区| 制服丝袜亚洲网站| 欧美成人精品福利| 久久亚洲精品国产精品紫薇| 亚洲精品一区二区三区香蕉| 久久噜噜亚洲综合| 91精品黄色片免费大全| 国产欧美视频一区二区三区| 国产视频一区二区三区在线观看| 精品国产伦一区二区三区观看体验 | 国产精品美女久久久久久久久| 久久嫩草精品久久久精品| 国产嫩草影院久久久久| 中文天堂在线一区| 午夜亚洲国产au精品一区二区| 美女诱惑一区二区| 国内成人精品2018免费看| 国产一区二区剧情av在线| 成人午夜免费av| 不卡一区二区三区四区| 91精品国产一区二区三区香蕉| 精品国产网站在线观看| 欧美韩国日本不卡| 亚洲一级在线观看|