2014-11-02 09:34:38 +00:00
|
|
|
/*
|
|
|
|
ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-11-02 16:38:13 +00:00
|
|
|
* @file pwm_lld.c
|
|
|
|
* @brief PLATFORM PWM subsystem low level driver source.
|
2014-11-02 09:34:38 +00:00
|
|
|
*
|
|
|
|
* @addtogroup PWM
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hal.h"
|
|
|
|
|
|
|
|
#if HAL_USE_PWM || defined(__DOXYGEN__)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local definitions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported variables. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief PWMD1 driver identifier.
|
|
|
|
* @note The driver PWMD1 allocates the complex timer TIM1 when enabled.
|
|
|
|
*/
|
|
|
|
#if PLATFORM_PWM_USE_PWM1 || defined(__DOXYGEN__)
|
|
|
|
PWMDriver PWMD1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local variables and types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver interrupt handlers. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Low level PWM driver initialization.
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_init(void) {
|
|
|
|
|
|
|
|
#if PLATFORM_PWM_USE_PWM1
|
|
|
|
/* Driver initialization.*/
|
|
|
|
pwmObjectInit(&PWMD1);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Configures and activates the PWM peripheral.
|
|
|
|
* @note Starting a driver that is already in the @p PWM_READY state
|
|
|
|
* disables all the active channels.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_start(PWMDriver *pwmp) {
|
|
|
|
|
|
|
|
if (pwmp->state == PWM_STOP) {
|
|
|
|
/* Clock activation and timer reset.*/
|
|
|
|
#if PLATFORM_PWM_USE_PWM1
|
|
|
|
if (&PWMD1 == pwmp) {
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Deactivates the PWM peripheral.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_stop(PWMDriver *pwmp) {
|
|
|
|
|
|
|
|
/* If in ready state then disables the PWM clock.*/
|
|
|
|
if (pwmp->state == PWM_READY) {
|
|
|
|
#if PLATFORM_PWM_USE_PWM1
|
|
|
|
if (&PWMD1 == pwmp) {
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2014-11-02 16:38:13 +00:00
|
|
|
}
|
2014-11-02 09:34:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enables a PWM channel.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @post The channel is active using the specified configuration.
|
|
|
|
* @note The function has effect at the next cycle start.
|
|
|
|
* @note Channel notification is not enabled.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
* @param[in] channel PWM channel identifier (0...channels-1)
|
|
|
|
* @param[in] width PWM pulse width as clock pulses number
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_enable_channel(PWMDriver *pwmp,
|
|
|
|
pwmchannel_t channel,
|
|
|
|
pwmcnt_t width) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
2014-11-02 16:38:13 +00:00
|
|
|
(void)channel;
|
|
|
|
(void)width;
|
2014-11-02 09:34:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disables a PWM channel and its notification.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @post The channel is disabled and its output line returned to the
|
|
|
|
* idle state.
|
|
|
|
* @note The function has effect at the next cycle start.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
* @param[in] channel PWM channel identifier (0...channels-1)
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
2014-11-02 16:38:13 +00:00
|
|
|
(void)channel;
|
2014-11-02 09:34:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enables the periodic activation edge notification.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @note If the notification is already enabled then the call has no effect.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_enable_periodic_notification(PWMDriver *pwmp) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disables the periodic activation edge notification.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @note If the notification is already disabled then the call has no effect.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_disable_periodic_notification(PWMDriver *pwmp) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Enables a channel de-activation edge notification.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @pre The channel must have been activated using @p pwmEnableChannel().
|
|
|
|
* @note If the notification is already enabled then the call has no effect.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
* @param[in] channel PWM channel identifier (0...channels-1)
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_enable_channel_notification(PWMDriver *pwmp,
|
|
|
|
pwmchannel_t channel) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
|
|
|
(void)channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disables a channel de-activation edge notification.
|
|
|
|
* @pre The PWM unit must have been activated using @p pwmStart().
|
|
|
|
* @pre The channel must have been activated using @p pwmEnableChannel().
|
|
|
|
* @note If the notification is already disabled then the call has no effect.
|
|
|
|
*
|
|
|
|
* @param[in] pwmp pointer to a @p PWMDriver object
|
|
|
|
* @param[in] channel PWM channel identifier (0...channels-1)
|
|
|
|
*
|
|
|
|
* @notapi
|
|
|
|
*/
|
|
|
|
void pwm_lld_disable_channel_notification(PWMDriver *pwmp,
|
|
|
|
pwmchannel_t channel) {
|
|
|
|
|
|
|
|
(void)pwmp;
|
|
|
|
(void)channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAL_USE_PWM */
|
|
|
|
|
|
|
|
/** @} */
|