From faf417ec91dbb65037ad18cf3d4bb252b8d410ef Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Fri, 5 Jan 2007 15:25:43 +0000 Subject: [PATCH] Renamed INSN_CONFIG_RESET_COUNT to more general INSN_CONFIG_RESET. 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 | 2 +- comedi/drivers/ni_tio.c | 18 +++++++++++++----- include/linux/comedi.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index ec5db182..32f9bf14 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -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: diff --git a/comedi/drivers/ni_tio.c b/comedi/drivers/ni_tio.c index e764e31d..52520562 100644 --- a/comedi/drivers/ni_tio.c +++ b/comedi/drivers/ni_tio.c @@ -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]; diff --git a/include/linux/comedi.h b/include/linux/comedi.h index 7903b594..72363ec9 100644 --- a/include/linux/comedi.h +++ b/include/linux/comedi.h @@ -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 -- 2.26.2