Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual
Page 153
Chapter
Programming the Scanner
8
8Ć19
/*
**
** MAP_CHANNEL() –– map a 6008SV2 channel
**
**
This function accepts a channel structure as input, and maps the E–page VMEbus window
**
to the specified channel. The function then initializes the channel structure
**
pointers to the various objects in the channel window (e.g., discrete I/O tables,
**
control/status area, and so forth.
**
**
parameters:
pointer to channel structure
**
return value:
none
*/
void
map_channel (channel far *chan)
{
char far
*base;
/* save current bus state */
EpcSaveState(&chan–>stash);
/* get pointer to base of scanner memory */
if (EpcSetAmMap(chan–>AddressMode, chan–>ScannerAddress,
(void far * far *) &base) != EPC_SUCCESS) {
fprintf(stderr, ”cannot map target scanner memory\n”);
exit(–1);
}
/*
** establish pointers to scanner objects
*/
if (chan–>ScannerMode == MODE_COMPATIBLE) {
/* output table at base of global memory */
chan–>OutputTable = &base[SVC_OTABLE_OFFSET];
/* input table at offset 80H */
chan–>InputTable = (char far *) &base[SVC_ITABLE_OFFSET];
/* control/status area at offset 100H */
chan–>ControlStatusArea = (char far *) &base[SVC_CSA_OFFSET];
/* general data area at offset 120H */
chan–>GeneralDataArea = (char far *) &base[SVC_GDA_OFFSET];
/* continuous block transfer write table */
chan–>ConBTWTable = (char far *) NULL;
/* continuous block transfer read table */
chan–>ConBTRTable = (char far *) NULL;
/* reset area at offset FBCH */
chan–>ResetArea = (char far *) &base[SVC_RESET_OFFSET];
/* vme ID area at offset FC0H */
chan–>VmeIdArea = (char far *) &base[SVC_VIA_OFFSET];