' ' (c)Copyright Sealevel Systems Incorporated, 1993 - 1995 ' '==================================================================== DECLARE SUB PrintMenu () DECLARE SUB FCN0 () DECLARE SUB FCN1 () DECLARE SUB FCN2 () DECLARE SUB FCN3 () DECLARE SUB FCN4 () DECLARE SUB FCN5 () DECLARE SUB FCN6 () DECLARE SUB FCN7 () DECLARE SUB FCNA () DECLARE SUB FCNB () DECLARE SUB FCNC () DECLARE SUB FCND () 'SCOM QuickBASIC Example '$INCLUDE: 'SCOM.BI' COMMON SHARED Port AS INTEGER PRINT "BASIC Serial Port Driver Demo 1994." Port = 0 TOP: PrintMenu SelM$ = INPUT$(1) PRINT SelM$ = UCASE$(SelM$) IF SelM$ = "0" THEN CALL FCN0 'InitPortCOM IF SelM$ = "1" THEN CALL FCN1 'PutCharCOM IF SelM$ = "2" THEN CALL FCN2 'GetCharCOM IF SelM$ = "3" THEN CALL FCN3 'ReqPortStatCOM IF SelM$ = "4" THEN CALL FCN4 'InitPortExCOM IF SelM$ = "5" THEN CALL FCN5 'ReqPortStatExCOM IF SelM$ = "6" THEN CALL FCN6 'GetBufferCountCOM IF SelM$ = "7" THEN CALL FCN7 'FlushBufferCOM 'IF SelM$ = "8" THEN CALL FCN0 'PutBlockCOM 'IF SelM$ = "9" THEN CALL FCN0 'GetBlockCOM IF SelM$ = "A" THEN CALL FCNA 'HandShakeConfigCOM IF SelM$ = "B" THEN CALL FCNB 'BaudRateConfigCOM IF SelM$ = "C" THEN CALL FCNC 'WritePortRegCOM IF SelM$ = "D" THEN CALL FCND 'ReadPortRegCOM 'IF SelM$ = "E" THEN CALL FCNE 'GetDrvInfo 'IF SelM$ = "F" THEN CALL FCNF 'Change Port IF SelM$ = "X" THEN GOTO STOPIT GOTO TOP STOPIT: PRINT PRINT END '==================================================================== '==================================================================== SUB FCN0 PRINT A% = InitPortCOM(Port, LBAUD + 9600 + PARITYNONE + WORDLENGTH8 + LSTOPBIT1) PRINT " Port/Modem Status ="; HEX$(A%) END SUB '==================================================================== SUB FCN1 PRINT "Character to send: " Sel$ = INPUT$(1) A% = PutCharCOM(Port, VAL(Sel$)) PRINT Sel$ PRINT " Zero if OK Tx/Character Transmitted ="; HEX$(A%) END SUB '==================================================================== SUB FCN2 PRINT A% = GetCharCOM(Port) PRINT " Line Status/Character Received ="; HEX$(A%) END SUB '==================================================================== SUB FCN3 PRINT A% = ReqPortStatCOM(Port) PRINT " Port/Modem Status ="; HEX$(A%) END SUB '==================================================================== SUB FCN4 PRINT A% = InitPortExCOM(Port, BAUD9600, NOPARITY, DATABITS8, STOPBIT1) PRINT " Port/Modem Status ="; HEX$(A%) END SUB '==================================================================== SUB FCN5 PRINT A% = ReqPortStatExCOM(Port, READMCR) PRINT " X/Modem Control Register ="; HEX$(A%) END SUB '==================================================================== SUB FCN6 PRINT A% = GetBufferCountCOM(Port, TXBUFFCOUNT) PRINT " Tx Buffer Count ="; A% A% = GetBufferCountCOM(Port, TXBUFFFREE) PRINT " Tx Buffer Free ="; A% A% = GetBufferCountCOM(Port, RXBUFFCOUNT) PRINT " Rx Buffer Free ="; A% A% = GetBufferCountCOM(Port, RXBUFFFREE) PRINT " Rx Buffer Count ="; A% END SUB '==================================================================== SUB FCN7 PRINT PRINT "Press <1> to Flush Tx, <2> to Flush Rx, <3> to Flush both."; Sel$ = INPUT$(1) PRINT Sel$ = UCASE$(Sel$) IF Sel$ = "0" THEN CALL FlushBufferCOM(Port, TXFLUSH) IF Sel$ = "1" THEN CALL FlushBufferCOM(Port, RXFLUSH) IF Sel$ = "2" THEN CALL FlushBufferCOM(Port, TXFLUSH + RXFLUSH) END SUB '==================================================================== SUB FCN8 PRINT 'PutBlockCOM END SUB '==================================================================== SUB FCN9 PRINT 'GetBlockCOM END SUB '==================================================================== SUB FCNA PRINT PRINT PRINT "Enter <0> to Set Handshake Byte or <1> to Get Handshake Byte."; Sel$ = INPUT$(1) PRINT Sel$ = UCASE$(Sel$) IF Sel$ = "0" THEN PRINT "Enter Handshake divisor in decimal:"; SelL$ = INPUT$(3) A% = HandShakeConfigCOM(Port, SETHANDSHAKE + VAL(SelL$)) END IF IF Sel$ = "1" THEN A% = HandShakeConfigCOM(Port, GETHANDSHAKE) IF Sel$ = "0" THEN PRINT " Hand Shake Setup Byte ="; HEX$(A%) END IF END SUB '==================================================================== SUB FCNB PRINT PRINT "Enter baud divisor, 0 to get present divisor."; Sel$ = INPUT$(4) PRINT Sel$ = UCASE$(Sel$) A% = BaudRateConfigCOM(Port, VAL(Sel$)) IF Sel$ = "0" THEN PRINT " Current Buad Divosor ="; HEX$(A%) END SUB '==================================================================== SUB FCNC PRINT CALL WritePortRegCOM(Port, SCRATCHREG, &H55) PRINT " 55 Hex written to UART Scratch Register" END SUB '==================================================================== SUB FCND PRINT A% = ReadPortRegCOM(Port, SCRATCHREG) PRINT " Scratch Register Contents ="; HEX$(A%) END SUB '==================================================================== SUB FCNE PRINT PRINT "Change Port To:" Sel$ = INPUT$(1) Port = VAL(Sel$) END SUB '==================================================================== SUB PrintMenu PRINT PRINT "Current Port is "; HEX$(Port) PRINT PRINT "0) InitPortCOM 1) PutCharCOMM" PRINT "2) GetCharCOM 3) ReqPortStatCOM" PRINT "4) InitPortExCOM 5) ReqPortStatExCOM" PRINT "6) GetBufferCountCOM 7) FlushBufferCOM" PRINT "8) PutBlockCOM 9) GetBlockCOM" PRINT "A) HandShakeConfigCOM B) BaudRateConfigCOM" PRINT "C) WritePortRegCOM D) ReadPortCOM" PRINT "E) ChangePort X) Exit Program " PRINT "Select Function: "; END SUB