Added INSN_CONFIG_GET_PWM_OUTPUT config insn.
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 7 Mar 2006 02:44:34 +0000 (02:44 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 7 Mar 2006 02:44:34 +0000 (02:44 +0000)
comedi/drivers/ni_mio_common.c
comedi/drivers/ni_stc.h
include/linux/comedi.h

index cb92c71c217ee70683b996636c736dc95b8da4d3..0e72d7c35a18d45bd5d6461f69b424b631055ec0 100644 (file)
@@ -3341,6 +3341,13 @@ static int ni_m_series_eeprom_insn_read(comedi_device *dev,comedi_subdevice *s,
        return 1;
 }
 
+static int ni_get_pwm_config(comedi_device *dev, lsampl_t *data)
+{
+       data[1] = devpriv->pwm_up_count * TIMER_BASE;
+       data[2] = devpriv->pwm_down_count * TIMER_BASE;
+       return 3;
+}
+
 static int ni_m_series_pwm_config(comedi_device *dev, comedi_subdevice *s,
        comedi_insn *insn, lsampl_t *data)
 {
@@ -3386,8 +3393,13 @@ static int ni_m_series_pwm_config(comedi_device *dev, comedi_subdevice *s,
                        return -EAGAIN;
                }
                ni_writel(MSeries_Cal_PWM_High_Time_Bits(up_count) | MSeries_Cal_PWM_Low_Time_Bits(down_count), M_Offset_Cal_PWM);
+               devpriv->pwm_up_count = up_count;
+               devpriv->pwm_down_count = down_count;
                return 5;
                break;
+       case INSN_CONFIG_GET_PWM_OUTPUT:
+               return ni_get_pwm_config(dev, data);
+               break;
        default:
                return -EINVAL;
                break;
@@ -3440,9 +3452,13 @@ static int ni_6143_pwm_config(comedi_device *dev, comedi_subdevice *s,
                        return -EAGAIN;
                }
                ni_writel(up_count, Calibration_HighTime_6143);
+               devpriv->pwm_up_count = up_count;
                ni_writel(down_count, Calibration_LowTime_6143);
+               devpriv->pwm_down_count = down_count;
                return 5;
                break;
+       case INSN_CONFIG_GET_PWM_OUTPUT:
+               return ni_get_pwm_config(dev, data);
        default:
                return -EINVAL;
                break;
index 0d98b8d702d27232540dd28dde45b2c749f613e7..29f091f3c89f909b3276db5129d531e6d2668a61 100644 (file)
@@ -1145,7 +1145,10 @@ static ni_board ni_boards[];
        unsigned short atrig_mode;                              \
        unsigned short atrig_high;                              \
        unsigned short atrig_low;                               \
-                                                               \
+       \
+       unsigned short pwm_up_count;    \
+       unsigned short pwm_down_count;  \
+       \
        sampl_t ai_fifo_buffer[0x2000];                         \
        uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE];
        
index 698ad1e006122096f653f6c71d7000ec9c865c6e..f18d55c4ab68eb7eb5dc905bab2a4af6fb7f1e11 100644 (file)
@@ -238,6 +238,7 @@ enum configuration_ids
        INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
        INSN_CONFIG_DIO_QUERY = 28,
        INSN_CONFIG_PWM_OUTPUT = 29,
+       INSN_CONFIG_GET_PWM_OUTPUT = 30,
        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