/* Copyright (C) Magna Carta Software, Inc. 1990, 1991. All Rights Reserved NS16550A.C -- Routines specific to the National Semiconductor NS16550x family. */ #include #if (defined(MSC) || defined(__WATCOMC__) || defined(__HIGHC__)) #include #endif /* SET_16550_THRESHOLD -- Set the interrupt threshold level and enable the FIFOs on the NS16550A. Parameters: COMM_PORT *p -- a ptr. to the port; WORD count -- the desired interrupt threshold level; valid values: 0 -- switch to 16450 mode; 1 -- interrupt when one character arrives in the buffer; 4 -- interrupt when four characters arrive in the buffer; 8 -- interrupt when eight characters arrive in the buffer; 14 -- interrupt when fourteen characters arrive in the buffer; Return value: EOF -- 16550A not present on the designated port; -2 -- invalid 16550A threshold level specified; 0 -- normal return; */ short set_16550_threshold(COMM_PORT *p, WORD count) { short val; if (isauart(p->ubase_addr) != 3) return (EOF); if (count) { switch (count) { case 1: val = 0; break; case 4: val = 1; break; case 8: val = 2; break; case 14: val = 3; break; default: val = -2; } if (val != -2) { /* INITIALIZE FIFO MODE */ outp(p->ubase_addr+2, 1); /* SET THRESHOLD LEVEL */ outp(p->ubase_addr+2, (val << 6) | 1); p->utype = (val << 8) | (BYTE) NS16550A; } } else { /* SWITCH TO 16450 MODE */ outp(p->ubase_addr+2, 0); } return ((val < 0) ? val : 0); }