From 4fab7c06d1b0c9e61f6106b5b2a5c2c0b5694c34 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 13 Oct 2010 11:45:07 +0000 Subject: ADC, SPI, PWM driver enhancements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2254 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/templates/pwm_lld.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'os/hal/templates') diff --git a/os/hal/templates/pwm_lld.h b/os/hal/templates/pwm_lld.h index 6d499d791..07ce6eb06 100644 --- a/os/hal/templates/pwm_lld.h +++ b/os/hal/templates/pwm_lld.h @@ -73,6 +73,25 @@ typedef struct PWMDriver PWMDriver; */ typedef void (*pwmcallback_t)(PWMDriver *pwmp); +/** + * @brief PWM driver channel configuration structure. + * @note Some architectures may not be able to support the channel mode + * or the callback, in this case the fields are ignored. + */ +typedef struct { + /** + * @brief Channel active logic level. + */ + pwmmode_t pcc_mode; + /** + * @brief Channel callback pointer. + * @note This callback is invoked on the channel compare event. If set to + * @p NULL then the callback is disabled. + */ + pwmcallback_t pcc_callback; + /* End of the mandatory fields.*/ +} PWMChannelConfig; + /** * @brief Driver configuration structure. * @note Implementations may extend this structure to contain more, @@ -116,6 +135,36 @@ struct PWMDriver { /* Driver macros. */ /*===========================================================================*/ +/** + * @brief Converts from degrees to pulse width. + * @note Be careful with rounding errors, this is integer math not magic. + * You can specify hundredths of degrees but make sure you have the + * proper hardware resolution by carefully choosing the clock source + * and prescaler settings, see @p PWM_COMPUTE_PSC. + * + * @param[in] pwmp pointer to a @p PWMDriver object + * @param[in] degrees degrees as an integer between 0 and 36000 + * @return The pulse width to be passed to @p pwmEnableChannel(). + * + * @api + */ +#define PWM_DEGREES_TO_WIDTH(pwpm, degrees) 0 + +/** + * @brief Converts from percentage to pulse width. + * @note Be careful with rounding errors, this is integer math not magic. + * You can specify tenths of thousandth but make sure you have the + * proper hardware resolution by carefully choosing the clock source + * and prescaler settings, see @p PWM_COMPUTE_PSC. + * + * @param[in] pwmp pointer to a @p PWMDriver object + * @param[in] percentage percentage as an integer between 0 and 10000 + * @return The pulse width to be passed to @p pwmEnableChannel(). + * + * @api + */ +#define PWM_PERCENTAGE_TO_WIDTH(pwpm, percentage) 0 + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ -- cgit v1.2.3