/* * ce_subMTBctl.c An EPICS subroutine record code module. * * This module will be used with a SUBroutine record to interface with * a LabVIEW program (EPICS_EDDTG.exe) to control * an MTB module in a PC from EPICS. Also see subroutine code * ce_subMTBsts to be used to view status * information from the MTB Channel. * * Reference the document "EPICS/LabVIEW MTB Programming Guide" to * determine the field-usage and bit-meanings, etc... * * Rev 0 17NOV03 ps Created * */ #include #include #include #include #include #include #include long ce_MTBctlInit(psub) struct subRecord *psub; { /* clear UDF */ psub->udf = 0; return(0); } long ce_MTBctl(psub) struct subRecord *psub; { int pgm_event,pgm_mode,pgm_STcode,pgm_pers,pgm_load, pgm_arm, pgm_enable, pgm_sendST; /* get control parms */ pgm_event = psub->a; pgm_mode = psub->d; pgm_pers = psub->e; pgm_load = psub->f; pgm_enable = psub->g; pgm_arm = psub->h; pgm_sendST = psub->j; pgm_STcode = psub->i; /* build composite control word */ psub->val = (pgm_load & 0x1) + ((pgm_enable & 0x1)<<1) + ((pgm_arm & 0x1)<<2) + ((pgm_sendST & 0x1)<<3) + ((pgm_mode & 0xF)<<4) + ((pgm_event & 0xFF)<<8) + ((pgm_STcode & 0xFF)<<16) + ((pgm_pers & 0x7)<<24); return(0); }