Renamed INSN_CONFIG_RESET_COUNT to more general INSN_CONFIG_RESET.
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 5 Jan 2007 15:25:43 +0000 (15:25 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 5 Jan 2007 15:25:43 +0000 (15:25 +0000)
Made setting of count on ni general-purpose counters leave the
values of the load a/b registers, and the load source select
undisturbed.

comedi/comedi_fops.c
comedi/drivers/ni_tio.c
include/linux/comedi.h

index ec5db182bd014df5e4da1e8376d81ac8f32e1ee0..32f9bf1418544d4a6215b741671fd02ac8634123 100644 (file)
@@ -631,7 +631,7 @@ static int check_insn_config_length(comedi_insn *insn, lsampl_t *data)
        case INSN_CONFIG_DIO_OUTPUT:
        case INSN_CONFIG_DIO_INPUT:
        case INSN_CONFIG_DISARM:
-       case INSN_CONFIG_RESET_COUNT:
+       case INSN_CONFIG_RESET:
                if(insn->n == 1) return 0;
                break;
        case INSN_CONFIG_ARM:
index e764e31d5cb0ee9225462b7d0d7948d2ed40d08d..525205626659678bb07184f297d7fdf7dfed280c 100644 (file)
@@ -1818,7 +1818,7 @@ 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:
+       case INSN_CONFIG_RESET:
                ni_tio_reset_count_and_disarm(counter);
                return 0;
                break;
@@ -1877,16 +1877,24 @@ int ni_tio_winsn(struct ni_gpct *counter,
        const unsigned channel = CR_CHAN(insn->chanspec);
        const unsigned command_reg = NITIO_Gi_Command_Reg(counter->counter_index);
        const unsigned mode_reg = NITIO_Gi_Mode_Reg(counter->counter_index);
+       unsigned load_reg;
 
        if(insn->n < 1) return 0;
        switch(channel)
        {
        case 0:
-               counter->regs[NITIO_Gi_LoadA_Reg(counter->counter_index)] = data[0];
-               counter->write_register(counter, data[0], NITIO_Gi_LoadA_Reg(counter->counter_index));
-               counter->regs[mode_reg] &= ~Gi_Load_Source_Select_Bit;
-               counter->write_register(counter, counter->regs[mode_reg], mode_reg);
+               /* don't disturb load source select, just use whichever load register is already selected. */
+               if(counter->regs[mode_reg] & Gi_Load_Source_Select_Bit)
+               {
+                       load_reg = NITIO_Gi_LoadB_Reg(counter->counter_index);
+               }else
+               {
+                       load_reg = NITIO_Gi_LoadA_Reg(counter->counter_index);
+               }
+               counter->write_register(counter, data[0], load_reg);
                counter->write_register(counter, counter->regs[command_reg] | Gi_Load_Bit, command_reg);
+               /* restore state of load reg to whatever the user set last set it to */
+               counter->write_register(counter, counter->regs[load_reg], load_reg);
                break;
        case 1:
                counter->regs[NITIO_Gi_LoadA_Reg(counter->counter_index)] = data[0];
index 7903b594d81b2ba76dbbc08233a02e55b6f5d5fc..72363ec97e6576fadbc2b3a99529c75e7e7d86b5 100644 (file)
@@ -242,7 +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_RESET = 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