mirror of https://github.com/rusefi/ChibiOS.git
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2406 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
297a1cefa8
commit
66c5a970fa
|
@ -269,6 +269,23 @@ struct PWMDriver {
|
|||
#define PWM_COMPUTE_ARR(pwmclk, pwmperiod) \
|
||||
((uint16_t)(((pwmclk) / (1000000 / (pwmperiod))) - 1))
|
||||
|
||||
/**
|
||||
* @brief Converts from fraction 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] numerator numerator of the fraction
|
||||
* @param[in] denominator percentage as an integer between 0 and numerator
|
||||
* @return The pulse width to be passed to @p pwmEnableChannel().
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define PWM_FRACTION_TO_WIDTH(pwmp, numerator, denominator) \
|
||||
((uint16_t)(((((uint32_t)(pwmp)->pd_config->pc_arr + 1UL) * \
|
||||
(uint32_t)(denominator)) / (uint32_t)(numerator)) - 1UL))
|
||||
|
||||
/**
|
||||
* @brief Converts from degrees to pulse width.
|
||||
* @note Be careful with rounding errors, this is integer math not magic.
|
||||
|
@ -283,8 +300,7 @@ struct PWMDriver {
|
|||
* @api
|
||||
*/
|
||||
#define PWM_DEGREES_TO_WIDTH(pwmp, degrees) \
|
||||
((uint16_t)(((((uint32_t)(pwmp)->pd_config->pc_arr + 1UL) * \
|
||||
(uint32_t)(degrees)) / 36000UL) - 1UL))
|
||||
PWM_FRACTION_TO_WIDTH(pwmp, 36000, degrees)
|
||||
|
||||
/**
|
||||
* @brief Converts from percentage to pulse width.
|
||||
|
@ -300,8 +316,7 @@ struct PWMDriver {
|
|||
* @api
|
||||
*/
|
||||
#define PWM_PERCENTAGE_TO_WIDTH(pwmp, percentage) \
|
||||
((uint16_t)(((((uint32_t)(pwmp)->pd_config->pc_arr + 1UL) * \
|
||||
(uint32_t)(percentage)) / 10000UL) - 1UL))
|
||||
PWM_FRACTION_TO_WIDTH(pwmp, 10000, percentage)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
|
|
@ -137,6 +137,21 @@ struct PWMDriver {
|
|||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Converts from fraction 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] numerator numerator of the fraction
|
||||
* @param[in] denominator percentage as an integer between 0 and numerator
|
||||
* @return The pulse width to be passed to @p pwmEnableChannel().
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define PWM_FRACTION_TO_WIDTH(pwmp, numerator, denominator) 0
|
||||
|
||||
/**
|
||||
* @brief Converts from degrees to pulse width.
|
||||
* @note Be careful with rounding errors, this is integer math not magic.
|
||||
|
@ -150,7 +165,8 @@ struct PWMDriver {
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
#define PWM_DEGREES_TO_WIDTH(pwmp, degrees) 0
|
||||
#define PWM_DEGREES_TO_WIDTH(pwmp, degrees) \
|
||||
PWM_FRACTION_TO_WIDTH(pwmp, 36000, degrees)
|
||||
|
||||
/**
|
||||
* @brief Converts from percentage to pulse width.
|
||||
|
@ -165,7 +181,8 @@ struct PWMDriver {
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
#define PWM_PERCENTAGE_TO_WIDTH(pwmp, percentage) 0
|
||||
#define PWM_PERCENTAGE_TO_WIDTH(pwmp, percentage) \
|
||||
PWM_FRACTION_TO_WIDTH(pwmp, 10000, percentage)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
- FIX: Fixed typo in board name (bug 3113574)(backported to 2.0.7).
|
||||
- FIX: Fixed defective event wait functions with timeout (bug 3113443)
|
||||
(backported to 2.0.7).
|
||||
- NEW: Added new macro PWM_FRACTION_TO_WIDTH() to the PWM driver model.
|
||||
- NEW: ARM7 port reorganization following the same pattern of the ARMCMx
|
||||
one, on now the port is also supports the ARM9 architecture (but not
|
||||
tested yet hardware). Removed the dependencies between the port layer
|
||||
|
|
Loading…
Reference in New Issue