|
|
|
@ -11,6 +11,46 @@
|
|
|
|
|
* @ingroup drivers_periph |
|
|
|
|
* @brief Low-level PWM peripheral driver |
|
|
|
|
* |
|
|
|
|
* This interface enables access to CPU peripherals generating PWM signals. On |
|
|
|
|
* most platforms, this interface will be implemented based on hardware timers, |
|
|
|
|
* though some CPUs provide dedicated PWM peripherals. |
|
|
|
|
* |
|
|
|
|
* The characteristics of a PWM signal can be defined by three basic parameters, |
|
|
|
|
* namely the frequency, the duty cycle, and the operational mode. This |
|
|
|
|
* interface supports basic PWM generation in left-aligned, right-aligned, and |
|
|
|
|
* center mode. Additionally the interface supports the definition of the used |
|
|
|
|
* resolution, defining the granularity with which one can specify the duty |
|
|
|
|
* cycle. This brings more flexibility to the configuration of the frequency, |
|
|
|
|
* especially on systems with low system clocks. |
|
|
|
|
* |
|
|
|
|
* Typically, a single PWM device (e.g. hardware timer) supports PWM signal |
|
|
|
|
* generation on multiple pins in parallel. While the duty cycle is selectable |
|
|
|
|
* for each channel individually, the frequency and resolution are shared for |
|
|
|
|
* all channels. |
|
|
|
|
* |
|
|
|
|
* The mapping/configuration of PWM devices (timers) and the used pins has to be |
|
|
|
|
* done in the board configuration (the board's `periph_conf.h). |
|
|
|
|
* |
|
|
|
|
* When using the PWM interface, first thing you have to do is initialize the |
|
|
|
|
* PWM device with the targeted mode, frequency, and resolution settings. Once |
|
|
|
|
* the device is initialized, it will start the generation of PWM signals on all |
|
|
|
|
* configured pins immediately, with an initial duty cycle of `0`. Use the |
|
|
|
|
* pwm_set() function to change the duty cycle for a given channel. If you |
|
|
|
|
* want to disable the PWM generation again, simply call pwm_poweroff(). |
|
|
|
|
* |
|
|
|
|
* @section sec_pm (Low-) power implications |
|
|
|
|
* |
|
|
|
|
* After initialization, the a PWM peripheral **should** be powered on and |
|
|
|
|
* active. When manually stopped using the pwm_poweroff() function, the PWM |
|
|
|
|
* generation **should** be stopped for all channels and the PWM peripheral |
|
|
|
|
* **should** be fully power off (e.g. through peripheral clock gating). Once |
|
|
|
|
* being re-enabled by calling the pwm_poweron() function, the PWM peripheral |
|
|
|
|
* **should** transparently continue its previously configured operation, |
|
|
|
|
* including the last active duty cycle values. |
|
|
|
|
* |
|
|
|
|
* While a PWM device is active, some implementations might need to block |
|
|
|
|
* certain power modes. |
|
|
|
|
* |
|
|
|
|
* @{ |
|
|
|
|
* @file |
|
|
|
|
* @brief Low-level PWM peripheral driver interface definitions |
|
|
|
@ -116,40 +156,25 @@ uint8_t pwm_channels(pwm_t dev);
|
|
|
|
|
void pwm_set(pwm_t dev, uint8_t channel, uint16_t value); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Start PWM generation on the given device |
|
|
|
|
* |
|
|
|
|
* @param[in] dev device to start |
|
|
|
|
*/ |
|
|
|
|
void pwm_start(pwm_t dev); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Stop PWM generation on the given device |
|
|
|
|
* @brief Resume PWM generation on the given device |
|
|
|
|
* |
|
|
|
|
* @param[in] dev device to stop |
|
|
|
|
*/ |
|
|
|
|
void pwm_stop(pwm_t dev); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Power on the PWM device |
|
|
|
|
* When this function is called, the given PWM device is powered on and |
|
|
|
|
* continues its previously configured operation. The duty cycle of each channel |
|
|
|
|
* will be the value that was last set. |
|
|
|
|
* |
|
|
|
|
* When the device is powered on the first time, no configuration is set. If |
|
|
|
|
* the device is powered back on, after having been initialized and powered off |
|
|
|
|
* before, the PWM device will continue its operation with the previously set |
|
|
|
|
* configuration. So there is no need in re-initializing then. |
|
|
|
|
* This function must not be called before the PWM device was initialized. |
|
|
|
|
* |
|
|
|
|
* @param[in] dev device to power on |
|
|
|
|
* @param[in] dev device to start |
|
|
|
|
*/ |
|
|
|
|
void pwm_poweron(pwm_t dev); |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Power off the given PWM device |
|
|
|
|
* @brief Stop PWM generation on the given device |
|
|
|
|
* |
|
|
|
|
* This function will power off the given PWM device, which on most platforms |
|
|
|
|
* means that it will be disabled using clock gating. The implementation must |
|
|
|
|
* make sure, that any previously configuration will hold when the device is |
|
|
|
|
* being powered back on. |
|
|
|
|
* This function stops the PWM generation on all configured channels for the |
|
|
|
|
* given device and powers down the given PWM peripheral. |
|
|
|
|
* |
|
|
|
|
* @param[in] dev device to power off |
|
|
|
|
* @param[in] dev device to stop |
|
|
|
|
*/ |
|
|
|
|
void pwm_poweroff(pwm_t dev); |
|
|
|
|
|
|
|
|
|