[PATCH v2 1/3] commands: add pwm manipulation command

marc at cpdesign.com.au marc at cpdesign.com.au
Mon May 29 04:03:52 PDT 2023


Hi,

Thanks for your comments. ..

> > +	if ((state.period_ns == 0)
> > +			&& (freq < 0) && (duty < 0) && (period < 0)) {
> > +		printf(" need to know some timing info; freq or dury/
period\n");
> 
> typo: s/dury/duty/
> 
> > +	    pwm_free(pwm);
> 
> indentation
> 


Fixed in v3

> > +		return COMMAND_ERROR_USAGE;
> > +	}
> > +
> > +	if (invert_polarity >= 0)
> > +		state.polarity = invert_polarity;
> > +
> > +	/* period */
> > +	if (freq > 0) {
> > +		state.p_enable = true;
> > +		state.period_ns = HZ_TO_NANOSECONDS(freq);
> > +		if (width < 0) {
> > +			width = 50;
> > +		}
> > +	} else if (period > 0) {
> > +		state.p_enable = true;
> > +		state.period_ns = period;
> > +	}
> > +
> > +	/* duty */
> > +	if (width >= 0) {
> > +		pwm_set_relative_duty_cycle(&state, width, 100);
> > +	} else if (duty >= 0) {
> > +		if (duty > state.period_ns)
> > +			printf(" warning: duty_ns is greater than 
period\n");
> > +
> > +		state.duty_ns = duty;
> > +	}
> > +
> > +	error = pwm_apply_state(pwm, &state);
> > +
> > +	if (stop > 0) {
> > +		state.p_enable = false;
> > +		error = pwm_apply_state(pwm, &state);
> > +	}
> > +
> > +	pwm_free(pwm);
> > +
> > +	return error;
> 
> nit: return 0
> 

This I didn't change - error is propagating return value of pwm_apply_state()

I also fixed your other comments for pwm_get (including the somewhat 
embarrassing ^S :/ )

Cheers
Marc






More information about the barebox mailing list