From: Frank Mori Hess Date: Tue, 7 Mar 2006 02:37:01 +0000 (+0000) Subject: Changed INSN_CONFIG_PWM_OUTPUT so the rounding mode for the up and X-Git-Tag: r0_7_71~50 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cda8c5010c283c09cfa869a68f85e419edcb0443;p=comedi.git Changed INSN_CONFIG_PWM_OUTPUT so the rounding mode for the up and down times can be set independently. --- diff --git a/Documentation/comedi/insn_config b/Documentation/comedi/insn_config index 9a2b60e3..69705143 100644 --- a/Documentation/comedi/insn_config +++ b/Documentation/comedi/insn_config @@ -187,6 +187,13 @@ ID=INSN_CONFIG_PWM_OUTPUT: Configure a pulse-width-modulation output. Returns EAGAIN error with modified values if exact timing is not achievable. [0] - ID - [1] - flags (rounding mode for up/down times: TRIG_ROUND_NEAREST, etc.) + [1] - up time flags (rounding mode for time: TRIG_ROUND_NEAREST, etc.) [2] - up time (nanoseconds) - [3] - down time (nanoseconds) + [3] - down time flags (rounding mode for time: TRIG_ROUND_NEAREST, etc.) + [4] - down time (nanoseconds) + +ID=INSN_CONFIG_GET_PWM_OUTPUT: Query a pulse-width-modulation output. + + [0] - ID + [1] - up time (nanoseconds) + [2] - down time (nanoseconds) diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index ca276cac..cb92c71c 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -3352,29 +3352,41 @@ static int ni_m_series_pwm_config(comedi_device *dev, comedi_subdevice *s, { case TRIG_ROUND_NEAREST: up_count = (data[2] + TIMER_BASE / 2) / TIMER_BASE; - down_count = (data[3] + TIMER_BASE / 2) / TIMER_BASE; break; case TRIG_ROUND_DOWN: up_count = data[2] / TIMER_BASE; - down_count = data[3] / TIMER_BASE; break; case TRIG_ROUND_UP: up_count = (data[2] + TIMER_BASE - 1) / TIMER_BASE; - down_count = (data[3] + TIMER_BASE - 1) / TIMER_BASE; + break; + default: + return -EINVAL; + break; + } + switch(data[3]) + { + case TRIG_ROUND_NEAREST: + down_count = (data[4] + TIMER_BASE / 2) / TIMER_BASE; + break; + case TRIG_ROUND_DOWN: + down_count = data[4] / TIMER_BASE; + break; + case TRIG_ROUND_UP: + down_count = (data[4] + TIMER_BASE - 1) / TIMER_BASE; break; default: return -EINVAL; break; } if(up_count * TIMER_BASE != data[2] || - down_count * TIMER_BASE != data[3]) + down_count * TIMER_BASE != data[4]) { data[2] = up_count * TIMER_BASE; - data[3] = down_count * TIMER_BASE; + data[4] = down_count * TIMER_BASE; return -EAGAIN; } ni_writel(MSeries_Cal_PWM_High_Time_Bits(up_count) | MSeries_Cal_PWM_Low_Time_Bits(down_count), M_Offset_Cal_PWM); - return 4; + return 5; break; default: return -EINVAL; @@ -3394,30 +3406,42 @@ static int ni_6143_pwm_config(comedi_device *dev, comedi_subdevice *s, { case TRIG_ROUND_NEAREST: up_count = (data[2] + TIMER_BASE / 2) / TIMER_BASE; - down_count = (data[3] + TIMER_BASE / 2) / TIMER_BASE; break; case TRIG_ROUND_DOWN: up_count = data[2] / TIMER_BASE; - down_count = data[3] / TIMER_BASE; break; case TRIG_ROUND_UP: up_count = (data[2] + TIMER_BASE - 1) / TIMER_BASE; - down_count = (data[3] + TIMER_BASE - 1) / TIMER_BASE; + break; + default: + return -EINVAL; + break; + } + switch(data[3]) + { + case TRIG_ROUND_NEAREST: + down_count = (data[4] + TIMER_BASE / 2) / TIMER_BASE; + break; + case TRIG_ROUND_DOWN: + down_count = data[4] / TIMER_BASE; + break; + case TRIG_ROUND_UP: + down_count = (data[4] + TIMER_BASE - 1) / TIMER_BASE; break; default: return -EINVAL; break; } if(up_count * TIMER_BASE != data[2] || - down_count * TIMER_BASE != data[3]) + down_count * TIMER_BASE != data[4]) { data[2] = up_count * TIMER_BASE; - data[3] = down_count * TIMER_BASE; + data[4] = down_count * TIMER_BASE; return -EAGAIN; } ni_writel(up_count, Calibration_HighTime_6143); ni_writel(down_count, Calibration_LowTime_6143); - return 4; + return 5; break; default: return -EINVAL;