Exemple #1
0
FskErr mraaPWMSetDutyCycleAndPeriod(FskPinPWM pin, UInt8 dutyCycle, UInt8 period)
{
	// dutyCycle and period aer in ms
	mraaPWM mpwm = (mraaPWM)pin;
	int result;
	float dc = (float)dutyCycle;

	result = mraa_pwm_config_ms(mpwm->context, period, dc);
	if (MRAA_SUCCESS != result) {
		return kFskErrOperationFailed;
	}

	mpwm->period = period;
	mpwm->dutyCycle = dutyCycle;
	if (!mpwm->enabled) {
		mraa_pwm_enable(mpwm->context, 1);
		mpwm->enabled = 1;
	}
	return  kFskErrNone;
}
Exemple #2
0
 /**
  * Set the period and duty of a PWM object.
  *
  * @param period represented in ms.
  * @param duty represnted in ms as float.
  * @return Result of operation
  */
 mraa_result_t
 config_ms(int period, float duty)
 {
     return mraa_pwm_config_ms(m_pwm, period, duty);
 }