예제 #1
0
파일: ehrpwm.c 프로젝트: BorisTw/BBB-kernel
static int ehrpwm_pwm_config(struct pwm_device *p,
	struct pwm_config *c)
{
	int ret = 0;

	switch (c->config_mask) {
	case BIT(PWM_CONFIG_PERIOD_TICKS):
		if (p->max_period_ticks &&
				(p->max_period_ticks >= c->period_ticks))
			p->period_ticks = p->max_period_ticks;
		else
			p->period_ticks = c->period_ticks;

		ret = ehrpwm_pwm_set_prd(p);
		break;

	case BIT(PWM_CONFIG_DUTY_TICKS):
		p->duty_ticks = c->duty_ticks;
		ret = ehrpwm_pwm_set_dty(p);
		break;

	case BIT(PWM_CONFIG_POLARITY):
		p->active_high = c->polarity;
		ret = ehrpwm_pwm_set_pol(p);
		break;

	case BIT(PWM_CONFIG_START):
		 ret = ehrpwm_pwm_start(p);
		 break;

	case BIT(PWM_CONFIG_STOP):
		ret = ehrpwm_pwm_stop(p);
		break;

	default:
		dev_dbg(p->dev, "%s: Invalid configuration\n", __func__);
		ret = -EINVAL;
	}

	return ret;
}
예제 #2
0
int mdaq_pwm_start(uint8_t channel)
{
#if (!defined MATLAB_MEX_FILE) && (!defined MDL_REF_SIM_TGT)
	return ehrpwm_pwm_start(channel);
#endif 
}