aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-07 07:57:43 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-04-07 07:57:43 +0000
commitd009502eb4c6b467d80a686b9a91f3ddbf0b595c (patch)
treeada55de9b67718570aeb5aee67ca667e2ed7caee /os
parent3adcb46879db0ebabf5d5575dcc724e8483c9079 (diff)
downloadChibiOS-d009502eb4c6b467d80a686b9a91f3ddbf0b595c.tar.gz
ChibiOS-d009502eb4c6b467d80a686b9a91f3ddbf0b595c.tar.bz2
ChibiOS-d009502eb4c6b467d80a686b9a91f3ddbf0b595c.zip
Added new pwmIsChannelEnabledI() API to the PWM driver, implemented in the STM32 driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5554 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/pwm.h12
-rw-r--r--os/hal/platforms/STM32/pwm_lld.h13
2 files changed, 25 insertions, 0 deletions
diff --git a/os/hal/include/pwm.h b/os/hal/include/pwm.h
index ce8e8b29b..a735cfbc2 100644
--- a/os/hal/include/pwm.h
+++ b/os/hal/include/pwm.h
@@ -211,6 +211,18 @@ typedef void (*pwmcallback_t)(PWMDriver *pwmp);
*/
#define pwmDisableChannelI(pwmp, channel) \
pwm_lld_disable_channel(pwmp, channel)
+
+/**
+ * @brief Returns a PWM channel status.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
+ *
+ * @iclass
+ */
+#define pwmIsChannelEnabledI(pwmp, channel) \
+ pwm_lld_is_channel_enabled(pwmp, channel)
/** @} */
/*===========================================================================*/
diff --git a/os/hal/platforms/STM32/pwm_lld.h b/os/hal/platforms/STM32/pwm_lld.h
index 94426e28c..8b1761f82 100644
--- a/os/hal/platforms/STM32/pwm_lld.h
+++ b/os/hal/platforms/STM32/pwm_lld.h
@@ -406,6 +406,19 @@ struct PWMDriver {
#define pwm_lld_change_period(pwmp, period) \
((pwmp)->tim->ARR = (uint16_t)((period) - 1))
+/**
+ * @brief Returns a PWM channel status.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
+ *
+ * @notapi
+ */
+#define pwm_lld_is_channel_enabled(pwmp, channel) \
+ ((pwmp->tim->CCR[channel] == 0) && \
+ ((pwmp->tim->DIER & (2 << channel)) == 0))
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/