Added INSN_CONFIG_RESET_COUNT
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 15 Dec 2006 16:34:28 +0000 (16:34 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 15 Dec 2006 16:34:28 +0000 (16:34 +0000)
comedi/comedi_fops.c
comedi/drivers/ni_tio.c
include/linux/comedi.h

index 59cd89556aae9fe1f2d8eb8916cf863ef567fb55..f41b05c6cda596c1f69453c88fe75a18c80ce596 100644 (file)
@@ -632,6 +632,7 @@ static int check_insn_config_length(comedi_insn *insn, lsampl_t *data)
        case INSN_CONFIG_DIO_INPUT:
        case INSN_CONFIG_ARM:
        case INSN_CONFIG_DISARM:
+       case INSN_CONFIG_RESET_COUNT:
                if(insn->n == 1) return 0;
                break;
        case INSN_CONFIG_DIO_QUERY:
index 39618523ceecc266057ab2f2a2796c1959c0ddce..d0077270cf7c04b7978d8c628dc5819ce27e3c29 100644 (file)
@@ -667,11 +667,15 @@ static int ni_tio_second_gate_registers_present(struct ni_gpct *counter)
        return 0;
 }
 
-void ni_tio_init_counter(struct ni_gpct *counter)
+static void ni_tio_reset_count_and_disarm(struct ni_gpct *counter)
 {
-       /* reset counter */
        counter->write_register(counter, Gi_Reset_Bit(counter->counter_index),
                NITIO_Gxx_Joint_Reset_Reg(counter->counter_index));
+}
+
+void ni_tio_init_counter(struct ni_gpct *counter)
+{
+       ni_tio_reset_count_and_disarm(counter);
        /* initialize counter registers */
        counter->regs[NITIO_Gi_Autoincrement_Reg(counter->counter_index)] = 0x0;
        counter->write_register(counter, counter->regs[NITIO_Gi_Autoincrement_Reg(counter->counter_index)],
@@ -1702,6 +1706,10 @@ int ni_tio_insn_config(struct ni_gpct *counter,
        case INSN_CONFIG_GET_GATE_SRC:
                return ni_tio_get_gate_src(counter, data[1], &data[2]);
                break;
+       case INSN_CONFIG_RESET_COUNT:
+               ni_tio_reset_count_and_disarm(counter);
+               return 0;
+               break;
        default:
                break;
        }
index 829c7549ed6f2802a159fb9affcaebe1ff98ab54..3c4059c5c1709a1d90d62e81d7d3640aa40abbeb 100644 (file)
@@ -242,6 +242,7 @@ enum configuration_ids
        INSN_CONFIG_ARM = 31,
        INSN_CONFIG_DISARM = 32,
        INSN_CONFIG_GET_COUNTER_STATUS = 33,
+       INSN_CONFIG_RESET_COUNT = 34,
        INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, // Use CTR as single pulsegenerator
        INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, // Use CTR as pulsetraingenerator
        INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, // Use the counter as encoder