S32 SDK
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  */
25 #ifndef FTM_PWM_DRIVER_H
26 #define FTM_PWM_DRIVER_H
27 
28 #include "ftm_common.h"
29 
38 /*******************************************************************************
39  * Definitions
40  ******************************************************************************/
42 #define FTM_MAX_DUTY_CYCLE (0x8000U)
43 
44 #define FTM_DUTY_TO_TICKS_SHIFT (15U)
45 
51 typedef enum
52 {
56 
57 
63 typedef struct
64 {
67  ftm_polarity_t ftmFaultPinPolarity;
69 
75 typedef struct
76 {
79  uint8_t faultFilterValue;
80  ftm_fault_mode_t faultMode;
83 
89 typedef struct
90 {
91  uint8_t hwChannelId;
92  ftm_polarity_t polarity;
93  uint16_t uDutyCyclePercent;
98 
104 typedef struct
105 {
106  uint8_t hwChannelId;
107  uint16_t firstEdge;
109  uint16_t secondEdge;
111  bool deadTime;
113  ftm_polarity_t mainChannelPolarity;
116  ftm_second_channel_polarity_t secondChannelPolarity;
124 
130 typedef struct
131 {
135  uint8_t deadTimeValue;
136  ftm_deadtime_ps_t deadTimePrescaler;
137  uint32_t uFrequencyHZ;
142 
143 /*******************************************************************************
144  * API
145  ******************************************************************************/
146 
147 #if defined(__cplusplus)
148 extern "C" {
149 #endif
150 
157 status_t FTM_DRV_DeinitPwm(uint32_t instance);
158 
169 status_t FTM_DRV_InitPwm(uint32_t instance,
170  const ftm_pwm_param_t * param);
171 
191 status_t FTM_DRV_UpdatePwmChannel(uint32_t instance,
192  uint8_t channel,
193  ftm_pwm_update_option_t typeOfUpdate,
194  uint16_t firstEdge,
195  uint16_t secondEdge,
196  bool softwareTrigger);
197 
210 status_t FTM_DRV_FastUpdatePwmChannels(uint32_t instance,
211  uint8_t numberOfChannels,
212  const uint8_t * channels,
213  const uint16_t * duty,
214  bool softwareTrigger);
215 
234 status_t FTM_DRV_UpdatePwmPeriod(uint32_t instance,
235  ftm_pwm_update_option_t typeOfUpdate,
236  uint32_t newValue,
237  bool softwareTrigger);
238 
239 #if FEATURE_FTM_HAS_SUPPORTED_DITHERING
240 
252 status_t FTM_DRV_UpdatePwmPeriodDither(uint32_t instance,
253  uint8_t newModFracVal,
254  bool softwareTrigger);
255 
271 status_t FTM_DRV_UpdatePwmEdgeChannelDither(uint32_t instance,
272  uint8_t channel,
273  uint8_t newMatchFracVal,
274  bool softwareTrigger);
275 #endif
276 
277 #ifdef ERRATA_E10856
278 
289 void FTM_PWM_DRV_IrqHandler(uint32_t instance,
290  uint32_t chnOutCtrlVal);
291 
292 #endif /* ERRATA_E10856 */
293 
294 #if defined(__cplusplus)
295 }
296 #endif
297  /* End of addtogroup ftm_pwm_driver */
301 
302 #endif /* FTM_PWM_DRIVER_H */
303 /*******************************************************************************
304  * EOF
305  ******************************************************************************/
ftm_fault_mode_t faultMode
status_t FTM_DRV_DeinitPwm(uint32_t instance)
Stops all PWM channels .
FlexTimer driver independent PWM parameter.
ftm_polarity_t ftmFaultPinPolarity
uint32_t uFrequencyHZ
const ftm_combined_ch_param_t * pwmCombinedChannelConfig
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 ...
ftm_deadtime_ps_t deadTimePrescaler
uint8_t nNumCombinedPwmChannels
const ftm_pwm_fault_param_t * faultConfig
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.
FlexTimer driver combined PWM parameter.
uint8_t nNumIndependentPwmChannels
FlexTimer driver PWM parameters.
#define FTM_FEATURE_FAULT_CHANNELS
ftm_polarity_t mainChannelPolarity
ftm_second_channel_polarity_t secondChannelPolarity
const ftm_independent_ch_param_t * pwmIndependentChannelConfig
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).
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:72
ftm_config_mode_t mode