/// <summary> /// Setting Line 1 or 2 in the input lines to be a counter /// </summary> /// <param name="mode"> /// AD_CNT_COUNTER = 0; /// AD_CNT_UPDOWN = 1; /// AD_CNT_QUAD_DECODER = 4; /// AD_CNT_PULSE_TIME = 5; /// </param> /// <param name="enable_rst"></param> public void SetCounter(int mode, bool enable_rst, int line) { // Set counter mode enableCounterReset = enable_rst; int rc; if (mode >= 0) { ad_counter_mode par; /* Setup counter mode, using Port A/1 and Port A/2 as * both counter inputs. The counter's reset input * gets connected to Port A/3 (if enabled). */ par = new ad_counter_mode(); par.cha = AD_CHA_TYPE_COUNTER | line; par.mode = (byte)(mode & 0xff); par.mux_a = 0; par.mux_b = 1; if (enable_rst) { par.mux_rst = 2; par.flags |= AD_CNT_ENABLE_RST; } rc = ad_set_counter_mode(adh, ref par); if (rc != 0) { Log.Error("error: failed to setup BMCM counter. Error = " + rc); return; } } }
public static int ad_get_counter_mode(int adh, ref ad_counter_mode mode) { return(ad_ioctl_counter_mode(adh, AD_GET_COUNTER_MODE, ref mode, Marshal.SizeOf(mode))); }
private static extern int ad_ioctl_counter_mode(int adh, uint ioc, ref ad_counter_mode par, int size);