/*******************************************************************/ /* */ /* Advanced Communication Borad Developer Toolkit 1993 */ /* (c)Copyright 1993-1995, Sealevel Systems Incorporated */ /* */ /*******************************************************************/ /* Please read the program abstract for details on this */ /* program. */ /* POLL2.C */ /*******************************************************************/ #include #include #include #include "acb.h" /* build with ACB.OBJ */ #include "Z8530.h" /*******************************************************************/ /* Things to make the program "compiler friendly"! */ /*******************************************************************/ #ifndef _BORLAND #define IN _inp #define OUT _outp #define FAR __far #else #define IN inportb #define OUT outportb #define FAR far #endif /*******************************************************************/ /* Functions Prototypes */ /*******************************************************************/ int main(void); /*******************************************************************/ #define PORT 0x238 /*base address of 238 hex */ #define ESC 27 /*keyboard character to terminate program*/ #define MAXFRAME 100 /*Maximum HDLC\SDLC frame to receive */ /*******************************************************************/ /* Z85x30 Init Values */ /*******************************************************************/ #define PRAM_COUNT 54 unsigned char init[PRAM_COUNT]= { WR0,NULL_CODE, /* MODES */ WR4, X1_CLOCK | SYNC_MODE_ENABLE | SDLC_MODE, WR1, WAIT_DMA_DISABLE | INT_DISABLE, WR2, 0x00, /* not used in polled mode */ WR3, RX_8_BITS | RX_CRC_ENABLE | SYNC_CHAR_LOAD_INHIBIT , WR5, TX_8_BITS | CRC_SDLC | TX_CRC_ENABLE, WR6, 0x00, /* not used-SDLC Address field */ WR7, 0x7e, /* SDLC Flag */ WR9, MI_DISABLE, WR10, CRC_PRESET_TO_ZERO, WR11, TX_CLK_BRG | RX_CLK_RTXC_PIN | TRXC_IS_OUTPUT | TRXC_OUT_BRG, WR12, 0xfe, /*time constant-low byte 4800 Baud*/ WR13, 0x01, /*time constant-high byte */ WR14, BRG_SOURCE_PCLK | DPLL_NULL, WR14, BRG_SOURCE_PCLK | DPLL_NULL, WR14, BRG_SOURCE_PCLK | DPLL_NULL, WR14, BRG_ENABLE | BRG_SOURCE_PCLK | DPLL_NULL, /* ENABLES */ WR3, RX_8_BITS | RX_CRC_ENABLE | SYNC_CHAR_LOAD_INHIBIT | RX_ENABLE, WR5, TX_8_BITS | CRC_SDLC | TX_CRC_ENABLE | TX_ENABLE, WR0, RESET_TX_CRC, WR0, ERROR_RESET, WR1, WAIT_DMA_DISABLE | INT_DISABLE, WR15, NO_EXT_STAT_INT, /*INTERRUPT*/ WR0, RESET_EXT_STATUS_INT, WR0, RESET_EXT_STATUS_INT, WR1, WAIT_DMA_DISABLE | INT_DISABLE, WR9, MI_DISABLE }; /*******************************************************************/ /* end of init table, adjust variable PRAM_COUNT after modifying */ /*******************************************************************/ unsigned char rxbuff[MAXFRAME]; unsigned short rxptr = 0; /*******************************************************************/ /* Start of main program */ /*******************************************************************/ int main(void) { unsigned char c = 0; unsigned char x = 0; void FAR *p; /*******************************************************************/ /* Verify Address of SCC (85x30) */ /*******************************************************************/ SCCout(PORT, WR2, 0x55); /*write to WR2*/ if (SCCin(PORT, RR2) != 0x55) /*read back RR2*/ { printf("\nError: Device not found at address %x HEX.\n",PORT); return(1); /*return code 1 for ERROR*/ } else { printf("\nDevice verified at address %x HEX.\n",PORT); } /*******************************************************************/ /* Initialize ACB card */ /*******************************************************************/ SCCout(PORT, WR9, FORCE_HW_RESET); /* channel reset A and B */ p = &init[0]; SCCInitEx(PORT, p, PRAM_COUNT); /* Initialize ACB */ /*******************************************************************/ /* Terminal */ /*******************************************************************/ printf("\n"); do { if (_bios_keybrd(_KEYBRD_READY)) /*SW INT 16 hex function 1*/ { x = (unsigned char)(_bios_keybrd(_KEYBRD_READ)); if (x != ESC) { OUT(PORT, x); /* write character to data port */ SCCout(PORT, WR0, RESET_TX_UR_EOM); /*reset TX underrun */ } } /* end if */ if (SCCin(PORT, RR0) & RX_CHAR_AVAIL) /* if RX char available? */ { c = (unsigned char) IN(PORT); rxbuff[rxptr] = c; /*put char in buffer*/ rxptr++; if (END_OF_FRAME & (SCCin(PORT, RR1))) /*Note this strips off*/ { rxptr = rxptr-2; /* the 16 bit CRC at the*/ if (rxptr > MAXFRAME+1) /* end of the Frame */ { printf("\n\nError: SDLC Frame Buffer Full.\n"); rxptr = 0; break; } rxbuff[rxptr] = 0; printf("%s",rxbuff); /*Frame exclude the CRC */ rxptr = 0; } } /* end if */ } while (x != ESC); /* end do while*/ return(0); } /*******************************************************************/ /* End of File */ /*******************************************************************/