Category : Tutorials + Patches
Archive   : NAT_UART.ZIP
Filename : SERIO.H

 
Output of file : SERIO.H contained in archive : NAT_UART.ZIP
/*
* SSSSSS EEEEEE RRRRRR III OOOOO H H
* S E R R I O O H H
* S E R R I O O H H
* SSSSSS EEEEEE RRRRRR I O O HHHHHHH
* S E R R I O O H H
* S E R R I O O .. H H
* SSSSSS EEEEEE R R III OOOOO .. H H
*
* serio.h -- serial I/O header file
*
* Author: Brian A. Berg
* Berg Software Design
* October 1988
*
* Developed for: National Semiconductor Corp.
*/

/* PIC 8259A parameters */
#define EOI 0x20 /* end-of-interrupt for PICTRL */
#define PICTRL 0x20
#define PICMSK 0x21

/* LBT invocation arguments: minumum and maximum values */
/* argument 1: COM number */
#define COM_MIN 1 /* COM1 */
#define COM_MAX 2 /* COM2 */
#define COM_CNT (COM_MAX-COM_MIN+1)
#define COM_DEF 1 /* DEFAULT: COM1 */
/* argument 2: termination error count */
#define TERMERR_MIN 0 /* allow infinite number of errors */
#define TERMERR_MAX 30000
#define TERMERR_DEF 1 /* DEFAULT: terminate after 1 error */
/* argument 3: baud rate divisor (based on 1.8432 MHz crystal) */
#define BAUDIV_MIN 2 /* 56000 baud */
#define BAUDIV_MAX 2304 /* 50 baud */
#define BAUDIV_DEF 12 /* DEFAULT: 9600 baud */
#define BAUD_NUMER 115200L /* numerator for computing baud rate */

/* UART register definitions using UART base address */
#define RBR (ubase+0) /* Receive Buffer Register (R )(DLAB==0)*/
#define THR (ubase+0) /* Transmitter Holding Register ( W)(DLAB==0)*/
#define IER (ubase+1) /* Interrupt Enable Register (R/W)(DLAB==0)*/
#define IIR (ubase+2) /* Interrupt Ident. Register (R ) */
#define FCR (ubase+2) /* FIFO Control Register ( W) */
#define LCR (ubase+3) /* Line Control Register (R/W) */
#define MCR (ubase+4) /* MODEM Control Register (R/W) */
#define LSR (ubase+5) /* Line Status Register (R ) */
#define MSR (ubase+6) /* MODEM Status Register (R/W) */

#define SCR (ubase+7) /* SCratch Register (R/W) */
#define DLL (ubase+0) /* Divisor Latch (LSB) (R/W)(DLAB==1)*/
#define DLM (ubase+1) /* Divisor Latch (MSB) (R/W)(DLAB==1)*/

/* bit settings */
/* IIR: */
#define NOIP 1 /* NO Interrupt Pending */
#define RLST 6 /* Receiver Line STatus interrupt */
#define RDAV 4 /* Received Data AVailable */
#define IIR_THRE 2 /* Transmitter Holding Register Empty */
/* LSR: */
#define DR 1 /* bit 0: Data Ready */
#define OE 2 /* bit 1: Overrun Error */
#define PE 4 /* bit 2: Parity Error */
#define FE 8 /* bit 3: Framing Error */
#define BI 0x10 /* bit 4: Break Interrupt */
#define LSR_THRE 0x20 /* bit 5: Transmtr Holding Reg Empty */
#define TEMT 0x40 /* bit 6: Transmitter Empty */

/* values for writing to IER */
#define IER_VAL1 0x05 /* RDA & RLS */
#define IER_VAL2 0x07 /* RDA & THRE & RLS */

/* register read/write macros */

#define rdRBR() ((UCHAR)inp(RBR)) /* read RBR */
#define rdDLL() ((UCHAR)inp(DLL)) /* read DLL */
#define rdDLM() ((UCHAR)inp(DLM)) /* read DLM */
#define rdIER() ((UCHAR)inp(IER)) /* read IER */
#define rdIIR() ((UCHAR)inp(IIR)) /* read IIR */
#define rdLCR() ((UCHAR)inp(LCR)) /* read LCR */
#define rdLSR() ((UCHAR)inp(LSR)) /* read LSR */
#define rdMSR() ((UCHAR)inp(MSR)) /* read MSR */
#define rdSCR() ((UCHAR)inp(SCR)) /* read SCR */

#define wrTHR(val) (outp(THR, val)) /* write THR */
#define wrDLL(val) (outp(DLL, val)) /* write DLL */
#define wrDLM(val) (outp(DLM, val)) /* write DLM */
#define wrIER(val) (outp(IER, val)) /* write IER */
#define wrFCR(val) (outp(FCR, val)) /* write FCR */
#define wrLCR(val) (outp(LCR, val)) /* write LCR */
#define wrMCR(val) (outp(MCR, val)) /* write MCR */
#define wrLSR(val) (outp(LSR, val)) /* write LSR */
#define wrMSR(val) (outp(MSR, val)) /* write MSR */
#define wrSCR(val) (outp(SCR, val)) /* write SCR */
/* end of serio.h */


  3 Responses to “Category : Tutorials + Patches
Archive   : NAT_UART.ZIP
Filename : SERIO.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/