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

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

?? ser_gen.c

?? 一個C語言寫的讀入位置跟蹤器數據的源程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/****************************************************************************
*****************************************************************************
    ser_gen.c       Generic Serial Routines for
		    RS232 PC Compatible and
		    RS485 Quatech Card (w/16550 UART Support)

    written for:    Ascension Technology Corporation
		    PO Box 527
		    Burlington, Vermont  05402
		    802-655-7879


    written by:     Jeff Finkelstein
		    Microprocessor Designs, Inc
		    PO Box 160
		    Shelburne, Vermont  05482
		    802-985-2535

    Modification History:

    9/16/93         jf  - created from serdpcin.c
    12/30/93        jf  - updated to allow this module to send data
			  out the RS232 port if the comport is configured for
			  an RS232 port
    1/8/94          jf  - restore comport now disables the FIFO

	   <<<< Copyright 1993 Ascension Technology Corporation >>>>
*****************************************************************************
****************************************************************************/
#include <stdio.h>          /* general I/O */
#include <time.h>           /* clock functions */
#include <dos.h>            /* needed for SETVECT/GETVECT */
#include "compiler.h"
#include "asctech.h"
#include "menu.h"
#include "pctimer.h"
#include "pcpic.h"
#include "birdmain.h"
#include "ser_gen.h"

/*
    Local Prototypes
*/
void interrupt far serialisr_com1(void);
void interrupt far serialisr_com2(void);
void interrupt far serialisr_com3(void);
void interrupt far serialisr_com4(void);
void serial_isr(short comport);
short ckuartfifo(short comport);


/*
    Base address of all the UARTS
*/
short com_base[NUMCOMPORTS] = {COM1BASE,COM2BASE,COM3BASE,COM4BASE};

/*
    flag indicates serial port saved
*/
short serialconfigsaved[NUMCOMPORTS] = {FALSE,FALSE,FALSE,FALSE};

/*
    Flag indicates the the FIFO is enabled
*/
short fifo_enabled[NUMCOMPORTS] = {FALSE,FALSE,FALSE,FALSE};

/*
    Value indicates that the Port is an RS485 Port
*/
short port_type[NUMCOMPORTS];

/*
    UART variable Storage
*/
unsigned char olddivisorlow[NUMCOMPORTS];            /* holds the old divisor low value */
unsigned char olddivisorhigh[NUMCOMPORTS];           /* holds the old divisor high value */
unsigned char oldlinecont[NUMCOMPORTS];              /* holds the old line control value */
unsigned char oldinterenable[NUMCOMPORTS];           /* holds the old interrupt enable value */
unsigned char oldmodemcont[NUMCOMPORTS];             /* holds the old modem control value */


/*
    Storage for the old serial interrupt vector
*/
void (interrupt far * oldserialintvect[NUMCOMPORTS])();  /* old serial interrupt vector */

/*
    Error Counters
*/

    short phaseerror_count[NUMCOMPORTS] = {0,0,0,0};                  /* holds the phase errors */
    short rxerrorvalue[NUMCOMPORTS] = {0,0,0,0};                      /* holds the rx error value */
	short rxbufoverruns[NUMCOMPORTS] = {FALSE,FALSE,FALSE,FALSE};     /* rx buffer overrun flag */
	short rxerrors[NUMCOMPORTS] = {FALSE,FALSE,FALSE,FALSE};          /* rx line errors flag */
	short txbufempty[NUMCOMPORTS] = {TRUE,TRUE,TRUE,TRUE};            /* tx buffer empty flag */

/*
    RX buffer
*/
    unsigned char rxbuf[NUMCOMPORTS][RXBUFSIZE];  /* rx buffer */
    unsigned char * rxbufinptr[NUMCOMPORTS];      /* rx buffer input pointer */
    unsigned char * rxbufoutptr[NUMCOMPORTS];     /* rx buffer output pointer */

/*
    TX buffer
*/
    unsigned char txbuf[NUMCOMPORTS][TXBUFSIZE];  /* tx buffer */
    unsigned char * txbufinptr[NUMCOMPORTS];      /* tx buffer input pointer */
    unsigned char * txbufoutptr[NUMCOMPORTS];     /* tx buffer output pointer */

/*
	tick timing varaible
*/

    unsigned int tick_msec = 18;        /* dos tick time in msec */


/*
    configserialport    -   Configure the Serial Port connected to the BIRD

    Prototype in:       serial.h

    Parameters Passed:  short comport

    Return Value:       TRUE if successfull, else FALSE

    Remarks:            Routine assumes that the current comports parameters
			have been saved prior to the call.
					    ** NOTE **
			Unfortunately, the PC ROM BIOS does NOT support baud
			rates upto 19200. Therefore, this routine must talk
			directly to the hardware to configure the serial port
			...this is not a problem in a PC environment since the
			I/O map is fixed for COM1 and COM2.
*/
int configserialport(comport,baud,type)
short comport;
long baud;
short type;
{
    unsigned divisor;

    /*
	Disable the interrupts
    */
    OUTPORTB(com_base[comport] + INTERENABLE, 0);

    /*
	Set the Global Port Type
    */
    port_type[comport] = type;

    /*
	Verify the comport and set the Base Address
    */
    switch (comport)
    {
	case COM1:
	    PCPIC_MASK(COM1IRQ);
	    SETVECT(COM1INTERRUPT,serialisr_com1);
	    break;

	case COM2:
	    PCPIC_MASK(COM2IRQ);
	    SETVECT(COM2INTERRUPT,serialisr_com2);
	    break;

	case COM3:
	    PCPIC_MASK(COM3IRQ);
	    SETVECT(COM3INTERRUPT,serialisr_com3);
	    break;

	case COM4:
	    PCPIC_MASK(COM4IRQ);
	    SETVECT(COM4INTERRUPT,serialisr_com4);
	    break;

	default:
	    printf("\n** ERROR ** invalid COM port\n");
	    return(FALSE);
    }

    /*
	assume that there are NO CHARACTERS CURRENTLY in the Tx Buffer
	and change the baud rate
    */
    OUTPORTB(com_base[comport] + LINECONT, DLAB);

    /*
	Set the least significant byte and then the most significant
	byte of the baud rate divisor
    */
    switch (port_type[comport])
    {
	case RS485_PORT:
	    divisor = 500000L/baud;
	    break;
	case RS232_PORT:
	    divisor = 115200L/baud;
	    break;
	default:
	    printf("\n\r** ERROR **  illegal Port Type in configserial\n\r");
	    return(FALSE);
    }
    OUTPORTB(com_base[comport], (divisor & 0xff));
    OUTPORTB(com_base[comport] + 1, ((divisor & 0xff00) >> 8));

    /*
	Set the Stop Bits = 1, Word Length = 8 and Parity = None
    */
    OUTPORTB(com_base[comport] + LINECONT, STOP_WORDLEN_PARITY);

    /*
	Deassert DTR...Make the TRANCEIVER go to Receive.. RS485
	Deassert DTR...Enable Output from the FOB.. RS232
	Deassert RTS...else the system will reset
	Assert OUT2...needed to allow interrupts to occur on PC compatible
	    serial I/O cards
    */
    switch(port_type[comport])
    {
	case RS232_PORT:
	    OUTPORTB(com_base[comport] + MODEMCONT, DTRON | OUT2);
	    break;
	case RS485_PORT:
	    OUTPORTB(com_base[comport] + MODEMCONT, OUT2);
	    break;
    }

    /*
	Check if it is a 16550 UART with a FIFO
	..use it if it is available..setup the receive trigger to 14 characters
    */
    OUTPORTB(com_base[comport] + FCR, 0);   /* disable the FIFO */
    fifo_enabled[comport] = ckuartfifo(comport);
    if (fifo_enabled[comport])
    {
	OUTPORTB(com_base[comport] + FCR, 0xC0 + 1);  /* enable the FIFO..0xc0 is for
						trigger level = 14 bytes */
    }
    else
    {
	/*
	    RS485 Ports Must have the FIFO for the DUAL system
	*/
	if (port_type[comport] == RS485_PORT)
	{
	    printf("\n\r** ERROR ** COM%d does not have a 16550 type UART\n\r",comport+1);
	    return(FALSE);
	}
    }

    /*
	Clear the Rx Buffer and Rx Errors
    */
    clear_rx(comport);

    /*
	Enable the 8259 Mask register for serial interrupts
    */
    switch (comport)
    {
	case COM1:
	     PCPIC_UNMASK(COM1IRQ);
	     break;
	case COM2:
	     PCPIC_UNMASK(COM2IRQ);
	     break;
	case COM3:
	     PCPIC_UNMASK(COM3IRQ);
	     break;
	case COM4:
	     PCPIC_UNMASK(COM4IRQ);
	     break;
    }

    return(TRUE);
}

/*
    ckuartfifo          Check for a Uart FIFO

    Prototype in:       serial.h

    Parameters Passed:  short comport - comport of the UART

    Return Value:       TRUE if the UART has a FIFO
			FALSE otherwise

    Remarks:            routine checks if the UART is a 16550 Type by
			trying to enable the FIFO and then checking if the
			FIFO did in fact become enabled

*/
short ckuartfifo(comport)
short comport;
{
    OUTPORTB(com_base[comport] + FCR, 7); /* Enable and Reset */
    if ((INPORTB(com_base[comport] + INTERIDENT) & 0xC0) != 0xC0)
	return(FALSE);
    OUTPORTB(com_base[comport] + FCR, 0); /* Disable */
    if ((INPORTB(com_base[comport] + INTERIDENT) & 0xC0) == 0xC0)
	return(FALSE);
    OUTPORTB(com_base[comport] + FCR, 1); /* Enable */
    if ((INPORTB(com_base[comport] + INTERIDENT) & 0xC0) != 0xC0)
	return(FALSE);

    return(TRUE);
}

/*
    saveserialconfig    -   save serial port configuration

    Prototype in:       serial.h

    Parameters Passed:  short comport

    Return Value:       void

    Remarks:            saves the current configuration of the serial port

*/
int saveserialconfig(comport)
short comport;
{
    /*
	Save the Serial interrupt Vector
    */
    switch (comport)
    {
	case COM1:
	    oldserialintvect[comport] = GETVECT(COM1INTERRUPT);
	    break;
	case COM2:
	    oldserialintvect[comport] = GETVECT(COM2INTERRUPT);
	    break;
	case COM3:
	    oldserialintvect[comport] = GETVECT(COM3INTERRUPT);
	    break;
	case COM4:
	    oldserialintvect[comport] = GETVECT(COM4INTERRUPT);
	    break;
    }

    /*
	Save the Current Com Port Configuration Regs including:
	    Divisor, Interrupt Enable, Line Control, Modem Control
    */
    oldlinecont[comport] = INPORTB(com_base[comport] + LINECONT);         /* save the old line control value */
    OUTPORTB(com_base[comport] + LINECONT, DLAB);                /* set DLAB to get the divisor */
    olddivisorlow[comport] = INPORTB(com_base[comport] + DIVISORLOW);     /* save the divisor low */
    olddivisorhigh[comport] = INPORTB(com_base[comport] + DIVISORHIGH);   /* save the divisor high */
    OUTPORTB(com_base[comport] + LINECONT,oldlinecont[comport] & 0x7f);   /* reset DLAB to get the divisor */
    oldinterenable[comport] = INPORTB(com_base[comport] + INTERENABLE);   /* save the interrupt enable reg */
    oldmodemcont[comport] = INPORTB(com_base[comport] + MODEMCONT);       /* save the modem control reg */

    serialconfigsaved[comport] = TRUE;

    return(TRUE);
}

/*
    restoreserialconfig -   Restore the original serial port configuration

    Prototype in:       serial.h

    Parameters Passed:  short comport

    Return Value:       void

    Remarks:            restores the configuration of the serial port
*/
void restoreserialconfig(comport)
short comport;
{
    /*
	Do not Restore if not previously stored
    */
    if (!serialconfigsaved[comport])
	return;

    /*
	Disable Serial Interrupts on 8259 while initializing port
	and switching interrupt vectors
    */
    switch (comport)
    {
	case COM1:
	    PCPIC_MASK(COM1IRQ);
	    break;

	case COM2:
	    PCPIC_MASK(COM2IRQ);
	    break;

	case COM3:
	    PCPIC_MASK(COM3IRQ);
	    break;

	case COM4:
	    PCPIC_MASK(COM4IRQ);
	    break;
    }

    /*
	Restore the Com Port Configuration Regs including:
	    Divisor, Interrupt Enable, Line Control, Modem Control
    */
    OUTPORTB(com_base[comport] + LINECONT, DLAB);                /* set DLAB to get the divisor */
    OUTPORTB(com_base[comport], olddivisorlow[comport]);                   /* restore the divisor low */
    OUTPORTB(com_base[comport] + 1,olddivisorhigh[comport]);              /* restore the divisor high */
    OUTPORTB(com_base[comport] + LINECONT,oldlinecont[comport]);          /* reset DLAB to get the divisor */
    OUTPORTB(com_base[comport] + INTERENABLE,oldinterenable[comport]);    /* restore the interrupt enable reg */
    OUTPORTB(com_base[comport] + MODEMCONT,oldmodemcont[comport]);        /* restore the interrupt enable reg */

    /*
	Restore the Serial Vector
	..disable interrupts during restoration
    */
    DISABLE();
    switch (comport)
    {
	case COM1:
	    SETVECT(COM1INTERRUPT,oldserialintvect[comport]);
	    break;
	case COM2:
	    SETVECT(COM2INTERRUPT,oldserialintvect[comport]);
	    break;
	case COM3:
	    SETVECT(COM3INTERRUPT,oldserialintvect[comport]);
	    break;
	case COM4:
	    SETVECT(COM4INTERRUPT,oldserialintvect[comport]);
	    break;
    }
    ENABLE();

    /*
	Disable the FIFO for other applications
    */
    if (fifo_enabled[comport])
	OUTPORTB(com_base[comport] + FCR, 0);   /* disable the FIFO */
}


/*
    clearrx             -   Read the characters out of the Rx buffer if available

    Prototype in:       serial.h

    Parameters Passed:  short comport

    Return Value:       void

    Remarks:            clears the rx buffer and rx errors if any

*/
void clear_rx(comport)
short comport;
{
    short i;

    phaseerror_count[comport] = 0;                       /* clear phase error cntr */
    rxerrorvalue[comport] = 0;                           /* clear error byte */
    rxerrors[comport] = FALSE;                           /* clear Rx error flag */
    rxbufoverruns[comport] = FALSE;                      /* clear Buf Overrun flag */
    rxbufinptr[comport] = rxbufoutptr[comport] = rxbuf[comport];           /* re initialize buffer ptrs */
    txbufinptr[comport] = txbufoutptr[comport] = txbuf[comport];           /* re initialize buffer ptrs */

    /*
       Clear the Interrupts
    */
    while (!(INPORTB(com_base[comport] + INTERIDENT) && 0x01))
    {
	INPORTB(com_base[comport] + RXBUF);       /* Clear the Data */
	INPORTB(com_base[comport] + MODEMSTATUS); /* Clear the Modem Status */
	INPORTB(com_base[comport] + LINESTATUS);  /* Clear the Line Status */
    }
}

/*
    get_serial_record   - Get a record from the serial port

    Prototype in:       serial.h

    Parameters Passed:  short comport
			rxbuf       -   pointer to a buffer to store the
					received characters
			recsize     -   number of characters to receive
			outputmode  -   POINT, CONTINUOUS or STREAM

    Return Value:       If successful, returns recsize
			else, RXERRORS if Rx errors were detected while
			receiving data, or RXPHASEERRORS if in POINT or
			CONTINUOUS mode and a phase error is detected.

    Remarks:            A record of data has the MSB of the first
			character set to a 1.  The routine verifies that
			the first character received is in PHASE.  If
			in STREAM mode, the routine resynches and tries
			to capture the data into the rxbuf.  If in POINT
			or CONTINUOUS mode, then the routine returns
			indicating a RXPHASEERROR.

*/
int get_serial_record(comport, rxbuffer, recsize, outputmode)
short comport;
unsigned char * rxbuffer;
short recsize;
short outputmode;
{
	short rxcount;
	short rxchar;
	short resynch;
    char * rxbufptr;

    resynch = TRUE;

    do
    {
	if  (resynch)
	{
	    rxcount = 0;                /* initialize char counter */
	    rxbufptr = rxbuffer;        /* setup buffer pointer */
	    resynch = FALSE;
	}

	/*
	    Get first character and if error and NOT in STREAM mode..return
	*/
	if (rxcount == 0)
	{
	    if ((rxchar = waitforchar(comport)) < 0)
	    {
		if ((outputmode != STREAM) || (rxchar == RXTIMEOUT))
		{
		    return(RXERRORS);
		}
	    }

	    /*
		Check to make sure the the phase bit is a '1'
		If not, then if STREAM mode, resynch
		else, return with error
	    */
	    if (!(rxchar & 0x80))
	    {
		if (outputmode == STREAM)
		{
		    /*
		       Resynch
		       ...and keep track of the phase error
		    */
		    phaseerror_count[comport]++;
		    resynch = TRUE;
		    continue;
		}
		else
		{
		     return(RXPHASEERROR);
		}
	    }
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡一区视频| 精品国产在天天线2019| 国产另类ts人妖一区二区| 性做久久久久久免费观看欧美| 自拍偷拍国产亚洲| 怡红院av一区二区三区| 夜夜嗨av一区二区三区| 亚洲电影一级片| 午夜影视日本亚洲欧洲精品| 免费在线观看一区二区三区| 久久国产免费看| 欧美日韩一区视频| 在线观看免费视频综合| 欧美精品v日韩精品v韩国精品v| 精品视频在线免费| 欧美一区二区三区性视频| 欧美一区二区观看视频| 精品免费日韩av| 亚洲国产电影在线观看| 亚洲欧美一区二区三区国产精品| 一区二区三区欧美激情| 日韩av中文在线观看| 久久99精品一区二区三区 | 色综合色综合色综合| 精品国产乱码91久久久久久网站| 欧美精品一区二区三区在线播放 | 欧美成人国产一区二区| 日韩美女主播在线视频一区二区三区| 91精品国产综合久久国产大片| 欧美一卡在线观看| 久久嫩草精品久久久精品一| 亚洲精品第一国产综合野| 日韩精品一区第一页| 国产精品资源网站| 欧美中文字幕一区二区三区| 欧美一区二区女人| 国产精品久久久久毛片软件| 日韩精品一级二级| av福利精品导航| 日韩精品中午字幕| 亚洲人xxxx| 国内精品在线播放| 欧美性受极品xxxx喷水| 中文字幕 久热精品 视频在线 | 亚洲欧美综合另类在线卡通| 午夜天堂影视香蕉久久| 国产成人丝袜美腿| 欧美一区二区三区不卡| 一区二区三区在线观看欧美| 国产一区在线看| 欧美日韩一区成人| 亚洲特黄一级片| 国产中文一区二区三区| 精品视频在线看| 国产精品久久久久影院亚瑟| 狠狠色丁香久久婷婷综合_中| 日本二三区不卡| 国产精品福利电影一区二区三区四区| 奇米影视在线99精品| 欧洲精品一区二区三区在线观看| 国产午夜精品一区二区三区视频 | 99热在这里有精品免费| 欧美美女一区二区在线观看| 亚洲色欲色欲www| 丁香啪啪综合成人亚洲小说| 欧美电影免费观看高清完整版在线 | 一区二区三区在线观看视频 | 中文字幕一区三区| 久久99久久99| 26uuu欧美日本| 国产高清在线精品| 国产日产欧产精品推荐色 | 97se狠狠狠综合亚洲狠狠| 久久精品一区二区三区四区 | 国产精品麻豆视频| 粗大黑人巨茎大战欧美成人| 久久精品人人爽人人爽| 国产成人在线免费| 欧美国产欧美综合| 不卡一区二区三区四区| 国产精品伦一区| 成人高清在线视频| 亚洲欧美激情插 | 国产精品妹子av| 91视频精品在这里| 亚洲国产欧美日韩另类综合| 欧美日韩精品一区二区三区| 水蜜桃久久夜色精品一区的特点| 国产日韩欧美激情| 国产成人av一区二区三区在线观看| 久久久精品国产免大香伊| 国产盗摄精品一区二区三区在线| 国产日产亚洲精品系列| 色999日韩国产欧美一区二区| 亚洲电影视频在线| 日韩一区二区三| 国产91精品久久久久久久网曝门| 国产精品蜜臀在线观看| 欧美日韩欧美一区二区| 蜜臀av性久久久久av蜜臀妖精| 久久这里只有精品6| 99麻豆久久久国产精品免费| 亚洲一区二区影院| 亚洲精品在线免费播放| 不卡高清视频专区| 日韩国产精品久久久| 久久你懂得1024| 欧洲av在线精品| 国产一区二区三区黄视频 | 日韩 欧美一区二区三区| 久久精品男人的天堂| 欧美在线免费视屏| 国产一区二区福利| 亚洲国产视频a| 日本一区二区免费在线观看视频| 欧美综合一区二区| 成人免费av资源| 免费观看91视频大全| 亚洲精品欧美专区| 久久久精品日韩欧美| 制服丝袜av成人在线看| 99久久精品99国产精品| 国内成+人亚洲+欧美+综合在线| 亚洲美女视频在线观看| 久久久久久久av麻豆果冻| 欧美日韩国产片| 99久久综合精品| 久久99久久久欧美国产| 亚洲国产人成综合网站| 亚洲天堂久久久久久久| 国产日韩综合av| 精品三级在线看| 在线不卡免费av| 欧美视频在线观看一区| 91尤物视频在线观看| 国产精品一区在线| 久久爱www久久做| 日韩电影在线一区| 亚洲综合一区二区三区| 中文字幕一区二区三区av| 国产三级欧美三级| 国产欧美日韩视频一区二区| 精品国产百合女同互慰| 日韩一级视频免费观看在线| 欧美精品九九99久久| 在线观看日韩高清av| 欧美特级限制片免费在线观看| 99久久精品费精品国产一区二区| 不卡一区二区中文字幕| 成人精品鲁一区一区二区| 国产成人午夜电影网| 成人亚洲一区二区一| 国产成人自拍网| 成人精品一区二区三区四区| 国产精品 欧美精品| 国产东北露脸精品视频| 国产91在线看| 成人三级伦理片| 99re亚洲国产精品| 91丨porny丨蝌蚪视频| 91美女视频网站| 在线观看日韩国产| 日韩欧美在线影院| 久久先锋影音av鲁色资源| 国产精品久久久久久久久搜平片| 国产精品理伦片| 亚洲综合丁香婷婷六月香| 天天综合网天天综合色| 九九在线精品视频| 国产ts人妖一区二区| 91黄色在线观看| 69堂成人精品免费视频| 精品国产91亚洲一区二区三区婷婷| 2020国产精品| 亚洲少妇最新在线视频| 日韩经典一区二区| 国产一区二区三区精品欧美日韩一区二区三区 | 色综合视频一区二区三区高清| 色婷婷亚洲综合| 在线电影国产精品| 国产精品三级av在线播放| 亚洲黄色av一区| 国产在线看一区| 欧美日韩在线综合| 久久婷婷国产综合国色天香| 亚洲人精品午夜| 奇米影视一区二区三区小说| 成人短视频下载| 91麻豆精品国产91| 国产精品护士白丝一区av| 偷拍日韩校园综合在线| 高清视频一区二区| 欧美日韩一区视频| 国产精品色在线| 开心九九激情九九欧美日韩精美视频电影 | 天堂va蜜桃一区二区三区漫画版| 国产成人在线视频免费播放| 欧美精品第1页| 亚洲视频在线观看一区| 激情五月婷婷综合|