Private
Public Access
2
0

pwm: add calls for getting PWM max and min period

Resolves #176

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Thomas Ingleby
2015-03-24 16:48:06 +00:00
parent 52c53760b2
commit 64f962d15c
3 changed files with 52 additions and 0 deletions

View File

@@ -186,6 +186,20 @@ mraa_result_t mraa_pwm_config_ms(mraa_pwm_context dev, int period, float duty);
*/ */
mraa_result_t mraa_pwm_config_percent(mraa_pwm_context dev, int period, float duty); mraa_result_t mraa_pwm_config_percent(mraa_pwm_context dev, int period, float duty);
/**
* Get the maximum pwm period in us
*
* @return max pwm in us
*/
int mraa_pwm_get_max_period();
/**
* Get the minimum pwm period in us
*
* @return min pwm in us
*/
int mraa_pwm_get_min_period();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -204,6 +204,26 @@ class Pwm
{ {
return mraa_pwm_config_percent(m_pwm, period, duty); return mraa_pwm_config_percent(m_pwm, period, duty);
} }
/**
* Get the maximum pwm period in us
*
* @return max pwm in us
*/
int
max_period()
{
return mraa_pwm_get_max_period();
}
/**
* Get the minimum pwm period in us
*
* @return min pwm in us
*/
int
min_period()
{
return mraa_pwm_get_min_period();
}
private: private:
mraa_pwm_context m_pwm; mraa_pwm_context m_pwm;

View File

@@ -452,3 +452,21 @@ mraa_pwm_config_percent(mraa_pwm_context dev, int ms, float percentage)
} }
return MRAA_SUCCESS; return MRAA_SUCCESS;
} }
int
mraa_pwm_get_max_period()
{
if (plat == NULL) {
return -1;
}
return plat->pwm_max_period;
}
int
mraa_pwm_get_min_period()
{
if (plat == NULL) {
return -1;
}
return plat->pwm_min_period;
}