From 9780aeb30b5c4cae52196f95376f654530aa1e5d Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 24 Oct 2006 15:06:10 +0000 Subject: [PATCH] Added NI_EXT_PFI() and NI_EXT_RTSI() helper functions to comedi.h for specifying pfi/rtsi lines as external trigger sources. Tweaked a couple names to match ni stc documentation more closely. --- comedi/drivers/ni_mio_common.c | 18 ++++++++++++----- include/linux/comedi.h | 36 ++++++++++++++-------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index f5d72f09..9231c628 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -4318,8 +4318,8 @@ static void ni_rtsi_init(comedi_device *dev) devpriv->stc_writew(dev, devpriv->rtsi_trig_a_output_reg, RTSI_Trig_A_Output_Register); devpriv->rtsi_trig_b_output_reg = RTSI_Trig_Output_Bits(4, NI_RTSI_OUTPUT_DA_START1) | - RTSI_Trig_Output_Bits(5, NI_RTSI_OUTPUT_G_SRC_0) | - RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE_0); + RTSI_Trig_Output_Bits(5, NI_RTSI_OUTPUT_G_SRC0) | + RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0); if(boardtype.reg_type == ni_reg_m_series) devpriv->rtsi_trig_b_output_reg |= RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC); devpriv->stc_writew(dev, devpriv->rtsi_trig_b_output_reg, @@ -4494,7 +4494,15 @@ static int ni_set_master_clock(comedi_device *dev, unsigned source, unsigned per { devpriv->rtsi_trig_direction_reg |= Use_RTSI_Clock_Bit; devpriv->stc_writew(dev, devpriv->rtsi_trig_direction_reg, RTSI_Trig_Direction_Register); - devpriv->clock_ns = period_ns; + if(devpriv->clock_ns == 0) + { + rt_printk("%s: we don't handle an unspecified clock period correctly yet, returning error.\n", + __FUNCTION__); + return -EINVAL; + }else + { + devpriv->clock_ns = period_ns; + } devpriv->clock_source = source; }else return -EINVAL; @@ -4526,8 +4534,8 @@ int ni_valid_rtsi_output_source(comedi_device *dev, unsigned chan, unsigned sour case NI_RTSI_OUTPUT_SCLKG: case NI_RTSI_OUTPUT_DACUPDN: case NI_RTSI_OUTPUT_DA_START1: - case NI_RTSI_OUTPUT_G_SRC_0: - case NI_RTSI_OUTPUT_G_GATE_0: + case NI_RTSI_OUTPUT_G_SRC0: + case NI_RTSI_OUTPUT_G_GATE0: case NI_RTSI_OUTPUT_RGOUT0: case NI_RTSI_OUTPUT_RTSI_BRD_0: return 1; diff --git a/include/linux/comedi.h b/include/linux/comedi.h index 076b088f..d6cba930 100644 --- a/include/linux/comedi.h +++ b/include/linux/comedi.h @@ -547,35 +547,29 @@ enum ni_rtsi_output NI_RTSI_OUTPUT_SCLKG = 2, NI_RTSI_OUTPUT_DACUPDN = 3, NI_RTSI_OUTPUT_DA_START1 = 4, - NI_RTSI_OUTPUT_G_SRC_0 = 5, - NI_RTSI_OUTPUT_G_GATE_0 = 6, + NI_RTSI_OUTPUT_G_SRC0 = 5, + NI_RTSI_OUTPUT_G_GATE0 = 6, NI_RTSI_OUTPUT_RGOUT0 = 7, NI_RTSI_OUTPUT_RTSI_BRD_0 = 8, - NI_RTSI_OUTPUT_RTSI_OSC = 12 /* m-series only */ + NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock on line 7 */ }; static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) { return NI_RTSI_OUTPUT_RTSI_BRD_0 + n; } -/* NI External Trigger lines */ -#define NI_EXT_PFI_0 0 -#define NI_EXT_PFI_1 1 -#define NI_EXT_PFI_2 2 -#define NI_EXT_PFI_3 3 -#define NI_EXT_PFI_4 4 -#define NI_EXT_PFI_5 5 -#define NI_EXT_PFI_6 6 -#define NI_EXT_PFI_7 7 -#define NI_EXT_PFI_8 8 -#define NI_EXT_PFI_9 9 -#define NI_EXT_RTSI_0 10 -#define NI_EXT_RTSI_1 11 -#define NI_EXT_RTSI_2 12 -#define NI_EXT_RTSI_3 13 -#define NI_EXT_RTSI_4 14 -#define NI_EXT_RTSI_5 15 -#define NI_EXT_RTSI_6 16 +/* NI External Trigger lines. These values are not arbitrary, but are related to + the bits required to program the board (offset by 1 for historical reasons). */ +static inline unsigned NI_EXT_PFI(unsigned pfi_channel) +{ + if(pfi_channel < 10) return pfi_channel; + else return pfi_channel + 10; +} +static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) +{ + if(rtsi_channel < 7) return 10 + rtsi_channel; + else return 19 + rtsi_channel; +} #ifdef __cplusplus } -- 2.26.2