The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /*
AnnaBridge 145:64910690c574 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 145:64910690c574 3 * All rights reserved.
AnnaBridge 145:64910690c574 4 *
AnnaBridge 145:64910690c574 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 145:64910690c574 6 * are permitted provided that the following conditions are met:
AnnaBridge 145:64910690c574 7 *
AnnaBridge 145:64910690c574 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 145:64910690c574 9 * of conditions and the following disclaimer.
AnnaBridge 145:64910690c574 10 *
AnnaBridge 145:64910690c574 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 145:64910690c574 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 145:64910690c574 13 * other materials provided with the distribution.
AnnaBridge 145:64910690c574 14 *
AnnaBridge 145:64910690c574 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 145:64910690c574 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 145:64910690c574 17 * software without specific prior written permission.
AnnaBridge 145:64910690c574 18 *
AnnaBridge 145:64910690c574 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 145:64910690c574 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 145:64910690c574 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 145:64910690c574 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 145:64910690c574 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 145:64910690c574 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 145:64910690c574 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 145:64910690c574 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 145:64910690c574 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 145:64910690c574 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 145:64910690c574 29 */
AnnaBridge 145:64910690c574 30 #ifndef _FSL_FTM_H_
AnnaBridge 145:64910690c574 31 #define _FSL_FTM_H_
AnnaBridge 145:64910690c574 32
AnnaBridge 145:64910690c574 33 #include "fsl_common.h"
AnnaBridge 145:64910690c574 34
AnnaBridge 145:64910690c574 35 /*!
AnnaBridge 145:64910690c574 36 * @addtogroup ftm
AnnaBridge 145:64910690c574 37 * @{
AnnaBridge 145:64910690c574 38 */
AnnaBridge 145:64910690c574 39
AnnaBridge 145:64910690c574 40
AnnaBridge 145:64910690c574 41 /*******************************************************************************
AnnaBridge 145:64910690c574 42 * Definitions
AnnaBridge 145:64910690c574 43 ******************************************************************************/
AnnaBridge 145:64910690c574 44
AnnaBridge 145:64910690c574 45 /*! @name Driver version */
AnnaBridge 145:64910690c574 46 /*@{*/
AnnaBridge 145:64910690c574 47 #define FSL_FTM_DRIVER_VERSION (MAKE_VERSION(2, 0, 2)) /*!< Version 2.0.2 */
AnnaBridge 145:64910690c574 48 /*@}*/
AnnaBridge 145:64910690c574 49
AnnaBridge 145:64910690c574 50 /*!
AnnaBridge 145:64910690c574 51 * @brief List of FTM channels
AnnaBridge 145:64910690c574 52 * @note Actual number of available channels is SoC dependent
AnnaBridge 145:64910690c574 53 */
AnnaBridge 145:64910690c574 54 typedef enum _ftm_chnl
AnnaBridge 145:64910690c574 55 {
AnnaBridge 145:64910690c574 56 kFTM_Chnl_0 = 0U, /*!< FTM channel number 0*/
AnnaBridge 145:64910690c574 57 kFTM_Chnl_1, /*!< FTM channel number 1 */
AnnaBridge 145:64910690c574 58 kFTM_Chnl_2, /*!< FTM channel number 2 */
AnnaBridge 145:64910690c574 59 kFTM_Chnl_3, /*!< FTM channel number 3 */
AnnaBridge 145:64910690c574 60 kFTM_Chnl_4, /*!< FTM channel number 4 */
AnnaBridge 145:64910690c574 61 kFTM_Chnl_5, /*!< FTM channel number 5 */
AnnaBridge 145:64910690c574 62 kFTM_Chnl_6, /*!< FTM channel number 6 */
AnnaBridge 145:64910690c574 63 kFTM_Chnl_7 /*!< FTM channel number 7 */
AnnaBridge 145:64910690c574 64 } ftm_chnl_t;
AnnaBridge 145:64910690c574 65
AnnaBridge 145:64910690c574 66 /*! @brief List of FTM faults */
AnnaBridge 145:64910690c574 67 typedef enum _ftm_fault_input
AnnaBridge 145:64910690c574 68 {
AnnaBridge 145:64910690c574 69 kFTM_Fault_0 = 0U, /*!< FTM fault 0 input pin */
AnnaBridge 145:64910690c574 70 kFTM_Fault_1, /*!< FTM fault 1 input pin */
AnnaBridge 145:64910690c574 71 kFTM_Fault_2, /*!< FTM fault 2 input pin */
AnnaBridge 145:64910690c574 72 kFTM_Fault_3 /*!< FTM fault 3 input pin */
AnnaBridge 145:64910690c574 73 } ftm_fault_input_t;
AnnaBridge 145:64910690c574 74
AnnaBridge 145:64910690c574 75 /*! @brief FTM PWM operation modes */
AnnaBridge 145:64910690c574 76 typedef enum _ftm_pwm_mode
AnnaBridge 145:64910690c574 77 {
AnnaBridge 145:64910690c574 78 kFTM_EdgeAlignedPwm = 0U, /*!< Edge-aligned PWM */
AnnaBridge 145:64910690c574 79 kFTM_CenterAlignedPwm, /*!< Center-aligned PWM */
AnnaBridge 145:64910690c574 80 kFTM_CombinedPwm /*!< Combined PWM */
AnnaBridge 145:64910690c574 81 } ftm_pwm_mode_t;
AnnaBridge 145:64910690c574 82
AnnaBridge 145:64910690c574 83 /*! @brief FTM PWM output pulse mode: high-true, low-true or no output */
AnnaBridge 145:64910690c574 84 typedef enum _ftm_pwm_level_select
AnnaBridge 145:64910690c574 85 {
AnnaBridge 145:64910690c574 86 kFTM_NoPwmSignal = 0U, /*!< No PWM output on pin */
AnnaBridge 145:64910690c574 87 kFTM_LowTrue, /*!< Low true pulses */
AnnaBridge 145:64910690c574 88 kFTM_HighTrue /*!< High true pulses */
AnnaBridge 145:64910690c574 89 } ftm_pwm_level_select_t;
AnnaBridge 145:64910690c574 90
AnnaBridge 145:64910690c574 91 /*! @brief Options to configure a FTM channel's PWM signal */
AnnaBridge 145:64910690c574 92 typedef struct _ftm_chnl_pwm_signal_param
AnnaBridge 145:64910690c574 93 {
AnnaBridge 145:64910690c574 94 ftm_chnl_t chnlNumber; /*!< The channel/channel pair number.
AnnaBridge 145:64910690c574 95 In combined mode, this represents the channel pair number. */
AnnaBridge 145:64910690c574 96 ftm_pwm_level_select_t level; /*!< PWM output active level select. */
AnnaBridge 145:64910690c574 97 uint8_t dutyCyclePercent; /*!< PWM pulse width, value should be between 0 to 100
AnnaBridge 145:64910690c574 98 0 = inactive signal(0% duty cycle)...
AnnaBridge 145:64910690c574 99 100 = always active signal (100% duty cycle).*/
AnnaBridge 145:64910690c574 100 uint8_t firstEdgeDelayPercent; /*!< Used only in combined PWM mode to generate an asymmetrical PWM.
AnnaBridge 145:64910690c574 101 Specifies the delay to the first edge in a PWM period.
AnnaBridge 145:64910690c574 102 If unsure leave as 0; Should be specified as a
AnnaBridge 145:64910690c574 103 percentage of the PWM period */
AnnaBridge 145:64910690c574 104 } ftm_chnl_pwm_signal_param_t;
AnnaBridge 145:64910690c574 105
AnnaBridge 145:64910690c574 106 /*! @brief FlexTimer output compare mode */
AnnaBridge 145:64910690c574 107 typedef enum _ftm_output_compare_mode
AnnaBridge 145:64910690c574 108 {
AnnaBridge 145:64910690c574 109 kFTM_NoOutputSignal = (1U << FTM_CnSC_MSA_SHIFT), /*!< No channel output when counter reaches CnV */
AnnaBridge 145:64910690c574 110 kFTM_ToggleOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (1U << FTM_CnSC_ELSA_SHIFT)), /*!< Toggle output */
AnnaBridge 145:64910690c574 111 kFTM_ClearOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (2U << FTM_CnSC_ELSA_SHIFT)), /*!< Clear output */
AnnaBridge 145:64910690c574 112 kFTM_SetOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (3U << FTM_CnSC_ELSA_SHIFT)) /*!< Set output */
AnnaBridge 145:64910690c574 113 } ftm_output_compare_mode_t;
AnnaBridge 145:64910690c574 114
AnnaBridge 145:64910690c574 115 /*! @brief FlexTimer input capture edge */
AnnaBridge 145:64910690c574 116 typedef enum _ftm_input_capture_edge
AnnaBridge 145:64910690c574 117 {
AnnaBridge 145:64910690c574 118 kFTM_RisingEdge = (1U << FTM_CnSC_ELSA_SHIFT), /*!< Capture on rising edge only*/
AnnaBridge 145:64910690c574 119 kFTM_FallingEdge = (2U << FTM_CnSC_ELSA_SHIFT), /*!< Capture on falling edge only*/
AnnaBridge 145:64910690c574 120 kFTM_RiseAndFallEdge = (3U << FTM_CnSC_ELSA_SHIFT) /*!< Capture on rising or falling edge */
AnnaBridge 145:64910690c574 121 } ftm_input_capture_edge_t;
AnnaBridge 145:64910690c574 122
AnnaBridge 145:64910690c574 123 /*! @brief FlexTimer dual edge capture modes */
AnnaBridge 145:64910690c574 124 typedef enum _ftm_dual_edge_capture_mode
AnnaBridge 145:64910690c574 125 {
AnnaBridge 145:64910690c574 126 kFTM_OneShot = 0U, /*!< One-shot capture mode */
AnnaBridge 145:64910690c574 127 kFTM_Continuous = (1U << FTM_CnSC_MSA_SHIFT) /*!< Continuous capture mode */
AnnaBridge 145:64910690c574 128 } ftm_dual_edge_capture_mode_t;
AnnaBridge 145:64910690c574 129
AnnaBridge 145:64910690c574 130 /*! @brief FlexTimer dual edge capture parameters */
AnnaBridge 145:64910690c574 131 typedef struct _ftm_dual_edge_capture_param
AnnaBridge 145:64910690c574 132 {
AnnaBridge 145:64910690c574 133 ftm_dual_edge_capture_mode_t mode; /*!< Dual Edge Capture mode */
AnnaBridge 145:64910690c574 134 ftm_input_capture_edge_t currChanEdgeMode; /*!< Input capture edge select for channel n */
AnnaBridge 145:64910690c574 135 ftm_input_capture_edge_t nextChanEdgeMode; /*!< Input capture edge select for channel n+1 */
AnnaBridge 145:64910690c574 136 } ftm_dual_edge_capture_param_t;
AnnaBridge 145:64910690c574 137
AnnaBridge 145:64910690c574 138 /*! @brief FlexTimer quadrature decode modes */
AnnaBridge 145:64910690c574 139 typedef enum _ftm_quad_decode_mode
AnnaBridge 145:64910690c574 140 {
AnnaBridge 145:64910690c574 141 kFTM_QuadPhaseEncode = 0U, /*!< Phase A and Phase B encoding mode */
AnnaBridge 145:64910690c574 142 kFTM_QuadCountAndDir /*!< Count and direction encoding mode */
AnnaBridge 145:64910690c574 143 } ftm_quad_decode_mode_t;
AnnaBridge 145:64910690c574 144
AnnaBridge 145:64910690c574 145 /*! @brief FlexTimer quadrature phase polarities */
AnnaBridge 145:64910690c574 146 typedef enum _ftm_phase_polarity
AnnaBridge 145:64910690c574 147 {
AnnaBridge 145:64910690c574 148 kFTM_QuadPhaseNormal = 0U, /*!< Phase input signal is not inverted */
AnnaBridge 145:64910690c574 149 kFTM_QuadPhaseInvert /*!< Phase input signal is inverted */
AnnaBridge 145:64910690c574 150 } ftm_phase_polarity_t;
AnnaBridge 145:64910690c574 151
AnnaBridge 145:64910690c574 152 /*! @brief FlexTimer quadrature decode phase parameters */
AnnaBridge 145:64910690c574 153 typedef struct _ftm_phase_param
AnnaBridge 145:64910690c574 154 {
AnnaBridge 145:64910690c574 155 bool enablePhaseFilter; /*!< True: enable phase filter; false: disable filter */
AnnaBridge 145:64910690c574 156 uint32_t phaseFilterVal; /*!< Filter value, used only if phase filter is enabled */
AnnaBridge 145:64910690c574 157 ftm_phase_polarity_t phasePolarity; /*!< Phase polarity */
AnnaBridge 145:64910690c574 158 } ftm_phase_params_t;
AnnaBridge 145:64910690c574 159
AnnaBridge 145:64910690c574 160 /*! @brief Structure is used to hold the parameters to configure a FTM fault */
AnnaBridge 145:64910690c574 161 typedef struct _ftm_fault_param
AnnaBridge 145:64910690c574 162 {
AnnaBridge 145:64910690c574 163 bool enableFaultInput; /*!< True: Fault input is enabled; false: Fault input is disabled */
AnnaBridge 145:64910690c574 164 bool faultLevel; /*!< True: Fault polarity is active low; in other words, '0' indicates a fault;
AnnaBridge 145:64910690c574 165 False: Fault polarity is active high */
AnnaBridge 145:64910690c574 166 bool useFaultFilter; /*!< True: Use the filtered fault signal;
AnnaBridge 145:64910690c574 167 False: Use the direct path from fault input */
AnnaBridge 145:64910690c574 168 } ftm_fault_param_t;
AnnaBridge 145:64910690c574 169
AnnaBridge 145:64910690c574 170 /*! @brief FlexTimer pre-scaler factor for the dead time insertion*/
AnnaBridge 145:64910690c574 171 typedef enum _ftm_deadtime_prescale
AnnaBridge 145:64910690c574 172 {
AnnaBridge 145:64910690c574 173 kFTM_Deadtime_Prescale_1 = 1U, /*!< Divide by 1 */
AnnaBridge 145:64910690c574 174 kFTM_Deadtime_Prescale_4, /*!< Divide by 4 */
AnnaBridge 145:64910690c574 175 kFTM_Deadtime_Prescale_16 /*!< Divide by 16 */
AnnaBridge 145:64910690c574 176 } ftm_deadtime_prescale_t;
AnnaBridge 145:64910690c574 177
AnnaBridge 145:64910690c574 178 /*! @brief FlexTimer clock source selection*/
AnnaBridge 145:64910690c574 179 typedef enum _ftm_clock_source
AnnaBridge 145:64910690c574 180 {
AnnaBridge 145:64910690c574 181 kFTM_SystemClock = 1U, /*!< System clock selected */
AnnaBridge 145:64910690c574 182 kFTM_FixedClock, /*!< Fixed frequency clock */
AnnaBridge 145:64910690c574 183 kFTM_ExternalClock /*!< External clock */
AnnaBridge 145:64910690c574 184 } ftm_clock_source_t;
AnnaBridge 145:64910690c574 185
AnnaBridge 145:64910690c574 186 /*! @brief FlexTimer pre-scaler factor selection for the clock source*/
AnnaBridge 145:64910690c574 187 typedef enum _ftm_clock_prescale
AnnaBridge 145:64910690c574 188 {
AnnaBridge 145:64910690c574 189 kFTM_Prescale_Divide_1 = 0U, /*!< Divide by 1 */
AnnaBridge 145:64910690c574 190 kFTM_Prescale_Divide_2, /*!< Divide by 2 */
AnnaBridge 145:64910690c574 191 kFTM_Prescale_Divide_4, /*!< Divide by 4 */
AnnaBridge 145:64910690c574 192 kFTM_Prescale_Divide_8, /*!< Divide by 8 */
AnnaBridge 145:64910690c574 193 kFTM_Prescale_Divide_16, /*!< Divide by 16 */
AnnaBridge 145:64910690c574 194 kFTM_Prescale_Divide_32, /*!< Divide by 32 */
AnnaBridge 145:64910690c574 195 kFTM_Prescale_Divide_64, /*!< Divide by 64 */
AnnaBridge 145:64910690c574 196 kFTM_Prescale_Divide_128 /*!< Divide by 128 */
AnnaBridge 145:64910690c574 197 } ftm_clock_prescale_t;
AnnaBridge 145:64910690c574 198
AnnaBridge 145:64910690c574 199 /*! @brief Options for the FlexTimer behaviour in BDM Mode */
AnnaBridge 145:64910690c574 200 typedef enum _ftm_bdm_mode
AnnaBridge 145:64910690c574 201 {
AnnaBridge 145:64910690c574 202 kFTM_BdmMode_0 = 0U,
AnnaBridge 145:64910690c574 203 /*!< FTM counter stopped, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V
AnnaBridge 145:64910690c574 204 registers bypass the register buffers */
AnnaBridge 145:64910690c574 205 kFTM_BdmMode_1,
AnnaBridge 145:64910690c574 206 /*!< FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are forced to their safe value , writes to
AnnaBridge 145:64910690c574 207 MOD,CNTIN and C(n)V registers bypass the register buffers */
AnnaBridge 145:64910690c574 208 kFTM_BdmMode_2,
AnnaBridge 145:64910690c574 209 /*!< FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are frozen when chip enters in BDM mode,
AnnaBridge 145:64910690c574 210 writes to MOD,CNTIN and C(n)V registers bypass the register buffers */
AnnaBridge 145:64910690c574 211 kFTM_BdmMode_3
AnnaBridge 145:64910690c574 212 /*!< FTM counter in functional mode, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and
AnnaBridge 145:64910690c574 213 C(n)V registers is in fully functional mode */
AnnaBridge 145:64910690c574 214 } ftm_bdm_mode_t;
AnnaBridge 145:64910690c574 215
AnnaBridge 145:64910690c574 216 /*! @brief Options for the FTM fault control mode */
AnnaBridge 145:64910690c574 217 typedef enum _ftm_fault_mode
AnnaBridge 145:64910690c574 218 {
AnnaBridge 145:64910690c574 219 kFTM_Fault_Disable = 0U, /*!< Fault control is disabled for all channels */
AnnaBridge 145:64910690c574 220 kFTM_Fault_EvenChnls, /*!< Enabled for even channels only(0,2,4,6) with manual fault clearing */
AnnaBridge 145:64910690c574 221 kFTM_Fault_AllChnlsMan, /*!< Enabled for all channels with manual fault clearing */
AnnaBridge 145:64910690c574 222 kFTM_Fault_AllChnlsAuto /*!< Enabled for all channels with automatic fault clearing */
AnnaBridge 145:64910690c574 223 } ftm_fault_mode_t;
AnnaBridge 145:64910690c574 224
AnnaBridge 145:64910690c574 225 /*!
AnnaBridge 145:64910690c574 226 * @brief FTM external trigger options
AnnaBridge 145:64910690c574 227 * @note Actual available external trigger sources are SoC-specific
AnnaBridge 145:64910690c574 228 */
AnnaBridge 145:64910690c574 229 typedef enum _ftm_external_trigger
AnnaBridge 145:64910690c574 230 {
AnnaBridge 145:64910690c574 231 kFTM_Chnl0Trigger = (1U << 4), /*!< Generate trigger when counter equals chnl 0 CnV reg */
AnnaBridge 145:64910690c574 232 kFTM_Chnl1Trigger = (1U << 5), /*!< Generate trigger when counter equals chnl 1 CnV reg */
AnnaBridge 145:64910690c574 233 kFTM_Chnl2Trigger = (1U << 0), /*!< Generate trigger when counter equals chnl 2 CnV reg */
AnnaBridge 145:64910690c574 234 kFTM_Chnl3Trigger = (1U << 1), /*!< Generate trigger when counter equals chnl 3 CnV reg */
AnnaBridge 145:64910690c574 235 kFTM_Chnl4Trigger = (1U << 2), /*!< Generate trigger when counter equals chnl 4 CnV reg */
AnnaBridge 145:64910690c574 236 kFTM_Chnl5Trigger = (1U << 3), /*!< Generate trigger when counter equals chnl 5 CnV reg */
AnnaBridge 145:64910690c574 237 kFTM_Chnl6Trigger =
AnnaBridge 145:64910690c574 238 (1U << 8), /*!< Available on certain SoC's, generate trigger when counter equals chnl 6 CnV reg */
AnnaBridge 145:64910690c574 239 kFTM_Chnl7Trigger =
AnnaBridge 145:64910690c574 240 (1U << 9), /*!< Available on certain SoC's, generate trigger when counter equals chnl 7 CnV reg */
AnnaBridge 145:64910690c574 241 kFTM_InitTrigger = (1U << 6), /*!< Generate Trigger when counter is updated with CNTIN */
AnnaBridge 145:64910690c574 242 kFTM_ReloadInitTrigger = (1U << 7) /*!< Available on certain SoC's, trigger on reload point */
AnnaBridge 145:64910690c574 243 } ftm_external_trigger_t;
AnnaBridge 145:64910690c574 244
AnnaBridge 145:64910690c574 245 /*! @brief FlexTimer PWM sync options to update registers with buffer */
AnnaBridge 145:64910690c574 246 typedef enum _ftm_pwm_sync_method
AnnaBridge 145:64910690c574 247 {
AnnaBridge 145:64910690c574 248 kFTM_SoftwareTrigger = FTM_SYNC_SWSYNC_MASK, /*!< Software triggers PWM sync */
AnnaBridge 145:64910690c574 249 kFTM_HardwareTrigger_0 = FTM_SYNC_TRIG0_MASK, /*!< Hardware trigger 0 causes PWM sync */
AnnaBridge 145:64910690c574 250 kFTM_HardwareTrigger_1 = FTM_SYNC_TRIG1_MASK, /*!< Hardware trigger 1 causes PWM sync */
AnnaBridge 145:64910690c574 251 kFTM_HardwareTrigger_2 = FTM_SYNC_TRIG2_MASK /*!< Hardware trigger 2 causes PWM sync */
AnnaBridge 145:64910690c574 252 } ftm_pwm_sync_method_t;
AnnaBridge 145:64910690c574 253
AnnaBridge 145:64910690c574 254 /*!
AnnaBridge 145:64910690c574 255 * @brief FTM options available as loading point for register reload
AnnaBridge 145:64910690c574 256 * @note Actual available reload points are SoC-specific
AnnaBridge 145:64910690c574 257 */
AnnaBridge 145:64910690c574 258 typedef enum _ftm_reload_point
AnnaBridge 145:64910690c574 259 {
AnnaBridge 145:64910690c574 260 kFTM_Chnl0Match = (1U << 0), /*!< Channel 0 match included as a reload point */
AnnaBridge 145:64910690c574 261 kFTM_Chnl1Match = (1U << 1), /*!< Channel 1 match included as a reload point */
AnnaBridge 145:64910690c574 262 kFTM_Chnl2Match = (1U << 2), /*!< Channel 2 match included as a reload point */
AnnaBridge 145:64910690c574 263 kFTM_Chnl3Match = (1U << 3), /*!< Channel 3 match included as a reload point */
AnnaBridge 145:64910690c574 264 kFTM_Chnl4Match = (1U << 4), /*!< Channel 4 match included as a reload point */
AnnaBridge 145:64910690c574 265 kFTM_Chnl5Match = (1U << 5), /*!< Channel 5 match included as a reload point */
AnnaBridge 145:64910690c574 266 kFTM_Chnl6Match = (1U << 6), /*!< Channel 6 match included as a reload point */
AnnaBridge 145:64910690c574 267 kFTM_Chnl7Match = (1U << 7), /*!< Channel 7 match included as a reload point */
AnnaBridge 145:64910690c574 268 kFTM_CntMax = (1U << 8), /*!< Use in up-down count mode only, reload when counter reaches the maximum value */
AnnaBridge 145:64910690c574 269 kFTM_CntMin = (1U << 9), /*!< Use in up-down count mode only, reload when counter reaches the minimum value */
AnnaBridge 145:64910690c574 270 kFTM_HalfCycMatch = (1U << 10) /*!< Available on certain SoC's, half cycle match reload point */
AnnaBridge 145:64910690c574 271 } ftm_reload_point_t;
AnnaBridge 145:64910690c574 272
AnnaBridge 145:64910690c574 273 /*!
AnnaBridge 145:64910690c574 274 * @brief List of FTM interrupts
AnnaBridge 145:64910690c574 275 * @note Actual available interrupts are SoC-specific
AnnaBridge 145:64910690c574 276 */
AnnaBridge 145:64910690c574 277 typedef enum _ftm_interrupt_enable
AnnaBridge 145:64910690c574 278 {
AnnaBridge 145:64910690c574 279 kFTM_Chnl0InterruptEnable = (1U << 0), /*!< Channel 0 interrupt */
AnnaBridge 145:64910690c574 280 kFTM_Chnl1InterruptEnable = (1U << 1), /*!< Channel 1 interrupt */
AnnaBridge 145:64910690c574 281 kFTM_Chnl2InterruptEnable = (1U << 2), /*!< Channel 2 interrupt */
AnnaBridge 145:64910690c574 282 kFTM_Chnl3InterruptEnable = (1U << 3), /*!< Channel 3 interrupt */
AnnaBridge 145:64910690c574 283 kFTM_Chnl4InterruptEnable = (1U << 4), /*!< Channel 4 interrupt */
AnnaBridge 145:64910690c574 284 kFTM_Chnl5InterruptEnable = (1U << 5), /*!< Channel 5 interrupt */
AnnaBridge 145:64910690c574 285 kFTM_Chnl6InterruptEnable = (1U << 6), /*!< Channel 6 interrupt */
AnnaBridge 145:64910690c574 286 kFTM_Chnl7InterruptEnable = (1U << 7), /*!< Channel 7 interrupt */
AnnaBridge 145:64910690c574 287 kFTM_FaultInterruptEnable = (1U << 8), /*!< Fault interrupt */
AnnaBridge 145:64910690c574 288 kFTM_TimeOverflowInterruptEnable = (1U << 9), /*!< Time overflow interrupt */
AnnaBridge 145:64910690c574 289 kFTM_ReloadInterruptEnable = (1U << 10) /*!< Reload interrupt; Available only on certain SoC's */
AnnaBridge 145:64910690c574 290 } ftm_interrupt_enable_t;
AnnaBridge 145:64910690c574 291
AnnaBridge 145:64910690c574 292 /*!
AnnaBridge 145:64910690c574 293 * @brief List of FTM flags
AnnaBridge 145:64910690c574 294 * @note Actual available flags are SoC-specific
AnnaBridge 145:64910690c574 295 */
AnnaBridge 145:64910690c574 296 typedef enum _ftm_status_flags
AnnaBridge 145:64910690c574 297 {
AnnaBridge 145:64910690c574 298 kFTM_Chnl0Flag = (1U << 0), /*!< Channel 0 Flag */
AnnaBridge 145:64910690c574 299 kFTM_Chnl1Flag = (1U << 1), /*!< Channel 1 Flag */
AnnaBridge 145:64910690c574 300 kFTM_Chnl2Flag = (1U << 2), /*!< Channel 2 Flag */
AnnaBridge 145:64910690c574 301 kFTM_Chnl3Flag = (1U << 3), /*!< Channel 3 Flag */
AnnaBridge 145:64910690c574 302 kFTM_Chnl4Flag = (1U << 4), /*!< Channel 4 Flag */
AnnaBridge 145:64910690c574 303 kFTM_Chnl5Flag = (1U << 5), /*!< Channel 5 Flag */
AnnaBridge 145:64910690c574 304 kFTM_Chnl6Flag = (1U << 6), /*!< Channel 6 Flag */
AnnaBridge 145:64910690c574 305 kFTM_Chnl7Flag = (1U << 7), /*!< Channel 7 Flag */
AnnaBridge 145:64910690c574 306 kFTM_FaultFlag = (1U << 8), /*!< Fault Flag */
AnnaBridge 145:64910690c574 307 kFTM_TimeOverflowFlag = (1U << 9), /*!< Time overflow Flag */
AnnaBridge 145:64910690c574 308 kFTM_ChnlTriggerFlag = (1U << 10), /*!< Channel trigger Flag */
AnnaBridge 145:64910690c574 309 kFTM_ReloadFlag = (1U << 11) /*!< Reload Flag; Available only on certain SoC's */
AnnaBridge 145:64910690c574 310 } ftm_status_flags_t;
AnnaBridge 145:64910690c574 311
AnnaBridge 145:64910690c574 312 /*!
AnnaBridge 145:64910690c574 313 * @brief List of FTM Quad Decoder flags.
AnnaBridge 145:64910690c574 314 */
AnnaBridge 145:64910690c574 315 enum _ftm_quad_decoder_flags
AnnaBridge 145:64910690c574 316 {
AnnaBridge 145:64910690c574 317 kFTM_QuadDecoderCountingIncreaseFlag = FTM_QDCTRL_QUADIR_MASK, /*!< Counting direction is increasing (FTM counter
AnnaBridge 145:64910690c574 318 increment), or the direction is decreasing. */
AnnaBridge 145:64910690c574 319 kFTM_QuadDecoderCountingOverflowOnTopFlag = FTM_QDCTRL_TOFDIR_MASK, /*!< Indicates if the TOF bit was set on the top
AnnaBridge 145:64910690c574 320 or the bottom of counting. */
AnnaBridge 145:64910690c574 321 };
AnnaBridge 145:64910690c574 322
AnnaBridge 145:64910690c574 323 /*!
AnnaBridge 145:64910690c574 324 * @brief FTM configuration structure
AnnaBridge 145:64910690c574 325 *
AnnaBridge 145:64910690c574 326 * This structure holds the configuration settings for the FTM peripheral. To initialize this
AnnaBridge 145:64910690c574 327 * structure to reasonable defaults, call the FTM_GetDefaultConfig() function and pass a
AnnaBridge 145:64910690c574 328 * pointer to the configuration structure instance.
AnnaBridge 145:64910690c574 329 *
AnnaBridge 145:64910690c574 330 * The configuration structure can be made constant so as to reside in flash.
AnnaBridge 145:64910690c574 331 */
AnnaBridge 145:64910690c574 332 typedef struct _ftm_config
AnnaBridge 145:64910690c574 333 {
AnnaBridge 145:64910690c574 334 ftm_clock_prescale_t prescale; /*!< FTM clock prescale value */
AnnaBridge 145:64910690c574 335 ftm_bdm_mode_t bdmMode; /*!< FTM behavior in BDM mode */
AnnaBridge 145:64910690c574 336 uint32_t pwmSyncMode; /*!< Synchronization methods to use to update buffered registers; Multiple
AnnaBridge 145:64910690c574 337 update modes can be used by providing an OR'ed list of options
AnnaBridge 145:64910690c574 338 available in enumeration ::ftm_pwm_sync_method_t. */
AnnaBridge 145:64910690c574 339 uint32_t reloadPoints; /*!< FTM reload points; When using this, the PWM
AnnaBridge 145:64910690c574 340 synchronization is not required. Multiple reload points can be used by providing
AnnaBridge 145:64910690c574 341 an OR'ed list of options available in
AnnaBridge 145:64910690c574 342 enumeration ::ftm_reload_point_t. */
AnnaBridge 145:64910690c574 343 ftm_fault_mode_t faultMode; /*!< FTM fault control mode */
AnnaBridge 145:64910690c574 344 uint8_t faultFilterValue; /*!< Fault input filter value */
AnnaBridge 145:64910690c574 345 ftm_deadtime_prescale_t deadTimePrescale; /*!< The dead time prescalar value */
AnnaBridge 145:64910690c574 346 uint32_t deadTimeValue; /*!< The dead time value
AnnaBridge 145:64910690c574 347 deadTimeValue's available range is 0-1023 when register has DTVALEX,
AnnaBridge 145:64910690c574 348 otherwise its available range is 0-63. */
AnnaBridge 145:64910690c574 349 uint32_t extTriggers; /*!< External triggers to enable. Multiple trigger sources can be
AnnaBridge 145:64910690c574 350 enabled by providing an OR'ed list of options available in
AnnaBridge 145:64910690c574 351 enumeration ::ftm_external_trigger_t. */
AnnaBridge 145:64910690c574 352 uint8_t chnlInitState; /*!< Defines the initialization value of the channels in OUTINT register */
AnnaBridge 145:64910690c574 353 uint8_t chnlPolarity; /*!< Defines the output polarity of the channels in POL register */
AnnaBridge 145:64910690c574 354 bool useGlobalTimeBase; /*!< True: Use of an external global time base is enabled;
AnnaBridge 145:64910690c574 355 False: disabled */
AnnaBridge 145:64910690c574 356 } ftm_config_t;
AnnaBridge 145:64910690c574 357
AnnaBridge 145:64910690c574 358 /*******************************************************************************
AnnaBridge 145:64910690c574 359 * API
AnnaBridge 145:64910690c574 360 ******************************************************************************/
AnnaBridge 145:64910690c574 361
AnnaBridge 145:64910690c574 362 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 363 extern "C" {
AnnaBridge 145:64910690c574 364 #endif
AnnaBridge 145:64910690c574 365
AnnaBridge 145:64910690c574 366 /*!
AnnaBridge 145:64910690c574 367 * @name Initialization and deinitialization
AnnaBridge 145:64910690c574 368 * @{
AnnaBridge 145:64910690c574 369 */
AnnaBridge 145:64910690c574 370
AnnaBridge 145:64910690c574 371 /*!
AnnaBridge 145:64910690c574 372 * @brief Ungates the FTM clock and configures the peripheral for basic operation.
AnnaBridge 145:64910690c574 373 *
AnnaBridge 145:64910690c574 374 * @note This API should be called at the beginning of the application which is using the FTM driver.
AnnaBridge 145:64910690c574 375 *
AnnaBridge 145:64910690c574 376 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 377 * @param config Pointer to the user configuration structure.
AnnaBridge 145:64910690c574 378 *
AnnaBridge 145:64910690c574 379 * @return kStatus_Success indicates success; Else indicates failure.
AnnaBridge 145:64910690c574 380 */
AnnaBridge 145:64910690c574 381 status_t FTM_Init(FTM_Type *base, const ftm_config_t *config);
AnnaBridge 145:64910690c574 382
AnnaBridge 145:64910690c574 383 /*!
AnnaBridge 145:64910690c574 384 * @brief Gates the FTM clock.
AnnaBridge 145:64910690c574 385 *
AnnaBridge 145:64910690c574 386 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 387 */
AnnaBridge 145:64910690c574 388 void FTM_Deinit(FTM_Type *base);
AnnaBridge 145:64910690c574 389
AnnaBridge 145:64910690c574 390 /*!
AnnaBridge 145:64910690c574 391 * @brief Fills in the FTM configuration structure with the default settings.
AnnaBridge 145:64910690c574 392 *
AnnaBridge 145:64910690c574 393 * The default values are:
AnnaBridge 145:64910690c574 394 * @code
AnnaBridge 145:64910690c574 395 * config->prescale = kFTM_Prescale_Divide_1;
AnnaBridge 145:64910690c574 396 * config->bdmMode = kFTM_BdmMode_0;
AnnaBridge 145:64910690c574 397 * config->pwmSyncMode = kFTM_SoftwareTrigger;
AnnaBridge 145:64910690c574 398 * config->reloadPoints = 0;
AnnaBridge 145:64910690c574 399 * config->faultMode = kFTM_Fault_Disable;
AnnaBridge 145:64910690c574 400 * config->faultFilterValue = 0;
AnnaBridge 145:64910690c574 401 * config->deadTimePrescale = kFTM_Deadtime_Prescale_1;
AnnaBridge 145:64910690c574 402 * config->deadTimeValue = 0;
AnnaBridge 145:64910690c574 403 * config->extTriggers = 0;
AnnaBridge 145:64910690c574 404 * config->chnlInitState = 0;
AnnaBridge 145:64910690c574 405 * config->chnlPolarity = 0;
AnnaBridge 145:64910690c574 406 * config->useGlobalTimeBase = false;
AnnaBridge 145:64910690c574 407 * @endcode
AnnaBridge 145:64910690c574 408 * @param config Pointer to the user configuration structure.
AnnaBridge 145:64910690c574 409 */
AnnaBridge 145:64910690c574 410 void FTM_GetDefaultConfig(ftm_config_t *config);
AnnaBridge 145:64910690c574 411
AnnaBridge 145:64910690c574 412 /*! @}*/
AnnaBridge 145:64910690c574 413
AnnaBridge 145:64910690c574 414 /*!
AnnaBridge 145:64910690c574 415 * @name Channel mode operations
AnnaBridge 145:64910690c574 416 * @{
AnnaBridge 145:64910690c574 417 */
AnnaBridge 145:64910690c574 418
AnnaBridge 145:64910690c574 419 /*!
AnnaBridge 145:64910690c574 420 * @brief Configures the PWM signal parameters.
AnnaBridge 145:64910690c574 421 *
AnnaBridge 145:64910690c574 422 * Call this function to configure the PWM signal period, mode, duty cycle, and edge. Use this
AnnaBridge 145:64910690c574 423 * function to configure all FTM channels that are used to output a PWM signal.
AnnaBridge 145:64910690c574 424 *
AnnaBridge 145:64910690c574 425 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 426 * @param chnlParams Array of PWM channel parameters to configure the channel(s)
AnnaBridge 145:64910690c574 427 * @param numOfChnls Number of channels to configure; This should be the size of the array passed in
AnnaBridge 145:64910690c574 428 * @param mode PWM operation mode, options available in enumeration ::ftm_pwm_mode_t
AnnaBridge 145:64910690c574 429 * @param pwmFreq_Hz PWM signal frequency in Hz
AnnaBridge 145:64910690c574 430 * @param srcClock_Hz FTM counter clock in Hz
AnnaBridge 145:64910690c574 431 *
AnnaBridge 145:64910690c574 432 * @return kStatus_Success if the PWM setup was successful
AnnaBridge 145:64910690c574 433 * kStatus_Error on failure
AnnaBridge 145:64910690c574 434 */
AnnaBridge 145:64910690c574 435 status_t FTM_SetupPwm(FTM_Type *base,
AnnaBridge 145:64910690c574 436 const ftm_chnl_pwm_signal_param_t *chnlParams,
AnnaBridge 145:64910690c574 437 uint8_t numOfChnls,
AnnaBridge 145:64910690c574 438 ftm_pwm_mode_t mode,
AnnaBridge 145:64910690c574 439 uint32_t pwmFreq_Hz,
AnnaBridge 145:64910690c574 440 uint32_t srcClock_Hz);
AnnaBridge 145:64910690c574 441
AnnaBridge 145:64910690c574 442 /*!
AnnaBridge 145:64910690c574 443 * @brief Updates the duty cycle of an active PWM signal.
AnnaBridge 145:64910690c574 444 *
AnnaBridge 145:64910690c574 445 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 446 * @param chnlNumber The channel/channel pair number. In combined mode, this represents
AnnaBridge 145:64910690c574 447 * the channel pair number
AnnaBridge 145:64910690c574 448 * @param currentPwmMode The current PWM mode set during PWM setup
AnnaBridge 145:64910690c574 449 * @param dutyCyclePercent New PWM pulse width; The value should be between 0 to 100
AnnaBridge 145:64910690c574 450 * 0=inactive signal(0% duty cycle)...
AnnaBridge 145:64910690c574 451 * 100=active signal (100% duty cycle)
AnnaBridge 145:64910690c574 452 */
AnnaBridge 145:64910690c574 453 void FTM_UpdatePwmDutycycle(FTM_Type *base,
AnnaBridge 145:64910690c574 454 ftm_chnl_t chnlNumber,
AnnaBridge 145:64910690c574 455 ftm_pwm_mode_t currentPwmMode,
AnnaBridge 145:64910690c574 456 uint8_t dutyCyclePercent);
AnnaBridge 145:64910690c574 457
AnnaBridge 145:64910690c574 458 /*!
AnnaBridge 145:64910690c574 459 * @brief Updates the edge level selection for a channel.
AnnaBridge 145:64910690c574 460 *
AnnaBridge 145:64910690c574 461 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 462 * @param chnlNumber The channel number
AnnaBridge 145:64910690c574 463 * @param level The level to be set to the ELSnB:ELSnA field; Valid values are 00, 01, 10, 11.
AnnaBridge 145:64910690c574 464 * See the Kinetis SoC reference manual for details about this field.
AnnaBridge 145:64910690c574 465 */
AnnaBridge 145:64910690c574 466 void FTM_UpdateChnlEdgeLevelSelect(FTM_Type *base, ftm_chnl_t chnlNumber, uint8_t level);
AnnaBridge 145:64910690c574 467
AnnaBridge 145:64910690c574 468 /*!
AnnaBridge 145:64910690c574 469 * @brief Enables capturing an input signal on the channel using the function parameters.
AnnaBridge 145:64910690c574 470 *
AnnaBridge 145:64910690c574 471 * When the edge specified in the captureMode argument occurs on the channel, the FTM counter is
AnnaBridge 145:64910690c574 472 * captured into the CnV register. The user has to read the CnV register separately to get this
AnnaBridge 145:64910690c574 473 * value. The filter function is disabled if the filterVal argument passed in is 0. The filter
AnnaBridge 145:64910690c574 474 * function is available only for channels 0, 1, 2, 3.
AnnaBridge 145:64910690c574 475 *
AnnaBridge 145:64910690c574 476 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 477 * @param chnlNumber The channel number
AnnaBridge 145:64910690c574 478 * @param captureMode Specifies which edge to capture
AnnaBridge 145:64910690c574 479 * @param filterValue Filter value, specify 0 to disable filter. Available only for channels 0-3.
AnnaBridge 145:64910690c574 480 */
AnnaBridge 145:64910690c574 481 void FTM_SetupInputCapture(FTM_Type *base,
AnnaBridge 145:64910690c574 482 ftm_chnl_t chnlNumber,
AnnaBridge 145:64910690c574 483 ftm_input_capture_edge_t captureMode,
AnnaBridge 145:64910690c574 484 uint32_t filterValue);
AnnaBridge 145:64910690c574 485
AnnaBridge 145:64910690c574 486 /*!
AnnaBridge 145:64910690c574 487 * @brief Configures the FTM to generate timed pulses.
AnnaBridge 145:64910690c574 488 *
AnnaBridge 145:64910690c574 489 * When the FTM counter matches the value of compareVal argument (this is written into CnV reg),
AnnaBridge 145:64910690c574 490 * the channel output is changed based on what is specified in the compareMode argument.
AnnaBridge 145:64910690c574 491 *
AnnaBridge 145:64910690c574 492 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 493 * @param chnlNumber The channel number
AnnaBridge 145:64910690c574 494 * @param compareMode Action to take on the channel output when the compare condition is met
AnnaBridge 145:64910690c574 495 * @param compareValue Value to be programmed in the CnV register.
AnnaBridge 145:64910690c574 496 */
AnnaBridge 145:64910690c574 497 void FTM_SetupOutputCompare(FTM_Type *base,
AnnaBridge 145:64910690c574 498 ftm_chnl_t chnlNumber,
AnnaBridge 145:64910690c574 499 ftm_output_compare_mode_t compareMode,
AnnaBridge 145:64910690c574 500 uint32_t compareValue);
AnnaBridge 145:64910690c574 501
AnnaBridge 145:64910690c574 502 /*!
AnnaBridge 145:64910690c574 503 * @brief Configures the dual edge capture mode of the FTM.
AnnaBridge 145:64910690c574 504 *
AnnaBridge 145:64910690c574 505 * This function sets up the dual edge capture mode on a channel pair. The capture edge for the
AnnaBridge 145:64910690c574 506 * channel pair and the capture mode (one-shot or continuous) is specified in the parameter
AnnaBridge 145:64910690c574 507 * argument. The filter function is disabled if the filterVal argument passed is zero. The filter
AnnaBridge 145:64910690c574 508 * function is available only on channels 0 and 2. The user has to read the channel CnV registers
AnnaBridge 145:64910690c574 509 * separately to get the capture values.
AnnaBridge 145:64910690c574 510 *
AnnaBridge 145:64910690c574 511 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 512 * @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
AnnaBridge 145:64910690c574 513 * @param edgeParam Sets up the dual edge capture function
AnnaBridge 145:64910690c574 514 * @param filterValue Filter value, specify 0 to disable filter. Available only for channel pair 0 and 1.
AnnaBridge 145:64910690c574 515 */
AnnaBridge 145:64910690c574 516 void FTM_SetupDualEdgeCapture(FTM_Type *base,
AnnaBridge 145:64910690c574 517 ftm_chnl_t chnlPairNumber,
AnnaBridge 145:64910690c574 518 const ftm_dual_edge_capture_param_t *edgeParam,
AnnaBridge 145:64910690c574 519 uint32_t filterValue);
AnnaBridge 145:64910690c574 520
AnnaBridge 145:64910690c574 521 /*! @}*/
AnnaBridge 145:64910690c574 522
AnnaBridge 145:64910690c574 523 /*!
AnnaBridge 145:64910690c574 524 * @brief Sets up the working of the FTM fault protection.
AnnaBridge 145:64910690c574 525 *
AnnaBridge 145:64910690c574 526 * FTM can have up to 4 fault inputs. This function sets up fault parameters, fault level, and a filter.
AnnaBridge 145:64910690c574 527 *
AnnaBridge 145:64910690c574 528 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 529 * @param faultNumber FTM fault to configure.
AnnaBridge 145:64910690c574 530 * @param faultParams Parameters passed in to set up the fault
AnnaBridge 145:64910690c574 531 */
AnnaBridge 145:64910690c574 532 void FTM_SetupFault(FTM_Type *base, ftm_fault_input_t faultNumber, const ftm_fault_param_t *faultParams);
AnnaBridge 145:64910690c574 533
AnnaBridge 145:64910690c574 534 /*!
AnnaBridge 145:64910690c574 535 * @name Interrupt Interface
AnnaBridge 145:64910690c574 536 * @{
AnnaBridge 145:64910690c574 537 */
AnnaBridge 145:64910690c574 538
AnnaBridge 145:64910690c574 539 /*!
AnnaBridge 145:64910690c574 540 * @brief Enables the selected FTM interrupts.
AnnaBridge 145:64910690c574 541 *
AnnaBridge 145:64910690c574 542 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 543 * @param mask The interrupts to enable. This is a logical OR of members of the
AnnaBridge 145:64910690c574 544 * enumeration ::ftm_interrupt_enable_t
AnnaBridge 145:64910690c574 545 */
AnnaBridge 145:64910690c574 546 void FTM_EnableInterrupts(FTM_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 547
AnnaBridge 145:64910690c574 548 /*!
AnnaBridge 145:64910690c574 549 * @brief Disables the selected FTM interrupts.
AnnaBridge 145:64910690c574 550 *
AnnaBridge 145:64910690c574 551 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 552 * @param mask The interrupts to enable. This is a logical OR of members of the
AnnaBridge 145:64910690c574 553 * enumeration ::ftm_interrupt_enable_t
AnnaBridge 145:64910690c574 554 */
AnnaBridge 145:64910690c574 555 void FTM_DisableInterrupts(FTM_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 556
AnnaBridge 145:64910690c574 557 /*!
AnnaBridge 145:64910690c574 558 * @brief Gets the enabled FTM interrupts.
AnnaBridge 145:64910690c574 559 *
AnnaBridge 145:64910690c574 560 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 561 *
AnnaBridge 145:64910690c574 562 * @return The enabled interrupts. This is the logical OR of members of the
AnnaBridge 145:64910690c574 563 * enumeration ::ftm_interrupt_enable_t
AnnaBridge 145:64910690c574 564 */
AnnaBridge 145:64910690c574 565 uint32_t FTM_GetEnabledInterrupts(FTM_Type *base);
AnnaBridge 145:64910690c574 566
AnnaBridge 145:64910690c574 567 /*! @}*/
AnnaBridge 145:64910690c574 568
AnnaBridge 145:64910690c574 569 /*!
AnnaBridge 145:64910690c574 570 * @name Status Interface
AnnaBridge 145:64910690c574 571 * @{
AnnaBridge 145:64910690c574 572 */
AnnaBridge 145:64910690c574 573
AnnaBridge 145:64910690c574 574 /*!
AnnaBridge 145:64910690c574 575 * @brief Gets the FTM status flags.
AnnaBridge 145:64910690c574 576 *
AnnaBridge 145:64910690c574 577 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 578 *
AnnaBridge 145:64910690c574 579 * @return The status flags. This is the logical OR of members of the
AnnaBridge 145:64910690c574 580 * enumeration ::ftm_status_flags_t
AnnaBridge 145:64910690c574 581 */
AnnaBridge 145:64910690c574 582 uint32_t FTM_GetStatusFlags(FTM_Type *base);
AnnaBridge 145:64910690c574 583
AnnaBridge 145:64910690c574 584 /*!
AnnaBridge 145:64910690c574 585 * @brief Clears the FTM status flags.
AnnaBridge 145:64910690c574 586 *
AnnaBridge 145:64910690c574 587 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 588 * @param mask The status flags to clear. This is a logical OR of members of the
AnnaBridge 145:64910690c574 589 * enumeration ::ftm_status_flags_t
AnnaBridge 145:64910690c574 590 */
AnnaBridge 145:64910690c574 591 void FTM_ClearStatusFlags(FTM_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 592
AnnaBridge 145:64910690c574 593 /*! @}*/
AnnaBridge 145:64910690c574 594
AnnaBridge 145:64910690c574 595 /*!
AnnaBridge 145:64910690c574 596 * @name Timer Start and Stop
AnnaBridge 145:64910690c574 597 * @{
AnnaBridge 145:64910690c574 598 */
AnnaBridge 145:64910690c574 599
AnnaBridge 145:64910690c574 600 /*!
AnnaBridge 145:64910690c574 601 * @brief Starts the FTM counter.
AnnaBridge 145:64910690c574 602 *
AnnaBridge 145:64910690c574 603 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 604 * @param clockSource FTM clock source; After the clock source is set, the counter starts running.
AnnaBridge 145:64910690c574 605 */
AnnaBridge 145:64910690c574 606 static inline void FTM_StartTimer(FTM_Type *base, ftm_clock_source_t clockSource)
AnnaBridge 145:64910690c574 607 {
AnnaBridge 145:64910690c574 608 uint32_t reg = base->SC;
AnnaBridge 145:64910690c574 609
AnnaBridge 145:64910690c574 610 reg &= ~(FTM_SC_CLKS_MASK);
AnnaBridge 145:64910690c574 611 reg |= FTM_SC_CLKS(clockSource);
AnnaBridge 145:64910690c574 612 base->SC = reg;
AnnaBridge 145:64910690c574 613 }
AnnaBridge 145:64910690c574 614
AnnaBridge 145:64910690c574 615 /*!
AnnaBridge 145:64910690c574 616 * @brief Stops the FTM counter.
AnnaBridge 145:64910690c574 617 *
AnnaBridge 145:64910690c574 618 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 619 */
AnnaBridge 145:64910690c574 620 static inline void FTM_StopTimer(FTM_Type *base)
AnnaBridge 145:64910690c574 621 {
AnnaBridge 145:64910690c574 622 /* Set clock source to none to disable counter */
AnnaBridge 145:64910690c574 623 base->SC &= ~(FTM_SC_CLKS_MASK);
AnnaBridge 145:64910690c574 624 }
AnnaBridge 145:64910690c574 625
AnnaBridge 145:64910690c574 626 /*! @}*/
AnnaBridge 145:64910690c574 627
AnnaBridge 145:64910690c574 628 /*!
AnnaBridge 145:64910690c574 629 * @name Software output control
AnnaBridge 145:64910690c574 630 * @{
AnnaBridge 145:64910690c574 631 */
AnnaBridge 145:64910690c574 632
AnnaBridge 145:64910690c574 633 /*!
AnnaBridge 145:64910690c574 634 * @brief Enables or disables the channel software output control.
AnnaBridge 145:64910690c574 635 *
AnnaBridge 145:64910690c574 636 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 637 * @param chnlNumber Channel to be enabled or disabled
AnnaBridge 145:64910690c574 638 * @param value true: channel output is affected by software output control
AnnaBridge 145:64910690c574 639 false: channel output is unaffected by software output control
AnnaBridge 145:64910690c574 640 */
AnnaBridge 145:64910690c574 641 static inline void FTM_SetSoftwareCtrlEnable(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)
AnnaBridge 145:64910690c574 642 {
AnnaBridge 145:64910690c574 643 if (value)
AnnaBridge 145:64910690c574 644 {
AnnaBridge 145:64910690c574 645 base->SWOCTRL |= (1U << chnlNumber);
AnnaBridge 145:64910690c574 646 }
AnnaBridge 145:64910690c574 647 else
AnnaBridge 145:64910690c574 648 {
AnnaBridge 145:64910690c574 649 base->SWOCTRL &= ~(1U << chnlNumber);
AnnaBridge 145:64910690c574 650 }
AnnaBridge 145:64910690c574 651 }
AnnaBridge 145:64910690c574 652
AnnaBridge 145:64910690c574 653 /*!
AnnaBridge 145:64910690c574 654 * @brief Sets the channel software output control value.
AnnaBridge 145:64910690c574 655 *
AnnaBridge 145:64910690c574 656 * @param base FTM peripheral base address.
AnnaBridge 145:64910690c574 657 * @param chnlNumber Channel to be configured
AnnaBridge 145:64910690c574 658 * @param value true to set 1, false to set 0
AnnaBridge 145:64910690c574 659 */
AnnaBridge 145:64910690c574 660 static inline void FTM_SetSoftwareCtrlVal(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)
AnnaBridge 145:64910690c574 661 {
AnnaBridge 145:64910690c574 662 if (value)
AnnaBridge 145:64910690c574 663 {
AnnaBridge 145:64910690c574 664 base->SWOCTRL |= (1U << (chnlNumber + FTM_SWOCTRL_CH0OCV_SHIFT));
AnnaBridge 145:64910690c574 665 }
AnnaBridge 145:64910690c574 666 else
AnnaBridge 145:64910690c574 667 {
AnnaBridge 145:64910690c574 668 base->SWOCTRL &= ~(1U << (chnlNumber + FTM_SWOCTRL_CH0OCV_SHIFT));
AnnaBridge 145:64910690c574 669 }
AnnaBridge 145:64910690c574 670 }
AnnaBridge 145:64910690c574 671
AnnaBridge 145:64910690c574 672 /*! @}*/
AnnaBridge 145:64910690c574 673
AnnaBridge 145:64910690c574 674 /*!
AnnaBridge 145:64910690c574 675 * @brief Enables or disables the FTM global time base signal generation to other FTMs.
AnnaBridge 145:64910690c574 676 *
AnnaBridge 145:64910690c574 677 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 678 * @param enable true to enable, false to disable
AnnaBridge 145:64910690c574 679 */
AnnaBridge 145:64910690c574 680 static inline void FTM_SetGlobalTimeBaseOutputEnable(FTM_Type *base, bool enable)
AnnaBridge 145:64910690c574 681 {
AnnaBridge 145:64910690c574 682 if (enable)
AnnaBridge 145:64910690c574 683 {
AnnaBridge 145:64910690c574 684 base->CONF |= FTM_CONF_GTBEOUT_MASK;
AnnaBridge 145:64910690c574 685 }
AnnaBridge 145:64910690c574 686 else
AnnaBridge 145:64910690c574 687 {
AnnaBridge 145:64910690c574 688 base->CONF &= ~FTM_CONF_GTBEOUT_MASK;
AnnaBridge 145:64910690c574 689 }
AnnaBridge 145:64910690c574 690 }
AnnaBridge 145:64910690c574 691
AnnaBridge 145:64910690c574 692 /*!
AnnaBridge 145:64910690c574 693 * @brief Sets the FTM peripheral timer channel output mask.
AnnaBridge 145:64910690c574 694 *
AnnaBridge 145:64910690c574 695 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 696 * @param chnlNumber Channel to be configured
AnnaBridge 145:64910690c574 697 * @param mask true: masked, channel is forced to its inactive state; false: unmasked
AnnaBridge 145:64910690c574 698 */
AnnaBridge 145:64910690c574 699 static inline void FTM_SetOutputMask(FTM_Type *base, ftm_chnl_t chnlNumber, bool mask)
AnnaBridge 145:64910690c574 700 {
AnnaBridge 145:64910690c574 701 if (mask)
AnnaBridge 145:64910690c574 702 {
AnnaBridge 145:64910690c574 703 base->OUTMASK |= (1U << chnlNumber);
AnnaBridge 145:64910690c574 704 }
AnnaBridge 145:64910690c574 705 else
AnnaBridge 145:64910690c574 706 {
AnnaBridge 145:64910690c574 707 base->OUTMASK &= ~(1U << chnlNumber);
AnnaBridge 145:64910690c574 708 }
AnnaBridge 145:64910690c574 709 }
AnnaBridge 145:64910690c574 710
AnnaBridge 145:64910690c574 711 #if defined(FSL_FEATURE_FTM_HAS_ENABLE_PWM_OUTPUT) && (FSL_FEATURE_FTM_HAS_ENABLE_PWM_OUTPUT)
AnnaBridge 145:64910690c574 712 /*!
AnnaBridge 145:64910690c574 713 * @brief Allows users to enable an output on an FTM channel.
AnnaBridge 145:64910690c574 714 *
AnnaBridge 145:64910690c574 715 * To enable the PWM channel output call this function with val=true. For input mode,
AnnaBridge 145:64910690c574 716 * call this function with val=false.
AnnaBridge 145:64910690c574 717 *
AnnaBridge 145:64910690c574 718 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 719 * @param chnlNumber Channel to be configured
AnnaBridge 145:64910690c574 720 * @param value true: enable output; false: output is disabled, used in input mode
AnnaBridge 145:64910690c574 721 */
AnnaBridge 145:64910690c574 722 static inline void FTM_SetPwmOutputEnable(FTM_Type *base, ftm_chnl_t chnlNumber, bool value)
AnnaBridge 145:64910690c574 723 {
AnnaBridge 145:64910690c574 724 if (value)
AnnaBridge 145:64910690c574 725 {
AnnaBridge 145:64910690c574 726 base->SC |= (1U << (chnlNumber + FTM_SC_PWMEN0_SHIFT));
AnnaBridge 145:64910690c574 727 }
AnnaBridge 145:64910690c574 728 else
AnnaBridge 145:64910690c574 729 {
AnnaBridge 145:64910690c574 730 base->SC &= ~(1U << (chnlNumber + FTM_SC_PWMEN0_SHIFT));
AnnaBridge 145:64910690c574 731 }
AnnaBridge 145:64910690c574 732 }
AnnaBridge 145:64910690c574 733 #endif
AnnaBridge 145:64910690c574 734
AnnaBridge 145:64910690c574 735 /*!
AnnaBridge 145:64910690c574 736 * @name Channel pair operations
AnnaBridge 145:64910690c574 737 * @{
AnnaBridge 145:64910690c574 738 */
AnnaBridge 145:64910690c574 739
AnnaBridge 145:64910690c574 740 /*!
AnnaBridge 145:64910690c574 741 * @brief This function enables/disables the fault control in a channel pair.
AnnaBridge 145:64910690c574 742 *
AnnaBridge 145:64910690c574 743 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 744 * @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
AnnaBridge 145:64910690c574 745 * @param value true: Enable fault control for this channel pair; false: No fault control
AnnaBridge 145:64910690c574 746 */
AnnaBridge 145:64910690c574 747 static inline void FTM_SetFaultControlEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
AnnaBridge 145:64910690c574 748 {
AnnaBridge 145:64910690c574 749 if (value)
AnnaBridge 145:64910690c574 750 {
AnnaBridge 145:64910690c574 751 base->COMBINE |= (1U << (FTM_COMBINE_FAULTEN0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 752 }
AnnaBridge 145:64910690c574 753 else
AnnaBridge 145:64910690c574 754 {
AnnaBridge 145:64910690c574 755 base->COMBINE &= ~(1U << (FTM_COMBINE_FAULTEN0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 756 }
AnnaBridge 145:64910690c574 757 }
AnnaBridge 145:64910690c574 758
AnnaBridge 145:64910690c574 759 /*!
AnnaBridge 145:64910690c574 760 * @brief This function enables/disables the dead time insertion in a channel pair.
AnnaBridge 145:64910690c574 761 *
AnnaBridge 145:64910690c574 762 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 763 * @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
AnnaBridge 145:64910690c574 764 * @param value true: Insert dead time in this channel pair; false: No dead time inserted
AnnaBridge 145:64910690c574 765 */
AnnaBridge 145:64910690c574 766 static inline void FTM_SetDeadTimeEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
AnnaBridge 145:64910690c574 767 {
AnnaBridge 145:64910690c574 768 if (value)
AnnaBridge 145:64910690c574 769 {
AnnaBridge 145:64910690c574 770 base->COMBINE |= (1U << (FTM_COMBINE_DTEN0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 771 }
AnnaBridge 145:64910690c574 772 else
AnnaBridge 145:64910690c574 773 {
AnnaBridge 145:64910690c574 774 base->COMBINE &= ~(1U << (FTM_COMBINE_DTEN0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 775 }
AnnaBridge 145:64910690c574 776 }
AnnaBridge 145:64910690c574 777
AnnaBridge 145:64910690c574 778 /*!
AnnaBridge 145:64910690c574 779 * @brief This function enables/disables complementary mode in a channel pair.
AnnaBridge 145:64910690c574 780 *
AnnaBridge 145:64910690c574 781 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 782 * @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
AnnaBridge 145:64910690c574 783 * @param value true: enable complementary mode; false: disable complementary mode
AnnaBridge 145:64910690c574 784 */
AnnaBridge 145:64910690c574 785 static inline void FTM_SetComplementaryEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
AnnaBridge 145:64910690c574 786 {
AnnaBridge 145:64910690c574 787 if (value)
AnnaBridge 145:64910690c574 788 {
AnnaBridge 145:64910690c574 789 base->COMBINE |= (1U << (FTM_COMBINE_COMP0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 790 }
AnnaBridge 145:64910690c574 791 else
AnnaBridge 145:64910690c574 792 {
AnnaBridge 145:64910690c574 793 base->COMBINE &= ~(1U << (FTM_COMBINE_COMP0_SHIFT + (FTM_COMBINE_COMBINE1_SHIFT * chnlPairNumber)));
AnnaBridge 145:64910690c574 794 }
AnnaBridge 145:64910690c574 795 }
AnnaBridge 145:64910690c574 796
AnnaBridge 145:64910690c574 797 /*!
AnnaBridge 145:64910690c574 798 * @brief This function enables/disables inverting control in a channel pair.
AnnaBridge 145:64910690c574 799 *
AnnaBridge 145:64910690c574 800 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 801 * @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
AnnaBridge 145:64910690c574 802 * @param value true: enable inverting; false: disable inverting
AnnaBridge 145:64910690c574 803 */
AnnaBridge 145:64910690c574 804 static inline void FTM_SetInvertEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
AnnaBridge 145:64910690c574 805 {
AnnaBridge 145:64910690c574 806 if (value)
AnnaBridge 145:64910690c574 807 {
AnnaBridge 145:64910690c574 808 base->INVCTRL |= (1U << chnlPairNumber);
AnnaBridge 145:64910690c574 809 }
AnnaBridge 145:64910690c574 810 else
AnnaBridge 145:64910690c574 811 {
AnnaBridge 145:64910690c574 812 base->INVCTRL &= ~(1U << chnlPairNumber);
AnnaBridge 145:64910690c574 813 }
AnnaBridge 145:64910690c574 814 }
AnnaBridge 145:64910690c574 815
AnnaBridge 145:64910690c574 816 /*! @}*/
AnnaBridge 145:64910690c574 817
AnnaBridge 145:64910690c574 818 /*!
AnnaBridge 145:64910690c574 819 * @name Quad Decoder
AnnaBridge 145:64910690c574 820 * @{
AnnaBridge 145:64910690c574 821 */
AnnaBridge 145:64910690c574 822
AnnaBridge 145:64910690c574 823 /*!
AnnaBridge 145:64910690c574 824 * @brief Configures the parameters and activates the quadrature decoder mode.
AnnaBridge 145:64910690c574 825 *
AnnaBridge 145:64910690c574 826 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 827 * @param phaseAParams Phase A configuration parameters
AnnaBridge 145:64910690c574 828 * @param phaseBParams Phase B configuration parameters
AnnaBridge 145:64910690c574 829 * @param quadMode Selects encoding mode used in quadrature decoder mode
AnnaBridge 145:64910690c574 830 */
AnnaBridge 145:64910690c574 831 void FTM_SetupQuadDecode(FTM_Type *base,
AnnaBridge 145:64910690c574 832 const ftm_phase_params_t *phaseAParams,
AnnaBridge 145:64910690c574 833 const ftm_phase_params_t *phaseBParams,
AnnaBridge 145:64910690c574 834 ftm_quad_decode_mode_t quadMode);
AnnaBridge 145:64910690c574 835
AnnaBridge 145:64910690c574 836 /*!
AnnaBridge 145:64910690c574 837 * @brief Gets the FTM Quad Decoder flags.
AnnaBridge 145:64910690c574 838 *
AnnaBridge 145:64910690c574 839 * @param base FTM peripheral base address.
AnnaBridge 145:64910690c574 840 * @return Flag mask of FTM Quad Decoder, see #_ftm_quad_decoder_flags.
AnnaBridge 145:64910690c574 841 */
AnnaBridge 145:64910690c574 842 static inline uint32_t FTM_GetQuadDecoderFlags(FTM_Type *base)
AnnaBridge 145:64910690c574 843 {
AnnaBridge 145:64910690c574 844 return base->QDCTRL & (FTM_QDCTRL_QUADIR_MASK | FTM_QDCTRL_TOFDIR_MASK);
AnnaBridge 145:64910690c574 845 }
AnnaBridge 145:64910690c574 846
AnnaBridge 145:64910690c574 847 /*!
AnnaBridge 145:64910690c574 848 * @brief Sets the modulo values for Quad Decoder.
AnnaBridge 145:64910690c574 849 *
AnnaBridge 145:64910690c574 850 * The modulo values configure the minimum and maximum values that the Quad decoder counter can reach. After the counter goes
AnnaBridge 145:64910690c574 851 * over, the counter value goes to the other side and decrease/increase again.
AnnaBridge 145:64910690c574 852 *
AnnaBridge 145:64910690c574 853 * @param base FTM peripheral base address.
AnnaBridge 145:64910690c574 854 * @param startValue The low limit value for Quad Decoder counter.
AnnaBridge 145:64910690c574 855 * @param overValue The high limit value for Quad Decoder counter.
AnnaBridge 145:64910690c574 856 */
AnnaBridge 145:64910690c574 857 static inline void FTM_SetQuadDecoderModuloValue(FTM_Type *base, uint32_t startValue, uint32_t overValue)
AnnaBridge 145:64910690c574 858 {
AnnaBridge 145:64910690c574 859 base->CNTIN = startValue;
AnnaBridge 145:64910690c574 860 base->MOD = overValue;
AnnaBridge 145:64910690c574 861 }
AnnaBridge 145:64910690c574 862
AnnaBridge 145:64910690c574 863 /*!
AnnaBridge 145:64910690c574 864 * @brief Gets the current Quad Decoder counter value.
AnnaBridge 145:64910690c574 865 *
AnnaBridge 145:64910690c574 866 * @param base FTM peripheral base address.
AnnaBridge 145:64910690c574 867 * @return Current quad Decoder counter value.
AnnaBridge 145:64910690c574 868 */
AnnaBridge 145:64910690c574 869 static inline uint32_t FTM_GetQuadDecoderCounterValue(FTM_Type *base)
AnnaBridge 145:64910690c574 870 {
AnnaBridge 145:64910690c574 871 return base->CNT;
AnnaBridge 145:64910690c574 872 }
AnnaBridge 145:64910690c574 873
AnnaBridge 145:64910690c574 874 /*!
AnnaBridge 145:64910690c574 875 * @brief Clears the current Quad Decoder counter value.
AnnaBridge 145:64910690c574 876 *
AnnaBridge 145:64910690c574 877 * The counter is set as the initial value.
AnnaBridge 145:64910690c574 878 *
AnnaBridge 145:64910690c574 879 * @param base FTM peripheral base address.
AnnaBridge 145:64910690c574 880 */
AnnaBridge 145:64910690c574 881 static inline void FTM_ClearQuadDecoderCounterValue(FTM_Type *base)
AnnaBridge 145:64910690c574 882 {
AnnaBridge 145:64910690c574 883 base->CNT = base->CNTIN;
AnnaBridge 145:64910690c574 884 }
AnnaBridge 145:64910690c574 885
AnnaBridge 145:64910690c574 886 /*! @}*/
AnnaBridge 145:64910690c574 887
AnnaBridge 145:64910690c574 888 /*!
AnnaBridge 145:64910690c574 889 * @brief Enables or disables the FTM software trigger for PWM synchronization.
AnnaBridge 145:64910690c574 890 *
AnnaBridge 145:64910690c574 891 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 892 * @param enable true: software trigger is selected, false: software trigger is not selected
AnnaBridge 145:64910690c574 893 */
AnnaBridge 145:64910690c574 894 static inline void FTM_SetSoftwareTrigger(FTM_Type *base, bool enable)
AnnaBridge 145:64910690c574 895 {
AnnaBridge 145:64910690c574 896 if (enable)
AnnaBridge 145:64910690c574 897 {
AnnaBridge 145:64910690c574 898 base->SYNC |= FTM_SYNC_SWSYNC_MASK;
AnnaBridge 145:64910690c574 899 }
AnnaBridge 145:64910690c574 900 else
AnnaBridge 145:64910690c574 901 {
AnnaBridge 145:64910690c574 902 base->SYNC &= ~FTM_SYNC_SWSYNC_MASK;
AnnaBridge 145:64910690c574 903 }
AnnaBridge 145:64910690c574 904 }
AnnaBridge 145:64910690c574 905
AnnaBridge 145:64910690c574 906 /*!
AnnaBridge 145:64910690c574 907 * @brief Enables or disables the FTM write protection.
AnnaBridge 145:64910690c574 908 *
AnnaBridge 145:64910690c574 909 * @param base FTM peripheral base address
AnnaBridge 145:64910690c574 910 * @param enable true: Write-protection is enabled, false: Write-protection is disabled
AnnaBridge 145:64910690c574 911 */
AnnaBridge 145:64910690c574 912 static inline void FTM_SetWriteProtection(FTM_Type *base, bool enable)
AnnaBridge 145:64910690c574 913 {
AnnaBridge 145:64910690c574 914 /* Configure write protection */
AnnaBridge 145:64910690c574 915 if (enable)
AnnaBridge 145:64910690c574 916 {
AnnaBridge 145:64910690c574 917 base->FMS |= FTM_FMS_WPEN_MASK;
AnnaBridge 145:64910690c574 918 }
AnnaBridge 145:64910690c574 919 else
AnnaBridge 145:64910690c574 920 {
AnnaBridge 145:64910690c574 921 base->MODE |= FTM_MODE_WPDIS_MASK;
AnnaBridge 145:64910690c574 922 }
AnnaBridge 145:64910690c574 923 }
AnnaBridge 145:64910690c574 924
AnnaBridge 145:64910690c574 925 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 926 }
AnnaBridge 145:64910690c574 927 #endif
AnnaBridge 145:64910690c574 928
AnnaBridge 145:64910690c574 929 /*! @}*/
AnnaBridge 145:64910690c574 930
AnnaBridge 145:64910690c574 931 #endif /* _FSL_FTM_H_*/