mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

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

Committer:
mbed_official
Date:
Thu Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/flextimer/fsl_ftm_hal.h@146:f64d43ff0c18
Child:
324:406fd2029f23
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #if !defined(__FSL_FTM_HAL_H__)
mbed_official 146:f64d43ff0c18 31 #define __FSL_FTM_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 34 #include "fsl_ftm_features.h"
mbed_official 146:f64d43ff0c18 35 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 36 #include <assert.h>
mbed_official 146:f64d43ff0c18 37
mbed_official 146:f64d43ff0c18 38 /*!
mbed_official 146:f64d43ff0c18 39 * @addtogroup ftm_hal
mbed_official 146:f64d43ff0c18 40 * @{
mbed_official 146:f64d43ff0c18 41 */
mbed_official 146:f64d43ff0c18 42
mbed_official 146:f64d43ff0c18 43 /*******************************************************************************
mbed_official 146:f64d43ff0c18 44 * Definitions
mbed_official 146:f64d43ff0c18 45 ******************************************************************************/
mbed_official 146:f64d43ff0c18 46 #define HW_FTM_CHANNEL_COUNT (8U) /*!< Number of channels for one FTM instance.*/
mbed_official 146:f64d43ff0c18 47 #define HW_FTM_CHANNEL_PAIR_COUNT (4U) /*!< Number of combined channel of one FTM instance.*/
mbed_official 146:f64d43ff0c18 48 #define HW_CHAN0 (0U) /*!< Channel number for CHAN0.*/
mbed_official 146:f64d43ff0c18 49 #define HW_CHAN1 (1U) /*!< Channel number for CHAN1.*/
mbed_official 146:f64d43ff0c18 50 #define HW_CHAN2 (2U) /*!< Channel number for CHAN2.*/
mbed_official 146:f64d43ff0c18 51 #define HW_CHAN3 (3U) /*!< Channel number for CHAN3.*/
mbed_official 146:f64d43ff0c18 52 #define HW_CHAN4 (4U) /*!< Channel number for CHAN4.*/
mbed_official 146:f64d43ff0c18 53 #define HW_CHAN5 (5U) /*!< Channel number for CHAN5.*/
mbed_official 146:f64d43ff0c18 54 #define HW_CHAN6 (6U) /*!< Channel number for CHAN6.*/
mbed_official 146:f64d43ff0c18 55 #define HW_CHAN7 (7U) /*!< Channel number for CHAN7.*/
mbed_official 146:f64d43ff0c18 56
mbed_official 146:f64d43ff0c18 57 #define FTM_COMBINE_CHAN_CTRL_WIDTH (8U)
mbed_official 146:f64d43ff0c18 58 /*! @brief FlexTimer clock source selection*/
mbed_official 146:f64d43ff0c18 59 typedef enum _ftm_clock_source
mbed_official 146:f64d43ff0c18 60 {
mbed_official 146:f64d43ff0c18 61 kClock_source_FTM_None = 0,
mbed_official 146:f64d43ff0c18 62 kClock_source_FTM_SystemClk,
mbed_official 146:f64d43ff0c18 63 kClock_source_FTM_FixedClk,
mbed_official 146:f64d43ff0c18 64 kClock_source_FTM_ExternalClk
mbed_official 146:f64d43ff0c18 65 }ftm_clock_source_t;
mbed_official 146:f64d43ff0c18 66
mbed_official 146:f64d43ff0c18 67 /*! @brief FlexTimer counting mode, up-down*/
mbed_official 146:f64d43ff0c18 68 typedef enum _ftm_counting_mode
mbed_official 146:f64d43ff0c18 69 {
mbed_official 146:f64d43ff0c18 70 kCounting_FTM_UP = 0,
mbed_official 146:f64d43ff0c18 71 kCounting_FTM_Down
mbed_official 146:f64d43ff0c18 72 }ftm_counting_mode_t;
mbed_official 146:f64d43ff0c18 73
mbed_official 146:f64d43ff0c18 74 /*! @brief FlexTimer pre-scaler factor selection for the clock source*/
mbed_official 146:f64d43ff0c18 75 typedef enum _ftm_clock_ps
mbed_official 146:f64d43ff0c18 76 {
mbed_official 146:f64d43ff0c18 77 kFtmDividedBy1 = 0,
mbed_official 146:f64d43ff0c18 78 kFtmDividedBy2 ,
mbed_official 146:f64d43ff0c18 79 kFtmDividedBy4 ,
mbed_official 146:f64d43ff0c18 80 kFtmDividedBy8,
mbed_official 146:f64d43ff0c18 81 kFtmDividedBy16,
mbed_official 146:f64d43ff0c18 82 kFtmDividedBy32,
mbed_official 146:f64d43ff0c18 83 kFtmDividedBy64,
mbed_official 146:f64d43ff0c18 84 kFtmDividedBy128
mbed_official 146:f64d43ff0c18 85 }ftm_clock_ps_t;
mbed_official 146:f64d43ff0c18 86
mbed_official 146:f64d43ff0c18 87 /*! @brief FlexTimer phase for the quadrature*/
mbed_official 146:f64d43ff0c18 88 typedef enum _ftm_phase_t
mbed_official 146:f64d43ff0c18 89 {
mbed_official 146:f64d43ff0c18 90 kFtmPhaseA = 0,
mbed_official 146:f64d43ff0c18 91 kFtmPhaseB
mbed_official 146:f64d43ff0c18 92 }ftm_phase_t;
mbed_official 146:f64d43ff0c18 93
mbed_official 146:f64d43ff0c18 94
mbed_official 146:f64d43ff0c18 95 /*! @brief FlexTimer pre-scaler factor for the deadtime insertion*/
mbed_official 146:f64d43ff0c18 96 typedef enum _ftm_deadtime_ps
mbed_official 146:f64d43ff0c18 97 {
mbed_official 146:f64d43ff0c18 98 kFtmDivided0 = 0,
mbed_official 146:f64d43ff0c18 99 kFtmDivided1 = 1,
mbed_official 146:f64d43ff0c18 100 kFtmDivided4 = 2,
mbed_official 146:f64d43ff0c18 101 kFtmDivided16 = 3,
mbed_official 146:f64d43ff0c18 102 }ftm_deadtime_ps_t;
mbed_official 146:f64d43ff0c18 103
mbed_official 146:f64d43ff0c18 104 /*! @brief FlexTimer operation mode, capture, output, dual, or quad*/
mbed_official 146:f64d43ff0c18 105 typedef enum _ftm_config_mode_t
mbed_official 146:f64d43ff0c18 106 {
mbed_official 146:f64d43ff0c18 107 kFtmInputCapture,
mbed_official 146:f64d43ff0c18 108 kFtmOutputCompare,
mbed_official 146:f64d43ff0c18 109 kFtmEdgeAlignedPWM,
mbed_official 146:f64d43ff0c18 110 kFtmCenterAlignedPWM,
mbed_official 146:f64d43ff0c18 111 kFtmCombinedPWM,
mbed_official 146:f64d43ff0c18 112 kFtmDualEdgeCapture,
mbed_official 146:f64d43ff0c18 113 kFtmQuadCapture
mbed_official 146:f64d43ff0c18 114 }ftm_config_mode_t;
mbed_official 146:f64d43ff0c18 115
mbed_official 146:f64d43ff0c18 116 /*! @brief FlexTimer input capture edge mode, rising edge, or falling edge */
mbed_official 146:f64d43ff0c18 117 typedef enum _ftm_input_capture_edge_mode_t
mbed_official 146:f64d43ff0c18 118 {
mbed_official 146:f64d43ff0c18 119 kFtmRisingEdge = 0,
mbed_official 146:f64d43ff0c18 120 kFtmFallingEdge,
mbed_official 146:f64d43ff0c18 121 kFtmRisingAndFalling
mbed_official 146:f64d43ff0c18 122 }ftm_input_capture_edge_mode_t;
mbed_official 146:f64d43ff0c18 123
mbed_official 146:f64d43ff0c18 124 /*! @brief FlexTimer output compare edge mode. Toggle, clear or set.*/
mbed_official 146:f64d43ff0c18 125 typedef enum _ftm_output_compare_edge_mode_t
mbed_official 146:f64d43ff0c18 126 {
mbed_official 146:f64d43ff0c18 127 kFtmToggleOnMatch = 0,
mbed_official 146:f64d43ff0c18 128 kFtmClearOnMatch,
mbed_official 146:f64d43ff0c18 129 kFtmSetOnMatch
mbed_official 146:f64d43ff0c18 130 }ftm_output_compare_edge_mode_t;
mbed_official 146:f64d43ff0c18 131
mbed_official 146:f64d43ff0c18 132 /*! @brief FlexTimer PWM output pulse mode, high-true or low-true on match up */
mbed_official 146:f64d43ff0c18 133 typedef enum _ftm_pwm_edge_mode_t
mbed_official 146:f64d43ff0c18 134 {
mbed_official 146:f64d43ff0c18 135 kFtmHighTrue = 0,
mbed_official 146:f64d43ff0c18 136 kFtmLowTrue
mbed_official 146:f64d43ff0c18 137 }ftm_pwm_edge_mode_t;
mbed_official 146:f64d43ff0c18 138
mbed_official 146:f64d43ff0c18 139 /*! @brief FlexTimer dual capture edge mode, one shot or continuous */
mbed_official 146:f64d43ff0c18 140 typedef enum _ftm_dual_capture_edge_mode_t
mbed_official 146:f64d43ff0c18 141 {
mbed_official 146:f64d43ff0c18 142 kFtmOneShout = 0,
mbed_official 146:f64d43ff0c18 143 kFtmContinuous
mbed_official 146:f64d43ff0c18 144 }ftm_dual_capture_edge_mode_t;
mbed_official 146:f64d43ff0c18 145
mbed_official 146:f64d43ff0c18 146 /*! @brief FlexTimer edge mode*/
mbed_official 146:f64d43ff0c18 147 typedef union _ftm_edge_mode_t
mbed_official 146:f64d43ff0c18 148 {
mbed_official 146:f64d43ff0c18 149 ftm_input_capture_edge_mode_t input_capture_edge_mode;
mbed_official 146:f64d43ff0c18 150 ftm_output_compare_edge_mode_t output_compare_edge_mode;
mbed_official 146:f64d43ff0c18 151 ftm_pwm_edge_mode_t ftm_pwm_edge_mode;
mbed_official 146:f64d43ff0c18 152 ftm_dual_capture_edge_mode_t ftm_dual_capture_edge_mode;
mbed_official 146:f64d43ff0c18 153 }ftm_edge_mode_t;
mbed_official 146:f64d43ff0c18 154 /*! @brief FlexTimer module configuration*/
mbed_official 146:f64d43ff0c18 155 typedef struct FTMConfig {
mbed_official 146:f64d43ff0c18 156 ftm_config_mode_t mode;
mbed_official 146:f64d43ff0c18 157 uint8_t channel; /*channel or channel pair in combine mode*/
mbed_official 146:f64d43ff0c18 158 ftm_edge_mode_t edge_mode;
mbed_official 146:f64d43ff0c18 159
mbed_official 146:f64d43ff0c18 160 }ftm_config_t;
mbed_official 146:f64d43ff0c18 161 /*FTM timer control*/
mbed_official 146:f64d43ff0c18 162 /*!
mbed_official 146:f64d43ff0c18 163 * @brief Sets the FTM clock source.
mbed_official 146:f64d43ff0c18 164 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 165 * @param clock The FTM peripheral clock selection
mbed_official 146:f64d43ff0c18 166 * bits:00: No clock 01: system clock 10 :fixed clock 11:External clock
mbed_official 146:f64d43ff0c18 167 */
mbed_official 146:f64d43ff0c18 168 static inline void ftm_hal_set_clock_source(uint8_t instance, ftm_clock_source_t clock)
mbed_official 146:f64d43ff0c18 169 {
mbed_official 146:f64d43ff0c18 170 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 171 BW_FTM_SC_CLKS(instance, clock);
mbed_official 146:f64d43ff0c18 172 }
mbed_official 146:f64d43ff0c18 173
mbed_official 146:f64d43ff0c18 174 /*!
mbed_official 146:f64d43ff0c18 175 * @brief Sets the FTM clock divider.
mbed_official 146:f64d43ff0c18 176 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 177 * @param ps The FTM peripheral clock pre-scale divider
mbed_official 146:f64d43ff0c18 178 */
mbed_official 146:f64d43ff0c18 179 static inline void ftm_hal_set_clock_ps(uint8_t instance, ftm_clock_ps_t ps)
mbed_official 146:f64d43ff0c18 180 {
mbed_official 146:f64d43ff0c18 181 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 182 BW_FTM_SC_PS(instance, ps);
mbed_official 146:f64d43ff0c18 183 }
mbed_official 146:f64d43ff0c18 184
mbed_official 146:f64d43ff0c18 185 /*!
mbed_official 146:f64d43ff0c18 186 * @brief Enables the FTM peripheral timer overflow interrupt.
mbed_official 146:f64d43ff0c18 187 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 188 */
mbed_official 146:f64d43ff0c18 189 static inline void ftm_hal_enable_timer_overflow_interrupt(uint8_t instance)
mbed_official 146:f64d43ff0c18 190 {
mbed_official 146:f64d43ff0c18 191 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 192 HW_FTM_SC_SET(instance, BM_FTM_SC_TOIE);
mbed_official 146:f64d43ff0c18 193 }
mbed_official 146:f64d43ff0c18 194
mbed_official 146:f64d43ff0c18 195 /*!
mbed_official 146:f64d43ff0c18 196 * @brief Disables the FTM peripheral timer overflow interrupt.
mbed_official 146:f64d43ff0c18 197 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 198 */
mbed_official 146:f64d43ff0c18 199 static inline void ftm_hal_disable_timer_overflow_interrupt(uint8_t instance)
mbed_official 146:f64d43ff0c18 200 {
mbed_official 146:f64d43ff0c18 201 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 202 HW_FTM_SC_CLR(instance, BM_FTM_SC_TOIE);
mbed_official 146:f64d43ff0c18 203 }
mbed_official 146:f64d43ff0c18 204
mbed_official 146:f64d43ff0c18 205 /*!
mbed_official 146:f64d43ff0c18 206 * @brief Returns the FTM peripheral timer overflow interrupt flag.
mbed_official 146:f64d43ff0c18 207 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 208 * @retval true if overflow, false if not
mbed_official 146:f64d43ff0c18 209 */
mbed_official 146:f64d43ff0c18 210 static inline bool ftm_is_timer_overflow(uint8_t instance)
mbed_official 146:f64d43ff0c18 211 {
mbed_official 146:f64d43ff0c18 212 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 213 return BR_FTM_SC_TOF(instance);
mbed_official 146:f64d43ff0c18 214 }
mbed_official 146:f64d43ff0c18 215
mbed_official 146:f64d43ff0c18 216 /*!
mbed_official 146:f64d43ff0c18 217 * @brief Sets the FTM center-aligned PWM select.
mbed_official 146:f64d43ff0c18 218 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 219 * @param mode 1:upcounting mode 0:up_down counting mode
mbed_official 146:f64d43ff0c18 220 */
mbed_official 146:f64d43ff0c18 221 static inline void ftm_hal_set_cpwms(uint8_t instance, uint8_t mode)
mbed_official 146:f64d43ff0c18 222 {
mbed_official 146:f64d43ff0c18 223 assert(instance <HW_FTM_INSTANCE_COUNT && mode<2);
mbed_official 146:f64d43ff0c18 224 BW_FTM_SC_CPWMS(instance, mode);
mbed_official 146:f64d43ff0c18 225 }
mbed_official 146:f64d43ff0c18 226
mbed_official 146:f64d43ff0c18 227 /*!
mbed_official 146:f64d43ff0c18 228 * @brief Sets the FTM peripheral current counter value.
mbed_official 146:f64d43ff0c18 229 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 230 * @param val FTM timer counter value to be set
mbed_official 146:f64d43ff0c18 231 */
mbed_official 146:f64d43ff0c18 232 static inline void ftm_hal_set_counter(uint8_t instance,uint16_t val)
mbed_official 146:f64d43ff0c18 233 {
mbed_official 146:f64d43ff0c18 234 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 235 BW_FTM_CNT_COUNT(instance, val);
mbed_official 146:f64d43ff0c18 236 }
mbed_official 146:f64d43ff0c18 237
mbed_official 146:f64d43ff0c18 238 /*!
mbed_official 146:f64d43ff0c18 239 * @brief Returns the FTM peripheral current counter value.
mbed_official 146:f64d43ff0c18 240 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 241 * @retval current FTM timer counter value
mbed_official 146:f64d43ff0c18 242 */
mbed_official 146:f64d43ff0c18 243 static inline uint16_t ftm_hal_get_counter(uint8_t instance)
mbed_official 146:f64d43ff0c18 244 {
mbed_official 146:f64d43ff0c18 245 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 246 return BR_FTM_CNT_COUNT(instance);
mbed_official 146:f64d43ff0c18 247 }
mbed_official 146:f64d43ff0c18 248
mbed_official 146:f64d43ff0c18 249 /*!
mbed_official 146:f64d43ff0c18 250 * @brief Sets the FTM peripheral timer modulo value.
mbed_official 146:f64d43ff0c18 251 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 252 * @param val The value to be set to the timer modulo
mbed_official 146:f64d43ff0c18 253 */
mbed_official 146:f64d43ff0c18 254 static inline void ftm_hal_set_mod(uint8_t instance, uint16_t val)
mbed_official 146:f64d43ff0c18 255 {
mbed_official 146:f64d43ff0c18 256 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 257 BW_FTM_MOD_MOD(instance, val);
mbed_official 146:f64d43ff0c18 258 }
mbed_official 146:f64d43ff0c18 259
mbed_official 146:f64d43ff0c18 260 /*!
mbed_official 146:f64d43ff0c18 261 * @brief Returns the FTM peripheral counter modulo value.
mbed_official 146:f64d43ff0c18 262 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 263 * @retval FTM timer modulo value
mbed_official 146:f64d43ff0c18 264 */
mbed_official 146:f64d43ff0c18 265 static inline uint16_t ftm_hal_get_mod(uint8_t instance)
mbed_official 146:f64d43ff0c18 266 {
mbed_official 146:f64d43ff0c18 267 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 268 return BR_FTM_MOD_MOD(instance);
mbed_official 146:f64d43ff0c18 269 }
mbed_official 146:f64d43ff0c18 270
mbed_official 146:f64d43ff0c18 271 /*!
mbed_official 146:f64d43ff0c18 272 * @brief Sets the FTM peripheral timer counter initial value.
mbed_official 146:f64d43ff0c18 273 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 274 * @param val initial value to be set
mbed_official 146:f64d43ff0c18 275 */
mbed_official 146:f64d43ff0c18 276 static inline void ftm_hal_set_counter_init_val(uint8_t instance, uint16_t val)
mbed_official 146:f64d43ff0c18 277 {
mbed_official 146:f64d43ff0c18 278 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 279 BW_FTM_CNTIN_INIT(instance, val&BM_FTM_CNTIN_INIT);
mbed_official 146:f64d43ff0c18 280 }
mbed_official 146:f64d43ff0c18 281
mbed_official 146:f64d43ff0c18 282 /*!
mbed_official 146:f64d43ff0c18 283 * @brief Returns the FTM peripheral counter initial value.
mbed_official 146:f64d43ff0c18 284 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 285 * @retval FTM timer counter initial value
mbed_official 146:f64d43ff0c18 286 */
mbed_official 146:f64d43ff0c18 287 static inline uint16_t ftm_hal_get_counter_init_val(uint8_t instance)
mbed_official 146:f64d43ff0c18 288 {
mbed_official 146:f64d43ff0c18 289 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 290 return BR_FTM_CNTIN_INIT(instance);
mbed_official 146:f64d43ff0c18 291 }
mbed_official 146:f64d43ff0c18 292
mbed_official 146:f64d43ff0c18 293 /*FTM channel operating mode (Mode, edge and level selection) for capture, output, PWM, combine, dual or quad*/
mbed_official 146:f64d43ff0c18 294 /*!
mbed_official 146:f64d43ff0c18 295 * @brief Sets the FTM peripheral timer channel mode.
mbed_official 146:f64d43ff0c18 296 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 297 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 298 * @param selection The mode to be set valid value MSnB:MSnA :00,01, 10, 11
mbed_official 146:f64d43ff0c18 299 */
mbed_official 146:f64d43ff0c18 300 static inline void ftm_hal_set_channel_MSnBA_mode(uint8_t instance, uint8_t channel, uint8_t selection)
mbed_official 146:f64d43ff0c18 301 {
mbed_official 146:f64d43ff0c18 302 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 303 BW_FTM_CnSC_MSA(instance, channel, selection&1);
mbed_official 146:f64d43ff0c18 304 BW_FTM_CnSC_MSB(instance, channel, selection&2? 1:0);
mbed_official 146:f64d43ff0c18 305
mbed_official 146:f64d43ff0c18 306 }
mbed_official 146:f64d43ff0c18 307
mbed_official 146:f64d43ff0c18 308 /*!
mbed_official 146:f64d43ff0c18 309 * @brief Sets the FTM peripheral timer channel edge level.
mbed_official 146:f64d43ff0c18 310 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 311 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 312 * @param level The rising or falling edge to be set, valid value ELSnB:ELSnA :00,01, 10, 11
mbed_official 146:f64d43ff0c18 313 */
mbed_official 146:f64d43ff0c18 314 static inline void ftm_hal_set_channel_edge_level(uint8_t instance, uint8_t channel, uint8_t level)
mbed_official 146:f64d43ff0c18 315 {
mbed_official 146:f64d43ff0c18 316 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 317 BW_FTM_CnSC_ELSA(instance, channel, level&1? 1:0);
mbed_official 146:f64d43ff0c18 318 BW_FTM_CnSC_ELSB(instance, channel, level&2?1:0);
mbed_official 146:f64d43ff0c18 319 }
mbed_official 146:f64d43ff0c18 320
mbed_official 146:f64d43ff0c18 321 /*!
mbed_official 146:f64d43ff0c18 322 * @brief Gets the FTM peripheral timer channel mode.
mbed_official 146:f64d43ff0c18 323 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 324 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 325 * @retval The MSnB:MSnA mode value, will be 00,01, 10, 11
mbed_official 146:f64d43ff0c18 326 */
mbed_official 146:f64d43ff0c18 327 static inline uint8_t ftm_hal_get_channel_mode(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 328 {
mbed_official 146:f64d43ff0c18 329 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 330 return (BR_FTM_CnSC_MSA(instance, channel)|| (BR_FTM_CnSC_MSB(instance, channel)<<1));
mbed_official 146:f64d43ff0c18 331 }
mbed_official 146:f64d43ff0c18 332
mbed_official 146:f64d43ff0c18 333 /*!
mbed_official 146:f64d43ff0c18 334 * @brief Gets the FTM peripheral timer channel edge level.
mbed_official 146:f64d43ff0c18 335 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 336 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 337 * @retval The ELSnB:ELSnA mode value, will be 00,01, 10, 11
mbed_official 146:f64d43ff0c18 338 */
mbed_official 146:f64d43ff0c18 339 static inline uint8_t ftm_hal_get_channel_edge_level(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 340 {
mbed_official 146:f64d43ff0c18 341 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 342 return (BR_FTM_CnSC_ELSA(instance, channel)|| (BR_FTM_CnSC_ELSB(instance, channel)<<1));
mbed_official 146:f64d43ff0c18 343 }
mbed_official 146:f64d43ff0c18 344
mbed_official 146:f64d43ff0c18 345 /*!
mbed_official 146:f64d43ff0c18 346 * @brief Enables or disables the FTM peripheral timer channel DMA.
mbed_official 146:f64d43ff0c18 347 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 348 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 349 * @param val enable or disable
mbed_official 146:f64d43ff0c18 350 */
mbed_official 146:f64d43ff0c18 351 static inline void ftm_hal_enable_channle_dma(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 352 {
mbed_official 146:f64d43ff0c18 353 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 354 BW_FTM_CnSC_DMA(instance, channel,(val? 1:0));
mbed_official 146:f64d43ff0c18 355 }
mbed_official 146:f64d43ff0c18 356
mbed_official 146:f64d43ff0c18 357 /*!
mbed_official 146:f64d43ff0c18 358 * @brief Returns whether the FTM peripheral timer channel DMA is enabled.
mbed_official 146:f64d43ff0c18 359 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 360 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 361 * @retval true if enabled, false if disabled
mbed_official 146:f64d43ff0c18 362 */
mbed_official 146:f64d43ff0c18 363 static inline bool ftm_hal_is_channel_dma(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 364 {
mbed_official 146:f64d43ff0c18 365 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 366 return (BR_FTM_CnSC_DMA(instance, channel) ? true : false);
mbed_official 146:f64d43ff0c18 367 }
mbed_official 146:f64d43ff0c18 368
mbed_official 146:f64d43ff0c18 369 /*!
mbed_official 146:f64d43ff0c18 370 * @brief Enables the FTM peripheral timer channel(n) interrupt.
mbed_official 146:f64d43ff0c18 371 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 372 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 373 */
mbed_official 146:f64d43ff0c18 374 static inline void ftm_hal_enable_channel_interrupt(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 375 {
mbed_official 146:f64d43ff0c18 376 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 377 BW_FTM_CnSC_CHIE(instance, channel, 1);
mbed_official 146:f64d43ff0c18 378 }
mbed_official 146:f64d43ff0c18 379 /*!
mbed_official 146:f64d43ff0c18 380 * @brief Disables the FTM peripheral timer channel(n) interrupt.
mbed_official 146:f64d43ff0c18 381 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 382 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 383 */
mbed_official 146:f64d43ff0c18 384 static inline void ftm_hal_disable_channel_interrupt(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 385 {
mbed_official 146:f64d43ff0c18 386 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 387 BW_FTM_CnSC_CHIE(instance, channel, 0);
mbed_official 146:f64d43ff0c18 388 }
mbed_official 146:f64d43ff0c18 389
mbed_official 146:f64d43ff0c18 390 /*!
mbed_official 146:f64d43ff0c18 391 * @brief Returns whether any event for the FTM peripheral timer channel has occurred.
mbed_official 146:f64d43ff0c18 392 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 393 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 394 * @retval true if event occurred, false otherwise.
mbed_official 146:f64d43ff0c18 395 */
mbed_official 146:f64d43ff0c18 396 static inline bool ftm_is_channel_event_occurred(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 397 {
mbed_official 146:f64d43ff0c18 398 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 399 return (BR_FTM_CnSC_CHF(instance, channel))? true : false;
mbed_official 146:f64d43ff0c18 400 }
mbed_official 146:f64d43ff0c18 401
mbed_official 146:f64d43ff0c18 402 /*FTM channel control*/
mbed_official 146:f64d43ff0c18 403 /*!
mbed_official 146:f64d43ff0c18 404 * @brief Sets the FTM peripheral timer channel counter value.
mbed_official 146:f64d43ff0c18 405 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 406 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 407 * @param val counter value to be set
mbed_official 146:f64d43ff0c18 408 */
mbed_official 146:f64d43ff0c18 409 static inline void ftm_hal_set_channel_count_value(uint8_t instance, uint8_t channel, uint16_t val)
mbed_official 146:f64d43ff0c18 410 {
mbed_official 146:f64d43ff0c18 411 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 412 HW_FTM_CnV_WR(instance, channel, val);
mbed_official 146:f64d43ff0c18 413 }
mbed_official 146:f64d43ff0c18 414
mbed_official 146:f64d43ff0c18 415 /*!
mbed_official 146:f64d43ff0c18 416 * @brief Gets the FTM peripheral timer channel counter value.
mbed_official 146:f64d43ff0c18 417 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 418 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 419 * @retval val return current channel counter value
mbed_official 146:f64d43ff0c18 420 */
mbed_official 146:f64d43ff0c18 421 static inline uint16_t ftm_hal_get_channel_count_value(uint8_t instance, uint8_t channel, uint16_t val)
mbed_official 146:f64d43ff0c18 422 {
mbed_official 146:f64d43ff0c18 423 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 424 return BR_FTM_CnV_VAL(instance, channel);
mbed_official 146:f64d43ff0c18 425 }
mbed_official 146:f64d43ff0c18 426
mbed_official 146:f64d43ff0c18 427 /*!
mbed_official 146:f64d43ff0c18 428 * @brief Gets the FTM peripheral timer channel event status.
mbed_official 146:f64d43ff0c18 429 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 430 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 431 * @retval val return current channel event status value
mbed_official 146:f64d43ff0c18 432 */
mbed_official 146:f64d43ff0c18 433 static inline uint32_t ftm_hal_get_channel_event_status(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 434 {
mbed_official 146:f64d43ff0c18 435 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 436 return (HW_FTM_STATUS_RD(instance)&(1U<<channel))? true: false;
mbed_official 146:f64d43ff0c18 437 /*return BR_FTM_STATUS(instance, channel);*/
mbed_official 146:f64d43ff0c18 438 }
mbed_official 146:f64d43ff0c18 439
mbed_official 146:f64d43ff0c18 440 /*!
mbed_official 146:f64d43ff0c18 441 * @brief Clears the FTM peripheral timer all channel event status.
mbed_official 146:f64d43ff0c18 442 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 443 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 444 * @retval val return current channel counter value
mbed_official 146:f64d43ff0c18 445 */
mbed_official 146:f64d43ff0c18 446 static inline void ftm_hal_clear_channel_event_status(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 447 {
mbed_official 146:f64d43ff0c18 448 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 449 HW_FTM_STATUS_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 450 }
mbed_official 146:f64d43ff0c18 451
mbed_official 146:f64d43ff0c18 452 /*!
mbed_official 146:f64d43ff0c18 453 * @brief Sets the FTM peripheral timer channel output mask.
mbed_official 146:f64d43ff0c18 454 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 455 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 456 * @param mask mask to be set 0 or 1, unmasked or masked
mbed_official 146:f64d43ff0c18 457 */
mbed_official 146:f64d43ff0c18 458 static inline void ftm_hal_set_channel_output_mask(uint8_t instance, uint8_t channel, bool mask)
mbed_official 146:f64d43ff0c18 459 {
mbed_official 146:f64d43ff0c18 460 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 461 mask? HW_FTM_OUTMASK_SET(instance, 1U<<channel):HW_FTM_OUTMASK_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 462 /* BW_FTM_OUTMASK_CHnOM(instance, channel,mask); */
mbed_official 146:f64d43ff0c18 463 }
mbed_official 146:f64d43ff0c18 464
mbed_official 146:f64d43ff0c18 465 /*!
mbed_official 146:f64d43ff0c18 466 * @brief Sets the FTM peripheral timer channel output initial state 0 or 1.
mbed_official 146:f64d43ff0c18 467 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 468 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 469 * @param state counter value to be set 0 or 1
mbed_official 146:f64d43ff0c18 470 */
mbed_official 146:f64d43ff0c18 471 static inline void ftm_hal_set_channel_output_init_state(uint8_t instance, uint8_t channel, uint8_t state)
mbed_official 146:f64d43ff0c18 472 {
mbed_official 146:f64d43ff0c18 473 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 474 HW_FTM_OUTINIT_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 475 HW_FTM_OUTINIT_SET(instance, (uint8_t)(state<<channel));
mbed_official 146:f64d43ff0c18 476 }
mbed_official 146:f64d43ff0c18 477
mbed_official 146:f64d43ff0c18 478 /*!
mbed_official 146:f64d43ff0c18 479 * @brief Sets the FTM peripheral timer channel output polarity.
mbed_official 146:f64d43ff0c18 480 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 481 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 482 * @param pol polarity to be set 0 or 1
mbed_official 146:f64d43ff0c18 483 */
mbed_official 146:f64d43ff0c18 484 static inline void ftm_hal_set_channel_output_polarity(uint8_t instance, uint8_t channel, uint8_t pol)
mbed_official 146:f64d43ff0c18 485 {
mbed_official 146:f64d43ff0c18 486 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 487 HW_FTM_POL_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 488 HW_FTM_POL_SET(instance, (uint8_t)(pol<<channel));
mbed_official 146:f64d43ff0c18 489 }
mbed_official 146:f64d43ff0c18 490 /*!
mbed_official 146:f64d43ff0c18 491 * @brief Sets the FTM peripheral timer channel input polarity.
mbed_official 146:f64d43ff0c18 492 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 493 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 494 * @param pol polarity to be set, 0: active high, 1:active low
mbed_official 146:f64d43ff0c18 495 */
mbed_official 146:f64d43ff0c18 496 static inline void ftm_hal_set_channel_fault_input_polarity(uint8_t instance, uint8_t channel, uint8_t pol)
mbed_official 146:f64d43ff0c18 497 {
mbed_official 146:f64d43ff0c18 498 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 499 HW_FTM_FLTPOL_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 500 HW_FTM_FLTPOL_SET(instance, (uint8_t)(pol<<channel));
mbed_official 146:f64d43ff0c18 501 }
mbed_official 146:f64d43ff0c18 502
mbed_official 146:f64d43ff0c18 503
mbed_official 146:f64d43ff0c18 504 /*Feature mode selection HAL*/
mbed_official 146:f64d43ff0c18 505 /*FTM fault control*/
mbed_official 146:f64d43ff0c18 506 /*!
mbed_official 146:f64d43ff0c18 507 * @brief Enables the FTM peripheral timer fault interrupt.
mbed_official 146:f64d43ff0c18 508 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 509 */
mbed_official 146:f64d43ff0c18 510 static inline void ftm_hal_enable_fault_interrupt(uint8_t instance)
mbed_official 146:f64d43ff0c18 511 {
mbed_official 146:f64d43ff0c18 512 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 513 BW_FTM_MODE_FAULTIE(instance, 1);
mbed_official 146:f64d43ff0c18 514 }
mbed_official 146:f64d43ff0c18 515
mbed_official 146:f64d43ff0c18 516 /*!
mbed_official 146:f64d43ff0c18 517 * @brief Disables the FTM peripheral timer fault interrupt.
mbed_official 146:f64d43ff0c18 518 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 519 */
mbed_official 146:f64d43ff0c18 520 static inline void ftm_hal_disable_fault_interrupt(uint8_t instance)
mbed_official 146:f64d43ff0c18 521 {
mbed_official 146:f64d43ff0c18 522 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 523 BW_FTM_MODE_FAULTIE(instance, 0);
mbed_official 146:f64d43ff0c18 524 }
mbed_official 146:f64d43ff0c18 525
mbed_official 146:f64d43ff0c18 526 /*!
mbed_official 146:f64d43ff0c18 527 * @brief Sets the FTM peripheral timer fault control mode.
mbed_official 146:f64d43ff0c18 528 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 529 * @param mode, valid number bits:00, 01, 10,11 (1, 2, 3, 4)
mbed_official 146:f64d43ff0c18 530 */
mbed_official 146:f64d43ff0c18 531 static inline void ftm_hal_set_fault_control_mode(uint8_t instance, uint8_t mode)
mbed_official 146:f64d43ff0c18 532 {
mbed_official 146:f64d43ff0c18 533 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 534 BW_FTM_MODE_FAULTM(instance, mode);
mbed_official 146:f64d43ff0c18 535 }
mbed_official 146:f64d43ff0c18 536
mbed_official 146:f64d43ff0c18 537 /*!
mbed_official 146:f64d43ff0c18 538 * @brief Enables the FTM peripheral timer capture test.
mbed_official 146:f64d43ff0c18 539 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 540 * @param enable true to enable, false to disable
mbed_official 146:f64d43ff0c18 541 */
mbed_official 146:f64d43ff0c18 542 static inline void ftm_hal_enable_capture_test(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 543 {
mbed_official 146:f64d43ff0c18 544 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 545 BW_FTM_MODE_CAPTEST(instance, enable? 1: 0);
mbed_official 146:f64d43ff0c18 546 }
mbed_official 146:f64d43ff0c18 547
mbed_official 146:f64d43ff0c18 548 /*!
mbed_official 146:f64d43ff0c18 549 * @brief Enables the FTM peripheral timer write protection.
mbed_official 146:f64d43ff0c18 550 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 551 * @param enable true to enable, false to disable
mbed_official 146:f64d43ff0c18 552 */
mbed_official 146:f64d43ff0c18 553 static inline void ftm_hal_enable_write_protection(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 554 {
mbed_official 146:f64d43ff0c18 555 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 556 BW_FTM_MODE_WPDIS(instance, enable? 0: 1);
mbed_official 146:f64d43ff0c18 557 }
mbed_official 146:f64d43ff0c18 558
mbed_official 146:f64d43ff0c18 559 /*!
mbed_official 146:f64d43ff0c18 560 * @brief Enables the FTM peripheral timer group.
mbed_official 146:f64d43ff0c18 561 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 562 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 563 */
mbed_official 146:f64d43ff0c18 564 static inline void ftm_hal_ftm_enable(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 565 {
mbed_official 146:f64d43ff0c18 566 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 567 assert(BR_FTM_MODE_WPDIS(instance));
mbed_official 146:f64d43ff0c18 568 BW_FTM_MODE_FTMEN(instance, enable? 0: 1);
mbed_official 146:f64d43ff0c18 569 }
mbed_official 146:f64d43ff0c18 570
mbed_official 146:f64d43ff0c18 571 /*!
mbed_official 146:f64d43ff0c18 572 * @brief Enables the FTM peripheral timer channel output initialization.
mbed_official 146:f64d43ff0c18 573 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 574 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 575 */
mbed_official 146:f64d43ff0c18 576 static inline void ftm_hal_enable_channel_init_output(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 577 {
mbed_official 146:f64d43ff0c18 578 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 579 BW_FTM_MODE_INIT(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 580 }
mbed_official 146:f64d43ff0c18 581
mbed_official 146:f64d43ff0c18 582 /*!
mbed_official 146:f64d43ff0c18 583 * @brief Sets the FTM peripheral timer sync mode.
mbed_official 146:f64d43ff0c18 584 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 585 * @param enable True no restriction both software and hardware sync, false only software sync.
mbed_official 146:f64d43ff0c18 586 */
mbed_official 146:f64d43ff0c18 587 static inline void ftm_hal_set_pwm_sync_mdoe(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 588 {
mbed_official 146:f64d43ff0c18 589 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 590 BW_FTM_MODE_PWMSYNC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 591 }
mbed_official 146:f64d43ff0c18 592
mbed_official 146:f64d43ff0c18 593 /*FTM synchronization control*/
mbed_official 146:f64d43ff0c18 594 /*!
mbed_official 146:f64d43ff0c18 595 * @brief Enables the FTM peripheral timer software trigger.
mbed_official 146:f64d43ff0c18 596 * @param instance The FTM peripheral instance number.
mbed_official 146:f64d43ff0c18 597 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 598 */
mbed_official 146:f64d43ff0c18 599 static inline void ftm_hal_enable_software_trigger(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 600 {
mbed_official 146:f64d43ff0c18 601 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 602 BW_FTM_SYNC_SWSYNC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 603 }
mbed_official 146:f64d43ff0c18 604
mbed_official 146:f64d43ff0c18 605 /*!
mbed_official 146:f64d43ff0c18 606 * @brief Sets the FTM peripheral timer hardware trigger.
mbed_official 146:f64d43ff0c18 607 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 608 * @param trigger_num 0, 1,2 for trigger0, trigger1 and trigger3
mbed_official 146:f64d43ff0c18 609 * @param enable True to enable, 1 to enable
mbed_official 146:f64d43ff0c18 610 */
mbed_official 146:f64d43ff0c18 611 void ftm_hal_set_hardware_trigger(uint8_t instance, uint8_t trigger_num, bool enable);
mbed_official 146:f64d43ff0c18 612
mbed_official 146:f64d43ff0c18 613 /*!
mbed_official 146:f64d43ff0c18 614 * @brief Enables the FTM peripheral timer output mask update by PWM sync.
mbed_official 146:f64d43ff0c18 615 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 616 * @param enable True to enable PWM sync, false to enable outmask in the rising edges of the system clock
mbed_official 146:f64d43ff0c18 617 */
mbed_official 146:f64d43ff0c18 618 static inline void ftm_hal_enable_output_mask_sync_by_pwm(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 619 {
mbed_official 146:f64d43ff0c18 620 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 621 BW_FTM_SYNC_SYNCHOM(instance, enable?1:0);
mbed_official 146:f64d43ff0c18 622 }
mbed_official 146:f64d43ff0c18 623
mbed_official 146:f64d43ff0c18 624 /*!
mbed_official 146:f64d43ff0c18 625 * @brief Enables the FTM peripheral timer counter re-initialized by sync.
mbed_official 146:f64d43ff0c18 626 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 627 * @param enable True to update FTM counter when triggered , false to count normally
mbed_official 146:f64d43ff0c18 628 */
mbed_official 146:f64d43ff0c18 629 static inline void ftm_hal_enable_count_reinit_sync(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 630 {
mbed_official 146:f64d43ff0c18 631 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 632 BW_FTM_SYNC_REINIT(instance, enable?1:0);
mbed_official 146:f64d43ff0c18 633 }
mbed_official 146:f64d43ff0c18 634 /*!
mbed_official 146:f64d43ff0c18 635 * @brief Enables the FTM peripheral timer maximum loading points.
mbed_official 146:f64d43ff0c18 636 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 637 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 638 */
mbed_official 146:f64d43ff0c18 639 static inline void ftm_hal_enable_max_loading(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 640 {
mbed_official 146:f64d43ff0c18 641 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 642 BW_FTM_SYNC_CNTMAX(instance, enable?1:0);
mbed_official 146:f64d43ff0c18 643 }
mbed_official 146:f64d43ff0c18 644 /*!
mbed_official 146:f64d43ff0c18 645 * @brief Enables the FTM peripheral timer minimum loading points.
mbed_official 146:f64d43ff0c18 646 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 647 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 648 */
mbed_official 146:f64d43ff0c18 649 static inline void ftm_hal_enable_min_loading(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 650 {
mbed_official 146:f64d43ff0c18 651 assert(instance <HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 652 BW_FTM_SYNC_CNTMIN(instance, enable?1:0);
mbed_official 146:f64d43ff0c18 653 }
mbed_official 146:f64d43ff0c18 654
mbed_official 146:f64d43ff0c18 655 /*!
mbed_official 146:f64d43ff0c18 656 * @brief Combines the channel control.
mbed_official 146:f64d43ff0c18 657 *
mbed_official 146:f64d43ff0c18 658 * Returns an index for each channel pair.
mbed_official 146:f64d43ff0c18 659 *
mbed_official 146:f64d43ff0c18 660 * @param channel The FTM peripheral channel number.
mbed_official 146:f64d43ff0c18 661 * @return 0 for channel pair 0 & 1\n
mbed_official 146:f64d43ff0c18 662 * 1 for channel pair 2 & 3\n
mbed_official 146:f64d43ff0c18 663 * 2 for channel pair 4 & 5\n
mbed_official 146:f64d43ff0c18 664 * 3 for channel pair 6 & 7
mbed_official 146:f64d43ff0c18 665 */
mbed_official 146:f64d43ff0c18 666 static uint32_t get_channel_pair_index(uint8_t channel)
mbed_official 146:f64d43ff0c18 667 {
mbed_official 146:f64d43ff0c18 668 if((channel == HW_CHAN0) || (channel == HW_CHAN1))
mbed_official 146:f64d43ff0c18 669 {
mbed_official 146:f64d43ff0c18 670 return 0;
mbed_official 146:f64d43ff0c18 671 }
mbed_official 146:f64d43ff0c18 672 else if((channel == HW_CHAN2) || (channel == HW_CHAN3))
mbed_official 146:f64d43ff0c18 673 {
mbed_official 146:f64d43ff0c18 674 return 1;
mbed_official 146:f64d43ff0c18 675 }
mbed_official 146:f64d43ff0c18 676 else if((channel == HW_CHAN4) || (channel == HW_CHAN5))
mbed_official 146:f64d43ff0c18 677 {
mbed_official 146:f64d43ff0c18 678 return 2;
mbed_official 146:f64d43ff0c18 679 }
mbed_official 146:f64d43ff0c18 680 else
mbed_official 146:f64d43ff0c18 681 {
mbed_official 146:f64d43ff0c18 682 return 3;
mbed_official 146:f64d43ff0c18 683 }
mbed_official 146:f64d43ff0c18 684 }
mbed_official 146:f64d43ff0c18 685
mbed_official 146:f64d43ff0c18 686 /*set DECAPEN bit*/
mbed_official 146:f64d43ff0c18 687 /*!
mbed_official 146:f64d43ff0c18 688 * @brief Enables the FTM peripheral timer dual edge capture mode.
mbed_official 146:f64d43ff0c18 689 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 690 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 691 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 692 */
mbed_official 146:f64d43ff0c18 693 static inline void ftm_hal_enable_dual_capture(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 694 {
mbed_official 146:f64d43ff0c18 695 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 696
mbed_official 146:f64d43ff0c18 697 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_DECAPEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 698 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_DECAPEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 699 }
mbed_official 146:f64d43ff0c18 700
mbed_official 146:f64d43ff0c18 701 /*!
mbed_official 146:f64d43ff0c18 702 * @brief Enables the FTM peripheral timer channel pair fault control.
mbed_official 146:f64d43ff0c18 703 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 704 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 705 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 706 */
mbed_official 146:f64d43ff0c18 707 static inline void ftm_hal_enable_dual_channel_fault(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 708 {
mbed_official 146:f64d43ff0c18 709 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 710
mbed_official 146:f64d43ff0c18 711 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_FAULTEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 712 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_FAULTEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 713 }
mbed_official 146:f64d43ff0c18 714
mbed_official 146:f64d43ff0c18 715 /*!
mbed_official 146:f64d43ff0c18 716 * @brief Enables the FTM peripheral timer channel pair counter PWM sync.
mbed_official 146:f64d43ff0c18 717 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 718 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 719 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 720 */
mbed_official 146:f64d43ff0c18 721 static inline void ftm_hal_enable_dual_channel_pwm_sync(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 722 {
mbed_official 146:f64d43ff0c18 723 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 724
mbed_official 146:f64d43ff0c18 725 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_SYNCEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 726 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_SYNCEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 727 }
mbed_official 146:f64d43ff0c18 728
mbed_official 146:f64d43ff0c18 729 /*!
mbed_official 146:f64d43ff0c18 730 * @brief Enables the FTM peripheral timer channel pair deadtime.
mbed_official 146:f64d43ff0c18 731 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 732 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 733 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 734 */
mbed_official 146:f64d43ff0c18 735 static inline void ftm_hal_enable_dual_channel_deadtime(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 736 {
mbed_official 146:f64d43ff0c18 737 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 738
mbed_official 146:f64d43ff0c18 739 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_DTEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 740 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_DTEN0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 741 }
mbed_official 146:f64d43ff0c18 742
mbed_official 146:f64d43ff0c18 743 /*!
mbed_official 146:f64d43ff0c18 744 * @brief Enables the FTM peripheral timer channel dual edge capture decap, not decapen.
mbed_official 146:f64d43ff0c18 745 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 746 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 747 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 748 */
mbed_official 146:f64d43ff0c18 749 static inline void ftm_hal_enable_dual_channel_decap(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 750 {
mbed_official 146:f64d43ff0c18 751 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 752
mbed_official 146:f64d43ff0c18 753 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_DECAP0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 754 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_DECAP0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 755 }
mbed_official 146:f64d43ff0c18 756
mbed_official 146:f64d43ff0c18 757 /*!
mbed_official 146:f64d43ff0c18 758 * @brief Enables the FTM peripheral timer channel pair output complement mode.
mbed_official 146:f64d43ff0c18 759 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 760 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 761 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 762 */
mbed_official 146:f64d43ff0c18 763 static inline void ftm_hal_enable_dual_channel_comp(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 764 {
mbed_official 146:f64d43ff0c18 765 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 766
mbed_official 146:f64d43ff0c18 767 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_COMP0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 768 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_COMP0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 769
mbed_official 146:f64d43ff0c18 770 }
mbed_official 146:f64d43ff0c18 771
mbed_official 146:f64d43ff0c18 772 /*!
mbed_official 146:f64d43ff0c18 773 * @brief Enables the FTM peripheral timer channel pair output combine mode.
mbed_official 146:f64d43ff0c18 774 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 775 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 776 * @param enable True to enable channel pair to combine, false to disable
mbed_official 146:f64d43ff0c18 777 */
mbed_official 146:f64d43ff0c18 778 static inline void ftm_hal_enable_dual_channel_combine(uint8_t instance, uint8_t channel, bool enable)
mbed_official 146:f64d43ff0c18 779 {
mbed_official 146:f64d43ff0c18 780 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 781
mbed_official 146:f64d43ff0c18 782 enable? HW_FTM_COMBINE_SET(instance, BM_FTM_COMBINE_COMBINE0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH)):
mbed_official 146:f64d43ff0c18 783 HW_FTM_COMBINE_CLR(instance, BM_FTM_COMBINE_COMBINE0 << (get_channel_pair_index(channel) * FTM_COMBINE_CHAN_CTRL_WIDTH));
mbed_official 146:f64d43ff0c18 784 }
mbed_official 146:f64d43ff0c18 785
mbed_official 146:f64d43ff0c18 786 /*FTM dead time insertion control*/
mbed_official 146:f64d43ff0c18 787 /*!
mbed_official 146:f64d43ff0c18 788 * @brief Set the FTM deadtime divider.
mbed_official 146:f64d43ff0c18 789 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 790 * @param divider The FTM peripheral prescale divider
mbed_official 146:f64d43ff0c18 791 0x :divided by 1, 10: divided by 4 11:divided by 16
mbed_official 146:f64d43ff0c18 792 */
mbed_official 146:f64d43ff0c18 793 static inline void ftm_hal_set_deadtime_prescale(uint8_t instance, ftm_deadtime_ps_t divider)
mbed_official 146:f64d43ff0c18 794 {
mbed_official 146:f64d43ff0c18 795 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 796 BW_FTM_DEADTIME_DTVAL(instance, divider);
mbed_official 146:f64d43ff0c18 797 }
mbed_official 146:f64d43ff0c18 798
mbed_official 146:f64d43ff0c18 799 /*!
mbed_official 146:f64d43ff0c18 800 * @brief Sets the FTM deadtime value.
mbed_official 146:f64d43ff0c18 801 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 802 * @param divider The FTM peripheral prescale divider
mbed_official 146:f64d43ff0c18 803 count: 0, no counts inserted 1: 1 count is inserted 2: 2 count is inserted....
mbed_official 146:f64d43ff0c18 804 */
mbed_official 146:f64d43ff0c18 805 static inline void ftm_hal_set_deadtime_count(uint8_t instance, uint8_t count)
mbed_official 146:f64d43ff0c18 806 {
mbed_official 146:f64d43ff0c18 807 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 808 BW_FTM_DEADTIME_DTPS(instance, count);
mbed_official 146:f64d43ff0c18 809 }
mbed_official 146:f64d43ff0c18 810 /*FTM external trigger */
mbed_official 146:f64d43ff0c18 811 /*!
mbed_official 146:f64d43ff0c18 812 * @brief Enables the generation of the FTM peripheral timer channel trigger when the FTM counter is equal to its initial value.
mbed_official 146:f64d43ff0c18 813 Channels 6 and 7 cannot be used as triggers.
mbed_official 146:f64d43ff0c18 814 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 815 * @param channel Channel to be enabled, valid value 0, 1, 2, 3, 4, 5
mbed_official 146:f64d43ff0c18 816 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 817 */
mbed_official 146:f64d43ff0c18 818 void ftm_hal_enable_channel_trigger(uint8_t instance, uint8_t channel, bool val);
mbed_official 146:f64d43ff0c18 819 /*!
mbed_official 146:f64d43ff0c18 820 * @brief Checks whether any channel trigger event has occurred.
mbed_official 146:f64d43ff0c18 821 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 822 * @retval True if there is a trigger event, false if not.
mbed_official 146:f64d43ff0c18 823 */
mbed_official 146:f64d43ff0c18 824 static inline bool ftm_hal_is_channel_trigger_generated(uint8_t instance, uint8_t channel)
mbed_official 146:f64d43ff0c18 825 {
mbed_official 146:f64d43ff0c18 826 assert(instance <HW_FTM_INSTANCE_COUNT && channel < HW_CHAN6);
mbed_official 146:f64d43ff0c18 827 return BR_FTM_EXTTRIG_TRIGF(instance);
mbed_official 146:f64d43ff0c18 828 }
mbed_official 146:f64d43ff0c18 829
mbed_official 146:f64d43ff0c18 830
mbed_official 146:f64d43ff0c18 831 /*Fault mode status*/
mbed_official 146:f64d43ff0c18 832 /*!
mbed_official 146:f64d43ff0c18 833 * @brief Gets the FTM detected fault input.
mbed_official 146:f64d43ff0c18 834 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 835 * @retval Return faulty byte
mbed_official 146:f64d43ff0c18 836 */
mbed_official 146:f64d43ff0c18 837 static inline uint8_t ftm_hal_get_detected_fault_input(uint8_t instance)
mbed_official 146:f64d43ff0c18 838 {
mbed_official 146:f64d43ff0c18 839 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 840 return (HW_FTM_FMS(instance).U &0x0f);
mbed_official 146:f64d43ff0c18 841 }
mbed_official 146:f64d43ff0c18 842 /*!
mbed_official 146:f64d43ff0c18 843 * @brief Checks whether the write protection is enabled.
mbed_official 146:f64d43ff0c18 844 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 845 * @retval True if enabled, false if not
mbed_official 146:f64d43ff0c18 846 */
mbed_official 146:f64d43ff0c18 847 static inline bool ftm_hal_is_write_protection_enable(uint8_t instance)
mbed_official 146:f64d43ff0c18 848 {
mbed_official 146:f64d43ff0c18 849 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 850 return BR_FTM_FMS_WPEN(instance)? true:false;
mbed_official 146:f64d43ff0c18 851 }
mbed_official 146:f64d43ff0c18 852
mbed_official 146:f64d43ff0c18 853 /*Quadrature decoder control*/
mbed_official 146:f64d43ff0c18 854 /*!
mbed_official 146:f64d43ff0c18 855 * @brief Enables the channel quadrature decoder.
mbed_official 146:f64d43ff0c18 856 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 857 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 858 */
mbed_official 146:f64d43ff0c18 859 static inline void ftm_hal_enable_quad_capture(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 860 {
mbed_official 146:f64d43ff0c18 861 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 862 }
mbed_official 146:f64d43ff0c18 863
mbed_official 146:f64d43ff0c18 864 /*Hardware definition for quadrature decoder control is missing, implement this later */
mbed_official 146:f64d43ff0c18 865 /*static inline void ftm_hal_enable_quad_input_filter(uint8_t instance, ftm_phase_t phase)
mbed_official 146:f64d43ff0c18 866 static inline void ftm_hal_set_quad_phase_normal_polarity(uint8_t instance, ftm_phase_t phase)
mbed_official 146:f64d43ff0c18 867 static inline void ftm_hal_set_quad_phase_invert_polarity(uint8_t instance, ftm_phase_t phase)
mbed_official 146:f64d43ff0c18 868 static inline void ftm_hal_set_quad_mode()
mbed_official 146:f64d43ff0c18 869 static inline void ftm_hal_set_quad_direction()
mbed_official 146:f64d43ff0c18 870 static inline void ftm_hal_set_quad_timer_overflow_direction()*/
mbed_official 146:f64d43ff0c18 871
mbed_official 146:f64d43ff0c18 872 /*!
mbed_official 146:f64d43ff0c18 873 * @brief Sets the FTM peripheral timer channel input capture filter value.
mbed_official 146:f64d43ff0c18 874 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 875 * @param channel The FTM peripheral channel number, only 0,1,2,3, channel 4, 5,6, 7 don't have.
mbed_official 146:f64d43ff0c18 876 * @param val Filter value to be set
mbed_official 146:f64d43ff0c18 877 */
mbed_official 146:f64d43ff0c18 878 void ftm_hal_set_channel_input_capture_filter(uint8_t instance, uint8_t channel, uint8_t val);
mbed_official 146:f64d43ff0c18 879
mbed_official 146:f64d43ff0c18 880
mbed_official 146:f64d43ff0c18 881
mbed_official 146:f64d43ff0c18 882 /*!
mbed_official 146:f64d43ff0c18 883 * @brief Enables the channel input filter.
mbed_official 146:f64d43ff0c18 884 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 885 * @param channel Channel to be enabled, valid value 0, 1, 2, 3
mbed_official 146:f64d43ff0c18 886 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 887 */
mbed_official 146:f64d43ff0c18 888 static inline void ftm_hal_enable_channel_fault_input_filter(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 889 {
mbed_official 146:f64d43ff0c18 890 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_CHAN4);
mbed_official 146:f64d43ff0c18 891 val? HW_FTM_FLTCTRL_SET(instance, (1U<<channel)) : HW_FTM_FLTCTRL_CLR(instance, (1U<<channel));
mbed_official 146:f64d43ff0c18 892 }
mbed_official 146:f64d43ff0c18 893
mbed_official 146:f64d43ff0c18 894 /*!
mbed_official 146:f64d43ff0c18 895 * @brief Enables the channel fault input.
mbed_official 146:f64d43ff0c18 896 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 897 * @param channel Channel to be enabled, valid value 0, 1, 2, 3
mbed_official 146:f64d43ff0c18 898 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 899 */
mbed_official 146:f64d43ff0c18 900 static inline void ftm_hal_enable_channel_fault_input(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 901 {
mbed_official 146:f64d43ff0c18 902 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_CHAN4);
mbed_official 146:f64d43ff0c18 903 val ? HW_FTM_FLTCTRL_SET(instance, ((1U << channel) + 4))
mbed_official 146:f64d43ff0c18 904 : HW_FTM_FLTCTRL_CLR(instance, ((1U << channel) + 4));
mbed_official 146:f64d43ff0c18 905 }
mbed_official 146:f64d43ff0c18 906
mbed_official 146:f64d43ff0c18 907 /*!
mbed_official 146:f64d43ff0c18 908 * @brief Enables the channel invert.
mbed_official 146:f64d43ff0c18 909 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 910 * @param channel The FTM peripheral channel number
mbed_official 146:f64d43ff0c18 911 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 912 */
mbed_official 146:f64d43ff0c18 913 static inline void ftm_hal_enable_dual_channel_invert(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 914 {
mbed_official 146:f64d43ff0c18 915 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 916
mbed_official 146:f64d43ff0c18 917 val ? HW_FTM_INVCTRL_SET(instance, (1U << get_channel_pair_index(channel)))
mbed_official 146:f64d43ff0c18 918 : HW_FTM_INVCTRL_CLR(instance, (1U << get_channel_pair_index(channel)));
mbed_official 146:f64d43ff0c18 919 }
mbed_official 146:f64d43ff0c18 920
mbed_official 146:f64d43ff0c18 921 /*FTM software output control*/
mbed_official 146:f64d43ff0c18 922 /*!
mbed_official 146:f64d43ff0c18 923 * @brief Enables the channel software control.
mbed_official 146:f64d43ff0c18 924 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 925 * @param channel Channel to be enabled, valid value 0, 1, 2, 3, 4,5,6,7
mbed_official 146:f64d43ff0c18 926 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 927 */
mbed_official 146:f64d43ff0c18 928 static inline void ftm_hal_enable_channel_software_ctrl(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 929 {
mbed_official 146:f64d43ff0c18 930 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 931 val? HW_FTM_SWOCTRL_SET(instance, (1U<<channel)) : HW_FTM_SWOCTRL_CLR(instance, (1U<<channel));
mbed_official 146:f64d43ff0c18 932 }
mbed_official 146:f64d43ff0c18 933 /*!
mbed_official 146:f64d43ff0c18 934 * @brief Sets the channel software control value.
mbed_official 146:f64d43ff0c18 935 * @param instance The FTM peripheral instance number.
mbed_official 146:f64d43ff0c18 936 * @param channel Channel to be enabled, valid value 0, 1, 2, 3,5,6,7,
mbed_official 146:f64d43ff0c18 937 * @param bool True to set 1, false to set 0
mbed_official 146:f64d43ff0c18 938 */
mbed_official 146:f64d43ff0c18 939 static inline void ftm_hal_set_channel_software_ctrl_val(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 940 {
mbed_official 146:f64d43ff0c18 941 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 942 val? HW_FTM_SWOCTRL_SET(instance, (1U<<(channel+8))) : HW_FTM_SWOCTRL_CLR(instance, (1U<<(channel+8)));
mbed_official 146:f64d43ff0c18 943 }
mbed_official 146:f64d43ff0c18 944
mbed_official 146:f64d43ff0c18 945 /*FTM PWM load control*/
mbed_official 146:f64d43ff0c18 946 /*!
mbed_official 146:f64d43ff0c18 947 * @brief Enables the FTM timer PWM loading of MOD, CNTIN and CV.
mbed_official 146:f64d43ff0c18 948 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 949 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 950 */
mbed_official 146:f64d43ff0c18 951 static inline void ftm_hal_enable_pwm_load(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 952 {
mbed_official 146:f64d43ff0c18 953 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 954 HW_FTM_PWMLOAD(instance).B.LDOK = enable? 1:0;
mbed_official 146:f64d43ff0c18 955 }
mbed_official 146:f64d43ff0c18 956
mbed_official 146:f64d43ff0c18 957 /*!
mbed_official 146:f64d43ff0c18 958 * @brief Enables the channel matching process.
mbed_official 146:f64d43ff0c18 959 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 960 * @param channel Channel to be enabled, valid value 0, 1, 2, 3, 4,5,6,7
mbed_official 146:f64d43ff0c18 961 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 962 */
mbed_official 146:f64d43ff0c18 963 static inline void ftm_hal_enable_pwm_load_matching_channel(uint8_t instance, uint8_t channel, bool val)
mbed_official 146:f64d43ff0c18 964 {
mbed_official 146:f64d43ff0c18 965 assert(instance < HW_FTM_INSTANCE_COUNT && channel < HW_FTM_CHANNEL_COUNT);
mbed_official 146:f64d43ff0c18 966 val? HW_FTM_PWMLOAD_SET(instance, 1U<<channel) : HW_FTM_PWMLOAD_CLR(instance, 1U<<channel);
mbed_official 146:f64d43ff0c18 967 }
mbed_official 146:f64d43ff0c18 968 /*FTM configuration*/
mbed_official 146:f64d43ff0c18 969 /*!
mbed_official 146:f64d43ff0c18 970 * @brief Enables the FTM timer global time base output.
mbed_official 146:f64d43ff0c18 971 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 972 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 973 */
mbed_official 146:f64d43ff0c18 974 static inline void ftm_hal_enable_global_time_base_output(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 975 {
mbed_official 146:f64d43ff0c18 976 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 977 BW_FTM_CONF_GTBEOUT(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 978 }
mbed_official 146:f64d43ff0c18 979
mbed_official 146:f64d43ff0c18 980 /*!
mbed_official 146:f64d43ff0c18 981 * @brief Enables the FTM timer global time base.
mbed_official 146:f64d43ff0c18 982 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 983 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 984 */
mbed_official 146:f64d43ff0c18 985 static inline void ftm_hal_enable_global_time_base(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 986 {
mbed_official 146:f64d43ff0c18 987 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 988 BW_FTM_CONF_GTBEEN(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 989 }
mbed_official 146:f64d43ff0c18 990
mbed_official 146:f64d43ff0c18 991 /*!
mbed_official 146:f64d43ff0c18 992 * @brief Sets the FTM timer TOF Frequency.
mbed_official 146:f64d43ff0c18 993 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 994 * @param val Value of the TOF bit set frequency
mbed_official 146:f64d43ff0c18 995 */
mbed_official 146:f64d43ff0c18 996 static inline void ftm_hal_set_bdm_mode(uint8_t instance, uint8_t val)
mbed_official 146:f64d43ff0c18 997 {
mbed_official 146:f64d43ff0c18 998 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 999 BW_FTM_CONF_NUMTOF(instance, val);
mbed_official 146:f64d43ff0c18 1000 }
mbed_official 146:f64d43ff0c18 1001
mbed_official 146:f64d43ff0c18 1002 /*!
mbed_official 146:f64d43ff0c18 1003 * @brief Sets the BDM mode.
mbed_official 146:f64d43ff0c18 1004 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1005 * @param val Value of the TOF bit set frequency
mbed_official 146:f64d43ff0c18 1006 */
mbed_official 146:f64d43ff0c18 1007 static inline void ftm_hal_set_tof_frequency(uint8_t instance, uint8_t val)
mbed_official 146:f64d43ff0c18 1008 {
mbed_official 146:f64d43ff0c18 1009 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1010 BW_FTM_CONF_BDMMODE(instance, val);
mbed_official 146:f64d43ff0c18 1011 }
mbed_official 146:f64d43ff0c18 1012
mbed_official 146:f64d43ff0c18 1013 /*FTM sync configuration*/
mbed_official 146:f64d43ff0c18 1014 /*hardware sync*/
mbed_official 146:f64d43ff0c18 1015 /*!
mbed_official 146:f64d43ff0c18 1016 * @brief Enables the FTM timer hardware sync activation.
mbed_official 146:f64d43ff0c18 1017 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1018 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1019 */
mbed_official 146:f64d43ff0c18 1020 static inline void ftm_hal_enable_hardware_sync_software_output_ctrl(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1021 {
mbed_official 146:f64d43ff0c18 1022 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1023 BW_FTM_SYNCONF_HWSOC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1024 }
mbed_official 146:f64d43ff0c18 1025
mbed_official 146:f64d43ff0c18 1026 /*!
mbed_official 146:f64d43ff0c18 1027 * @brief Enables the FTM timer hardware inverting control sync.
mbed_official 146:f64d43ff0c18 1028 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1029 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1030 */
mbed_official 146:f64d43ff0c18 1031 static inline void ftm_hal_enable_hardware_sync_invert_ctrl(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1032 {
mbed_official 146:f64d43ff0c18 1033 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1034 BW_FTM_SYNCONF_HWINVC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1035 }
mbed_official 146:f64d43ff0c18 1036
mbed_official 146:f64d43ff0c18 1037 /*!
mbed_official 146:f64d43ff0c18 1038 * @brief Enables the FTM timer hardware outmask sync.
mbed_official 146:f64d43ff0c18 1039 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1040 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1041 */
mbed_official 146:f64d43ff0c18 1042 static inline void ftm_hal_enable_hardware_sync_output_mask(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1043 {
mbed_official 146:f64d43ff0c18 1044 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1045 BW_FTM_SYNCONF_HWOM(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1046 }
mbed_official 146:f64d43ff0c18 1047
mbed_official 146:f64d43ff0c18 1048 /*!
mbed_official 146:f64d43ff0c18 1049 * @brief MOD, CNTIN, and CV registers synchronization is activated.
mbed_official 146:f64d43ff0c18 1050 *
mbed_official 146:f64d43ff0c18 1051 * A hardware trigger activates the synchronization.
mbed_official 146:f64d43ff0c18 1052 *
mbed_official 146:f64d43ff0c18 1053 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1054 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1055 */
mbed_official 146:f64d43ff0c18 1056 static inline void ftm_hal_enable_hardware_sycn_mod_cntin_cv(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1057 {
mbed_official 146:f64d43ff0c18 1058 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1059 BW_FTM_SYNCONF_HWWRBUF(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1060 }
mbed_official 146:f64d43ff0c18 1061
mbed_official 146:f64d43ff0c18 1062 /*!
mbed_official 146:f64d43ff0c18 1063 * @brief The FTM counter synchronization is activated by a hardware trigger.
mbed_official 146:f64d43ff0c18 1064 *
mbed_official 146:f64d43ff0c18 1065 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1066 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1067 */
mbed_official 146:f64d43ff0c18 1068 static inline void ftm_hal_enable_hardware_sync_counter(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1069 {
mbed_official 146:f64d43ff0c18 1070 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1071 BW_FTM_SYNCONF_HWRSTCNT(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1072 }
mbed_official 146:f64d43ff0c18 1073
mbed_official 146:f64d43ff0c18 1074 /*!
mbed_official 146:f64d43ff0c18 1075 * @brief Enables the FTM timer software sync activation.
mbed_official 146:f64d43ff0c18 1076 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1077 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1078 */
mbed_official 146:f64d43ff0c18 1079 static inline void ftm_hal_enable_pwm_sync_swoctrl(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1080 {
mbed_official 146:f64d43ff0c18 1081 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1082 BW_FTM_SYNCONF_SWOC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1083 }
mbed_official 146:f64d43ff0c18 1084
mbed_official 146:f64d43ff0c18 1085 /*!
mbed_official 146:f64d43ff0c18 1086 * @brief Enables the FTM timer enhanced PWM sync mode.
mbed_official 146:f64d43ff0c18 1087 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1088 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1089 */
mbed_official 146:f64d43ff0c18 1090 static inline void ftm_hal_enable_enhanced_pwm_sync_mdoe(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1091 {
mbed_official 146:f64d43ff0c18 1092 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1093 BW_FTM_SYNCONF_SYNCMODE(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1094 }
mbed_official 146:f64d43ff0c18 1095
mbed_official 146:f64d43ff0c18 1096
mbed_official 146:f64d43ff0c18 1097 /*!
mbed_official 146:f64d43ff0c18 1098 * @brief Enables the FTM timer software output control sync.
mbed_official 146:f64d43ff0c18 1099 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1100 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1101 */
mbed_official 146:f64d43ff0c18 1102 static inline void ftm_hal_enable_software_sync_swoctrl(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1103 {
mbed_official 146:f64d43ff0c18 1104 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1105 BW_FTM_SYNCONF_SWSOC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1106 }
mbed_official 146:f64d43ff0c18 1107
mbed_official 146:f64d43ff0c18 1108 /*!
mbed_official 146:f64d43ff0c18 1109 * @brief Enables the FTM timer software inverting control sync.
mbed_official 146:f64d43ff0c18 1110 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1111 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1112 */
mbed_official 146:f64d43ff0c18 1113 static inline void ftm_hal_enable_software_sync_invert_ctrl(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1114 {
mbed_official 146:f64d43ff0c18 1115 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1116 BW_FTM_SYNCONF_SWINVC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1117 }
mbed_official 146:f64d43ff0c18 1118
mbed_official 146:f64d43ff0c18 1119 /*!
mbed_official 146:f64d43ff0c18 1120 * @brief Enables the FTM timer software outmask sync.
mbed_official 146:f64d43ff0c18 1121 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1122 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1123 */
mbed_official 146:f64d43ff0c18 1124 static inline void ftm_hal_enable_software_sync_output_mask(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1125 {
mbed_official 146:f64d43ff0c18 1126 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1127 BW_FTM_SYNCONF_SWOM(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1128 }
mbed_official 146:f64d43ff0c18 1129
mbed_official 146:f64d43ff0c18 1130 /*!
mbed_official 146:f64d43ff0c18 1131 * @brief Enables the FTM timer software outmask sync.
mbed_official 146:f64d43ff0c18 1132 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1133 * @param enable True to enable, false to disable.
mbed_official 146:f64d43ff0c18 1134 */
mbed_official 146:f64d43ff0c18 1135 static inline void ftm_hal_enable_software_sycn_mod_cntin_cv(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1136 {
mbed_official 146:f64d43ff0c18 1137 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1138 BW_FTM_SYNCONF_SWWRBUF(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1139 }
mbed_official 146:f64d43ff0c18 1140
mbed_official 146:f64d43ff0c18 1141 /*!
mbed_official 146:f64d43ff0c18 1142 * @brief Enables the FTM timer counter software sync.
mbed_official 146:f64d43ff0c18 1143 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1144 * @param enable True to enable, false to disable
mbed_official 146:f64d43ff0c18 1145 */
mbed_official 146:f64d43ff0c18 1146 static inline void ftm_hal_enable_software_sync_counter(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1147 {
mbed_official 146:f64d43ff0c18 1148 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1149 BW_FTM_SYNCONF_SWRSTCNT(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1150 }
mbed_official 146:f64d43ff0c18 1151
mbed_official 146:f64d43ff0c18 1152 /*!
mbed_official 146:f64d43ff0c18 1153 * @brief Enables the FTM timer INVCTRL update by PWM.
mbed_official 146:f64d43ff0c18 1154 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1155 * @param enable True to update with PWM, false to update with rising edge of system clock.
mbed_official 146:f64d43ff0c18 1156 */
mbed_official 146:f64d43ff0c18 1157 static inline void ftm_hal_enable_invert_sync_with_rising_edge(uint8_t instance, bool enable)
mbed_official 146:f64d43ff0c18 1158 {
mbed_official 146:f64d43ff0c18 1159 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1160 BW_FTM_SYNCONF_INVC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1161 }
mbed_official 146:f64d43ff0c18 1162
mbed_official 146:f64d43ff0c18 1163 /*!
mbed_official 146:f64d43ff0c18 1164 * @brief Enables the FTM timer cntin update by PWM.
mbed_official 146:f64d43ff0c18 1165 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1166 * @param enable True to update with PWM, false to update with rising edge of system clock.
mbed_official 146:f64d43ff0c18 1167 */
mbed_official 146:f64d43ff0c18 1168 static inline void ftm_hal_enable_cntin_sync_with_rising_edge(uint8_t instance, bool enable )
mbed_official 146:f64d43ff0c18 1169 {
mbed_official 146:f64d43ff0c18 1170 assert(instance < HW_FTM_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1171 BW_FTM_SYNCONF_CNTINC(instance, enable? 1:0);
mbed_official 146:f64d43ff0c18 1172 }
mbed_official 146:f64d43ff0c18 1173
mbed_official 146:f64d43ff0c18 1174
mbed_official 146:f64d43ff0c18 1175 /*HAL functionality*/
mbed_official 146:f64d43ff0c18 1176 /*!
mbed_official 146:f64d43ff0c18 1177 * @brief Resets the FTM registers
mbed_official 146:f64d43ff0c18 1178 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1179 */
mbed_official 146:f64d43ff0c18 1180 void ftm_hal_reset(uint8_t instance);
mbed_official 146:f64d43ff0c18 1181
mbed_official 146:f64d43ff0c18 1182 /*!
mbed_official 146:f64d43ff0c18 1183 * @brief Initializes the FTM.
mbed_official 146:f64d43ff0c18 1184 * @param instance The FTM peripheral instance number.
mbed_official 146:f64d43ff0c18 1185 */
mbed_official 146:f64d43ff0c18 1186 void ftm_hal_init(uint8_t instance, ftm_config_t *config);
mbed_official 146:f64d43ff0c18 1187 /*Initializes the 5 FTM operating mode, input capture, output compare, PWM output(edge aligned, center-aligned, conbine), dual and quadrature).*/
mbed_official 146:f64d43ff0c18 1188
mbed_official 146:f64d43ff0c18 1189 /*void ftm_hal_input_capture_mode(uint8_t instance);*/
mbed_official 146:f64d43ff0c18 1190 /*void ftm_hal_output_compare_mode(uint8_t instance);*/
mbed_official 146:f64d43ff0c18 1191
mbed_official 146:f64d43ff0c18 1192 /*!
mbed_official 146:f64d43ff0c18 1193 * @brief Enables the FTM timer when it is PWM output mode.
mbed_official 146:f64d43ff0c18 1194 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1195 * @param config pwm config parameter
mbed_official 146:f64d43ff0c18 1196 */
mbed_official 146:f64d43ff0c18 1197 void ftm_hal_enable_pwm_mode(uint8_t instance, ftm_config_t *config);
mbed_official 146:f64d43ff0c18 1198
mbed_official 146:f64d43ff0c18 1199 /*!
mbed_official 146:f64d43ff0c18 1200 * @brief Initializes the FTM timer when it is PWM output mode.
mbed_official 146:f64d43ff0c18 1201 * @param instance The FTM peripheral instance number
mbed_official 146:f64d43ff0c18 1202 */
mbed_official 146:f64d43ff0c18 1203 void ftm_hal_disable_pwm_mode(uint8_t instance, ftm_config_t *config);
mbed_official 146:f64d43ff0c18 1204 /*void ftm_hal_dual_mode(uint8_t instance);*/
mbed_official 146:f64d43ff0c18 1205 /*void ftm_hal_quad_mode(uint8_t instance);*/
mbed_official 146:f64d43ff0c18 1206
mbed_official 146:f64d43ff0c18 1207
mbed_official 146:f64d43ff0c18 1208 /*void ftm_hal_set_counting_mode(); //up, up down or free running counting mode*/
mbed_official 146:f64d43ff0c18 1209 /*void ftm_hal_set_deadtime(uint8_t instance, uint_32 us);*/
mbed_official 146:f64d43ff0c18 1210
mbed_official 146:f64d43ff0c18 1211 /*! @}*/
mbed_official 146:f64d43ff0c18 1212
mbed_official 146:f64d43ff0c18 1213 #endif /* __FSL_FTM_HAL_H__*/
mbed_official 146:f64d43ff0c18 1214 /*******************************************************************************
mbed_official 146:f64d43ff0c18 1215 * EOF
mbed_official 146:f64d43ff0c18 1216 ******************************************************************************/