ftm_pwm_driver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
29 #ifndef FTM_PWM_DRIVER_H
30 #define FTM_PWM_DRIVER_H
31 
32 #include "ftm_common.h"
33 
39 /*******************************************************************************
40  * Definitions
41  ******************************************************************************/
43 #define FTM_MAX_DUTY_CYCLE (0x8000U)
44 
45 #define FTM_DUTY_TO_TICKS_SHIFT (15U)
46 
52 typedef enum
53 {
57 
63 typedef enum
64 {
65  FTM_POLARITY_LOW = 0x00U,
68 
74 typedef enum
75 {
81 
87 typedef enum
88 {
98 
104 typedef enum
105 {
111 
117 typedef struct
118 {
123 
129 typedef struct
130 {
137 
143 typedef struct
144 {
145  uint8_t hwChannelId;
147  uint16_t uDutyCyclePercent;
154  bool deadTime;
156 
162 typedef struct
163 {
164  uint8_t hwChannelId;
165  uint16_t firstEdge;
167  uint16_t secondEdge;
169  bool deadTime;
184 
190 typedef struct
191 {
195  uint8_t deadTimeValue;
197  uint32_t uFrequencyHZ;
202 
203 /*******************************************************************************
204  * API
205  ******************************************************************************/
206 
207 #if defined(__cplusplus)
208 extern "C" {
209 #endif
210 
217 status_t FTM_DRV_DeinitPwm(uint32_t instance);
218 
229 status_t FTM_DRV_InitPwm(uint32_t instance,
230  const ftm_pwm_param_t * param);
231 
251 status_t FTM_DRV_UpdatePwmChannel(uint32_t instance,
252  uint8_t channel,
253  ftm_pwm_update_option_t typeOfUpdate,
254  uint16_t firstEdge,
255  uint16_t secondEdge,
256  bool softwareTrigger);
257 
270 status_t FTM_DRV_FastUpdatePwmChannels(uint32_t instance,
271  uint8_t numberOfChannels,
272  const uint8_t * channels,
273  const uint16_t * duty,
274  bool softwareTrigger);
275 
294 status_t FTM_DRV_UpdatePwmPeriod(uint32_t instance,
295  ftm_pwm_update_option_t typeOfUpdate,
296  uint32_t newValue,
297  bool softwareTrigger);
298 
299 #if FEATURE_FTM_HAS_SUPPORTED_DITHERING
300 
312 status_t FTM_DRV_UpdatePwmPeriodDither(uint32_t instance,
313  uint8_t newModFracVal,
314  bool softwareTrigger);
315 
332  uint8_t channel,
333  uint8_t newMatchFracVal,
334  bool softwareTrigger);
335 #endif
336 
337 #ifdef ERRATA_E10856
338 
349 void FTM_PWM_DRV_IrqHandler(uint32_t instance,
350  uint32_t chnOutCtrlVal);
351 
352 #endif /* ERRATA_E10856 */
353 
354 #if defined(__cplusplus)
355 }
356 #endif
357  /* End of addtogroup ftm_pwm_driver */
361 
362 #endif /* FTM_PWM_DRIVER_H */
363 /*******************************************************************************
364  * EOF
365  ******************************************************************************/
ftm_polarity_t
FlexTimer PWM output pulse mode, high-true or low-true on match up.
ftm_fault_mode_t faultMode
status_t FTM_DRV_DeinitPwm(uint32_t instance)
Stops all PWM channels .
FlexTimer driver independent PWM parameter.
ftm_safe_state_polarity_t levelSelect
ftm_polarity_t ftmFaultPinPolarity
uint32_t uFrequencyHZ
ftm_second_channel_polarity_t
FlexTimer PWM channel (n+1) polarity for combine mode.
status_t FTM_DRV_UpdatePwmPeriod(uint32_t instance, ftm_pwm_update_option_t typeOfUpdate, uint32_t newValue, bool softwareTrigger)
This function will update the new period in the frequency or in the counter value into mode register ...
status_t FTM_DRV_UpdatePwmEdgeChannelDither(uint32_t instance, uint8_t channel, uint8_t newMatchFracVal, bool softwareTrigger)
This function will use in the PWM edge dithering. This value is added to the channel (n) internal acc...
ftm_deadtime_ps_t deadTimePrescaler
uint8_t nNumCombinedPwmChannels
ftm_safe_state_polarity_t levelSelectOnNextChn
ftm_safe_state_polarity_t
Select level of the channel (n) output at the beginning.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
Definition: status.h:44
status_t FTM_DRV_FastUpdatePwmChannels(uint32_t instance, uint8_t numberOfChannels, const uint8_t *channels, const uint16_t *duty, bool softwareTrigger)
This function will update the duty cycle of PWM output for multiple channels.
FlexTimer driver PWM Fault channel parameters.
ftm_safe_state_polarity_t levelSelect
status_t FTM_DRV_UpdatePwmPeriodDither(uint32_t instance, uint8_t newModFracVal, bool softwareTrigger)
This function will use in the PWM period dithering. This value is added to an internal accumulator at...
ftm_second_channel_polarity_t secondChannelPolarity
FlexTimer driver combined PWM parameter.
uint8_t nNumIndependentPwmChannels
FlexTimer driver PWM parameters.
ftm_polarity_t mainChannelPolarity
ftm_fault_mode_t
FlexTimer fault control.
ftm_independent_ch_param_t * pwmIndependentChannelConfig
ftm_deadtime_ps_t
FlexTimer pre-scaler factor for the dead-time insertion.
Definition: ftm_common.h:334
ftm_second_channel_polarity_t secondChannelPolarity
status_t FTM_DRV_UpdatePwmChannel(uint32_t instance, uint8_t channel, ftm_pwm_update_option_t typeOfUpdate, uint16_t firstEdge, uint16_t secondEdge, bool softwareTrigger)
This function updates the waveform output in PWM mode (duty cycle and phase).
#define FTM_FEATURE_FAULT_CHANNELS
ftm_pwm_update_option_t
FlexTimer Configure type of PWM update in the duty cycle or in ticks.
status_t FTM_DRV_InitPwm(uint32_t instance, const ftm_pwm_param_t *param)
Configures the duty cycle and frequency and starts outputting the PWM on all channels configured in p...
FlexTimer driver PWM Fault parameter.
ftm_config_mode_t
FlexTimer operation mode.
Definition: ftm_common.h:221
ftm_pwm_fault_param_t * faultConfig
ftm_config_mode_t mode
ftm_combined_ch_param_t * pwmCombinedChannelConfig