aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-30 13:54:04 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-30 13:54:04 +0000
commite40ae9763814661fa99e2b546e4f2562fb48650b (patch)
treef3157c29964739ef5e7fcc46688861d63c5b9313 /os/hal/include
parenta2ee0679d1525a80cdaccc020413bfbb61d9b070 (diff)
downloadChibiOS-e40ae9763814661fa99e2b546e4f2562fb48650b.tar.gz
ChibiOS-e40ae9763814661fa99e2b546e4f2562fb48650b.tar.bz2
ChibiOS-e40ae9763814661fa99e2b546e4f2562fb48650b.zip
Enhanced PWM driver
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7208 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/pwm.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/os/hal/include/pwm.h b/os/hal/include/pwm.h
index d7176660e..6ecd93717 100644
--- a/os/hal/include/pwm.h
+++ b/os/hal/include/pwm.h
@@ -87,7 +87,7 @@ typedef enum {
typedef struct PWMDriver PWMDriver;
/**
- * @brief PWM notification callback type.
+ * @brief Type of a PWM notification callback.
*
* @param[in] pwmp pointer to a @p PWMDriver object
*/
@@ -187,13 +187,15 @@ typedef void (*pwmcallback_t)(PWMDriver *pwmp);
* or immediately (fallback implementation).
*
* @param[in] pwmp pointer to a @p PWMDriver object
- * @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
+ * @param[in] channel PWM channel identifier (0...channels-1)
* @param[in] width PWM pulse width as clock pulses number
*
* @iclass
*/
-#define pwmEnableChannelI(pwmp, channel, width) \
- pwm_lld_enable_channel(pwmp, channel, width)
+#define pwmEnableChannelI(pwmp, channel, width) do { \
+ (pwmp)->enabled |= 1 << (channel); \
+ pwm_lld_enable_channel(pwmp, channel, width); \
+} while (0)
/**
* @brief Disables a PWM channel.
@@ -205,24 +207,26 @@ typedef void (*pwmcallback_t)(PWMDriver *pwmp);
* or immediately (fallback implementation).
*
* @param[in] pwmp pointer to a @p PWMDriver object
- * @param[in] channel PWM channel identifier (0...PWM_CHANNELS-1)
+ * @param[in] channel PWM channel identifier (0...channels-1)
*
* @iclass
*/
-#define pwmDisableChannelI(pwmp, channel) \
- pwm_lld_disable_channel(pwmp, channel)
+#define pwmDisableChannelI(pwmp, channel) do { \
+ (pwmp)->enabled &= ~(1 << (channel)); \
+ pwm_lld_disable_channel(pwmp, channel); \
+} while (0)
/**
* @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)
+ * @param[in] channel PWM channel identifier (0...channels-1)
*
* @iclass
*/
#define pwmIsChannelEnabledI(pwmp, channel) \
- pwm_lld_is_channel_enabled(pwmp, channel)
+ ((bool)((pwmp)->enabled & (1 << (channel))))
/** @} */
/*===========================================================================*/
@@ -241,6 +245,10 @@ extern "C" {
pwmchannel_t channel,
pwmcnt_t width);
void pwmDisableChannel(PWMDriver *pwmp, pwmchannel_t channel);
+ void pwmEnablePeriodicNotification(PWMDriver *pwmp);
+ void pwmDisablePeriodicNotification(PWMDriver *pwmp);
+ void pwmEnableChannelNotification(PWMDriver *pwmp, pwmchannel_t channel);
+ void pwmDisableChannelNotification(PWMDriver *pwmp, pwmchannel_t channel);
#ifdef __cplusplus
}
#endif