Title: Software Examples for 5 Bit, 1.5 Stop Bits Under DOS
Keywords: DOS Data_bits Stop_bits
KDB: KDB-037
Revision: 0.00
Author: Support
Distribution: External
This file contains 3 files: cti5bit.c, z80c.h and cti5bit.mak.
These are intended to be used as samples and examples
for setting Intellicon cards into 5 bit, 1.5 stop bits under DOS.
*****************File: cti5bit.c*********************** /* Title : CTI5BIT.C * Author : Allan Smith * Project : Intellicon * Date : June 10, 1994 * Revised : * * This program will set port 0 to 5 bits 1.5 stop bits * ** Copyright (c) 1994 CTI, Connect Tech Inc. All Rights Reserved. ** ** THIS IS THE UNPUBLISHED PROPRIETARY SOURCE CODE OF CONNECT TECH INC. ** The copyright notice above does not evidence any actual or intended ** publication of such source code. ** ** This module contains Proprietary Information of Connect Tech, Inc ** and should be treated as Confidential. * ******************************************************************************/ #include #include #include #include #include "z80c.h" #define COMM_INT 0x14 /* Communications interrupt 14h */ #define ID_FN 0x06 /* function that ids our port and # of fns */ #define CTTY_FN 0x12 /* funciton that changes and reports options */ #define QUERY_FN 0x0c /* function that reads Intellicon params */ #define EINIT_FN 0x04 /* function that inits port */ #define USE_Z80CE 0x8000 #define Z80_NULL_CODE 0 #define Z80_NMI_CMD 0x0d #define Z80_NMI_DEV 0x0c #define NMI_STTY 2 struct z80ce_defs z80ce; /* ctty structure */ unsigned int ctiseg = 0xd000; unsigned int ctiioport = 0x300; void load_ce( struct z80ce_defs *z80ce_ptr, unsigned short port_no ); void set_ce( struct z80ce_defs *z80ce_ptr, unsigned short port_no ); int atoh( char *string ); void z80_command( unsigned char port, unsigned char cmd ); char get_digit( char c ); void main( int argc, char *argv[] ){ if( argc == 1 ){ printf( "USE: cti5bit [io_port] [segment]\n" ); printf( " io_port defaults to 0x300 and segment defaults to 0xd000\n" ); exit( 0 ); } if( argc >= 3 ) ctiioport = atoh( argv[2] ); if( argc >= 4 ) ctiseg = atoh( argv[3] ); load_ce( &z80ce, atoi( argv[1] )); z80ce.data_bits = 5; z80ce.stop_bits = 2; /* 2 == 1.5, 3 == 2 */ set_ce( &z80ce, atoi( argv[1] )); z80_command( (unsigned char)atoi( argv[1] ), NMI_STTY ); outp( ctiioport+1, 0 ); } void load_ce( struct z80ce_defs *z80ce_ptr, unsigned short port_no ){ union _REGS regs; struct _SREGS segs; _segread( &segs ); segs.es = segs.ds; regs.x.ax = CTTY_FN<<8; regs.x.bx = USE_Z80CE; regs.x.dx = port_no; regs.x.cx = 0; /* query */ regs.x.si = (unsigned)z80ce_ptr; _int86x( COMM_INT, ®s, ®s, &segs ); } void set_ce( struct z80ce_defs *z80ce_ptr, unsigned short port_no ){ union _REGS regs; struct _SREGS segs; _segread( &segs ); segs.es = segs.ds; regs.x.ax = CTTY_FN<<8; regs.x.bx = USE_Z80CE; regs.x.dx = port_no; regs.x.cx = USE_Z80CE; /* set */ regs.x.si = (unsigned)z80ce_ptr; _int86x( COMM_INT, ®s, ®s, &segs ); } /********************************************************************** ** Function: atoh ** ** Routine to convert an ascii string to hex number ** ** Arguments: ** string hex string to be converted into an integer **********************************************************************/ int atoh( char *string ) { int digit, result; result = 0; while( ( digit = get_digit( *string++ ) ) != -1 ) result = result * 16 + digit; return( result ); } /********************************************************************** ** Function: get_digit ** ** Routine to convert a single ascii digit to hex ** ** Arguments: ** c a single ascii digit to be converted to hex **********************************************************************/ char get_digit( char c ) { if ( ( c >= '0' ) && ( c <= '9' ) ) return( c - '0' ); if ( ( c >= 'a' ) && ( c <= 'f' ) ) return( c - 'a' + 10 ); if ( ( c >= 'A' ) && ( c <= 'F' ) ) return( c - 'A' + 10 ); return( -1 ); } void z80_command( unsigned char port, unsigned char cmd ){ unsigned char _far *z80_cmd; unsigned char _far *z80_dev; long i; z80_cmd = _MK_FP( ctiseg, Z80_NMI_CMD ); _disable(); while( 1 ){ if( *z80_cmd == Z80_NULL_CODE ) /* wait till last command is done */ break; /* exit loop */ _enable(); /* make sure ints are on while waiting */ for( i = 0; i < 100000; ++i ) /* time delay */ ; _disable(); } z80_dev = MK_FP( ctiseg, Z80_NMI_DEV ); *z80_dev = port; *z80_cmd = cmd; _enable(); } *****************End File: cti5bit.c*********************** *****************File: z80c.h*********************** /* * Z80 channel entry defs */ #pragma pack(1) struct z80ce_defs { unsigned char device; unsigned short options; unsigned char page; unsigned char type; unsigned char brk; unsigned char escape; unsigned char rubout; unsigned char cancel; unsigned char eot; unsigned char up; unsigned char right; unsigned char down; unsigned char left; unsigned char home; unsigned char clear; unsigned char function; unsigned char insert; unsigned char _delete; unsigned char row; unsigned char col; unsigned short baud; unsigned char parity; unsigned char stop_bits; unsigned char data_bits; unsigned short tty_options; unsigned short in; unsigned short out; unsigned short mdm_port_status; unsigned short out_xon_xoff; unsigned short in_xon_xoff; unsigned char line_status; unsigned short count; unsigned char inb1; unsigned char num_in; unsigned char outb1; unsigned char num_out; unsigned char misc; unsigned char reserved[10]; }; #pragma pack() *****************End File: z80c.h*********************** *****************File: cti5bit.mak*********************** # Microsoft Visual C++ generated build script - Do not modify PROJ = CTI5BIT DEBUG = 0 PROGTYPE = 6 CALLER = ARGS = DLLS = D_RCDEFINES = -d_DEBUG R_RCDEFINES = -dNDEBUG ORIGIN = MSVC ORIGIN_VER = 1.00 PROJPATH = D:\JOBS\CTISETT\ USEMFC = 0 CC = cl CPP = cl CXX = cl CCREATEPCHFLAG = CPPCREATEPCHFLAG = CUSEPCHFLAG = CPPUSEPCHFLAG = FIRSTC = FIRSTCPP = ASSIGN1A.CPP RC = rc CFLAGS_D_DEXE = /nologo /W3 /FR /G2 /Zi /D_DEBUG /Od /AM /D_DOS /Fd"CTI5BIT.PDB" CFLAGS_R_DEXE = /nologo /W3 /FR /G2 /DNDEBUG /Gs /Ox /AM /D_DOS LFLAGS_D_DEXE = /NOLOGO /ONERROR:NOEXE /NOI /CO /STACK:5120 LFLAGS_R_DEXE = /NOLOGO /ONERROR:NOEXE /NOI /STACK:5120 LIBS_D_DEXE = oldnames mlibce LIBS_R_DEXE = oldnames mlibce RCFLAGS = /nologo RESFLAGS = /nologo RUNFLAGS = OBJS_EXT = LIBS_EXT = !if "$(DEBUG)" == "1" CFLAGS = $(CFLAGS_D_DEXE) LFLAGS = $(LFLAGS_D_DEXE) LIBS = $(LIBS_D_DEXE) MAPFILE = nul RCDEFINES = $(D_RCDEFINES) !else CFLAGS = $(CFLAGS_R_DEXE) LFLAGS = $(LFLAGS_R_DEXE) LIBS = $(LIBS_R_DEXE) MAPFILE = nul RCDEFINES = $(R_RCDEFINES) !endif !if [if exist MSVC.BND del MSVC.BND] !endif SBRS = CTI5BIT.SBR CTI5BIT_DEP = d:\jobs\ctisett\z80c.h all: $(PROJ).EXE $(PROJ).BSC CTI5BIT.OBJ: CTI5BIT.C $(CTI5BIT_DEP) $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c CTI5BIT.C $(PROJ).EXE:: CTI5BIT.OBJ $(OBJS_EXT) $(DEFFILE) echo >NUL @<<$(PROJ).CRF CTI5BIT.OBJ + $(OBJS_EXT) $(PROJ).EXE $(MAPFILE) c:\msvc\lib\+ c:\msvc\mfc\lib\+ $(LIBS) $(DEFFILE); << link $(LFLAGS) @$(PROJ).CRF run: $(PROJ).EXE $(PROJ) $(RUNFLAGS) $(PROJ).BSC: $(SBRS) bscmake @<< /o$@ $(SBRS) *****************End File: cti5bit.mak***********************
End of KDB-037