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.
TARGET_K64F/TOOLCHAIN_IAR/fsl_cmt.h@172:65be27845400, 2019-02-20 (annotated)
- 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?
User | Revision | Line number | New 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_CMT_H_ |
AnnaBridge | 145:64910690c574 | 31 | #define _FSL_CMT_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 cmt |
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 | /*! @brief CMT driver version 2.0.1. */ |
AnnaBridge | 145:64910690c574 | 48 | #define FSL_CMT_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
AnnaBridge | 145:64910690c574 | 49 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 50 | |
AnnaBridge | 145:64910690c574 | 51 | /*! |
AnnaBridge | 145:64910690c574 | 52 | * @brief The modes of CMT. |
AnnaBridge | 145:64910690c574 | 53 | */ |
AnnaBridge | 145:64910690c574 | 54 | typedef enum _cmt_mode |
AnnaBridge | 145:64910690c574 | 55 | { |
AnnaBridge | 145:64910690c574 | 56 | kCMT_DirectIROCtl = 0x00U, /*!< Carrier modulator is disabled and the IRO signal is directly in software control */ |
AnnaBridge | 145:64910690c574 | 57 | kCMT_TimeMode = 0x01U, /*!< Carrier modulator is enabled in time mode. */ |
AnnaBridge | 145:64910690c574 | 58 | kCMT_FSKMode = 0x05U, /*!< Carrier modulator is enabled in FSK mode. */ |
AnnaBridge | 145:64910690c574 | 59 | kCMT_BasebandMode = 0x09U /*!< Carrier modulator is enabled in baseband mode. */ |
AnnaBridge | 145:64910690c574 | 60 | } cmt_mode_t; |
AnnaBridge | 145:64910690c574 | 61 | |
AnnaBridge | 145:64910690c574 | 62 | /*! |
AnnaBridge | 145:64910690c574 | 63 | * @brief The CMT clock divide primary prescaler. |
AnnaBridge | 145:64910690c574 | 64 | * The primary clock divider is used to divider the bus clock to |
AnnaBridge | 145:64910690c574 | 65 | * get the intermediate frequency to approximately equal to 8 MHZ. |
AnnaBridge | 145:64910690c574 | 66 | * When the bus clock is 8 MHZ, set primary prescaler to "kCMT_PrimaryClkDiv1". |
AnnaBridge | 145:64910690c574 | 67 | */ |
AnnaBridge | 145:64910690c574 | 68 | typedef enum _cmt_primary_clkdiv |
AnnaBridge | 145:64910690c574 | 69 | { |
AnnaBridge | 145:64910690c574 | 70 | kCMT_PrimaryClkDiv1 = 0U, /*!< The intermediate frequency is the bus clock divided by 1. */ |
AnnaBridge | 145:64910690c574 | 71 | kCMT_PrimaryClkDiv2 = 1U, /*!< The intermediate frequency is the bus clock divided by 2. */ |
AnnaBridge | 145:64910690c574 | 72 | kCMT_PrimaryClkDiv3 = 2U, /*!< The intermediate frequency is the bus clock divided by 3. */ |
AnnaBridge | 145:64910690c574 | 73 | kCMT_PrimaryClkDiv4 = 3U, /*!< The intermediate frequency is the bus clock divided by 4. */ |
AnnaBridge | 145:64910690c574 | 74 | kCMT_PrimaryClkDiv5 = 4U, /*!< The intermediate frequency is the bus clock divided by 5. */ |
AnnaBridge | 145:64910690c574 | 75 | kCMT_PrimaryClkDiv6 = 5U, /*!< The intermediate frequency is the bus clock divided by 6. */ |
AnnaBridge | 145:64910690c574 | 76 | kCMT_PrimaryClkDiv7 = 6U, /*!< The intermediate frequency is the bus clock divided by 7. */ |
AnnaBridge | 145:64910690c574 | 77 | kCMT_PrimaryClkDiv8 = 7U, /*!< The intermediate frequency is the bus clock divided by 8. */ |
AnnaBridge | 145:64910690c574 | 78 | kCMT_PrimaryClkDiv9 = 8U, /*!< The intermediate frequency is the bus clock divided by 9. */ |
AnnaBridge | 145:64910690c574 | 79 | kCMT_PrimaryClkDiv10 = 9U, /*!< The intermediate frequency is the bus clock divided by 10. */ |
AnnaBridge | 145:64910690c574 | 80 | kCMT_PrimaryClkDiv11 = 10U, /*!< The intermediate frequency is the bus clock divided by 11. */ |
AnnaBridge | 145:64910690c574 | 81 | kCMT_PrimaryClkDiv12 = 11U, /*!< The intermediate frequency is the bus clock divided by 12. */ |
AnnaBridge | 145:64910690c574 | 82 | kCMT_PrimaryClkDiv13 = 12U, /*!< The intermediate frequency is the bus clock divided by 13. */ |
AnnaBridge | 145:64910690c574 | 83 | kCMT_PrimaryClkDiv14 = 13U, /*!< The intermediate frequency is the bus clock divided by 14. */ |
AnnaBridge | 145:64910690c574 | 84 | kCMT_PrimaryClkDiv15 = 14U, /*!< The intermediate frequency is the bus clock divided by 15. */ |
AnnaBridge | 145:64910690c574 | 85 | kCMT_PrimaryClkDiv16 = 15U /*!< The intermediate frequency is the bus clock divided by 16. */ |
AnnaBridge | 145:64910690c574 | 86 | } cmt_primary_clkdiv_t; |
AnnaBridge | 145:64910690c574 | 87 | |
AnnaBridge | 145:64910690c574 | 88 | /*! |
AnnaBridge | 145:64910690c574 | 89 | * @brief The CMT clock divide secondary prescaler. |
AnnaBridge | 145:64910690c574 | 90 | * The second prescaler can be used to divide the 8 MHZ CMT clock |
AnnaBridge | 145:64910690c574 | 91 | * by 1, 2, 4, or 8 according to the specification. |
AnnaBridge | 145:64910690c574 | 92 | */ |
AnnaBridge | 145:64910690c574 | 93 | typedef enum _cmt_second_clkdiv |
AnnaBridge | 145:64910690c574 | 94 | { |
AnnaBridge | 145:64910690c574 | 95 | kCMT_SecondClkDiv1 = 0U, /*!< The CMT clock is the intermediate frequency frequency divided by 1. */ |
AnnaBridge | 145:64910690c574 | 96 | kCMT_SecondClkDiv2 = 1U, /*!< The CMT clock is the intermediate frequency frequency divided by 2. */ |
AnnaBridge | 145:64910690c574 | 97 | kCMT_SecondClkDiv4 = 2U, /*!< The CMT clock is the intermediate frequency frequency divided by 4. */ |
AnnaBridge | 145:64910690c574 | 98 | kCMT_SecondClkDiv8 = 3U /*!< The CMT clock is the intermediate frequency frequency divided by 8. */ |
AnnaBridge | 145:64910690c574 | 99 | } cmt_second_clkdiv_t; |
AnnaBridge | 145:64910690c574 | 100 | |
AnnaBridge | 145:64910690c574 | 101 | /*! |
AnnaBridge | 145:64910690c574 | 102 | * @brief The CMT infrared output polarity. |
AnnaBridge | 145:64910690c574 | 103 | */ |
AnnaBridge | 145:64910690c574 | 104 | typedef enum _cmt_infrared_output_polarity |
AnnaBridge | 145:64910690c574 | 105 | { |
AnnaBridge | 145:64910690c574 | 106 | kCMT_IROActiveLow = 0U, /*!< The CMT infrared output signal polarity is active-low. */ |
AnnaBridge | 145:64910690c574 | 107 | kCMT_IROActiveHigh = 1U /*!< The CMT infrared output signal polarity is active-high. */ |
AnnaBridge | 145:64910690c574 | 108 | } cmt_infrared_output_polarity_t; |
AnnaBridge | 145:64910690c574 | 109 | |
AnnaBridge | 145:64910690c574 | 110 | /*! |
AnnaBridge | 145:64910690c574 | 111 | * @brief The CMT infrared output signal state control. |
AnnaBridge | 145:64910690c574 | 112 | */ |
AnnaBridge | 145:64910690c574 | 113 | typedef enum _cmt_infrared_output_state |
AnnaBridge | 145:64910690c574 | 114 | { |
AnnaBridge | 145:64910690c574 | 115 | kCMT_IROCtlLow = 0U, /*!< The CMT Infrared output signal state is controlled to low. */ |
AnnaBridge | 145:64910690c574 | 116 | kCMT_IROCtlHigh = 1U /*!< The CMT Infrared output signal state is controlled to high. */ |
AnnaBridge | 145:64910690c574 | 117 | } cmt_infrared_output_state_t; |
AnnaBridge | 145:64910690c574 | 118 | |
AnnaBridge | 145:64910690c574 | 119 | /*! |
AnnaBridge | 145:64910690c574 | 120 | * @brief CMT interrupt configuration structure, default settings all disabled. |
AnnaBridge | 145:64910690c574 | 121 | * |
AnnaBridge | 145:64910690c574 | 122 | * This structure contains the settings for all of the CMT interrupt configurations. |
AnnaBridge | 145:64910690c574 | 123 | */ |
AnnaBridge | 145:64910690c574 | 124 | enum _cmt_interrupt_enable |
AnnaBridge | 145:64910690c574 | 125 | { |
AnnaBridge | 145:64910690c574 | 126 | kCMT_EndOfCycleInterruptEnable = CMT_MSC_EOCIE_MASK, /*!< CMT end of cycle interrupt. */ |
AnnaBridge | 145:64910690c574 | 127 | }; |
AnnaBridge | 145:64910690c574 | 128 | |
AnnaBridge | 145:64910690c574 | 129 | /*! |
AnnaBridge | 145:64910690c574 | 130 | * @brief CMT carrier generator and modulator configuration structure |
AnnaBridge | 145:64910690c574 | 131 | * |
AnnaBridge | 145:64910690c574 | 132 | */ |
AnnaBridge | 145:64910690c574 | 133 | typedef struct _cmt_modulate_config |
AnnaBridge | 145:64910690c574 | 134 | { |
AnnaBridge | 145:64910690c574 | 135 | uint8_t highCount1; /*!< The high-time for carrier generator first register. */ |
AnnaBridge | 145:64910690c574 | 136 | uint8_t lowCount1; /*!< The low-time for carrier generator first register. */ |
AnnaBridge | 145:64910690c574 | 137 | uint8_t highCount2; /*!< The high-time for carrier generator second register for FSK mode. */ |
AnnaBridge | 145:64910690c574 | 138 | uint8_t lowCount2; /*!< The low-time for carrier generator second register for FSK mode. */ |
AnnaBridge | 145:64910690c574 | 139 | uint16_t markCount; /*!< The mark time for the modulator gate. */ |
AnnaBridge | 145:64910690c574 | 140 | uint16_t spaceCount; /*!< The space time for the modulator gate. */ |
AnnaBridge | 145:64910690c574 | 141 | } cmt_modulate_config_t; |
AnnaBridge | 145:64910690c574 | 142 | |
AnnaBridge | 145:64910690c574 | 143 | /*! @brief CMT basic configuration structure. */ |
AnnaBridge | 145:64910690c574 | 144 | typedef struct _cmt_config |
AnnaBridge | 145:64910690c574 | 145 | { |
AnnaBridge | 145:64910690c574 | 146 | bool isInterruptEnabled; /*!< Timer interrupt 0-disable, 1-enable. */ |
AnnaBridge | 145:64910690c574 | 147 | bool isIroEnabled; /*!< The IRO output 0-disabled, 1-enabled. */ |
AnnaBridge | 145:64910690c574 | 148 | cmt_infrared_output_polarity_t iroPolarity; /*!< The IRO polarity. */ |
AnnaBridge | 145:64910690c574 | 149 | cmt_second_clkdiv_t divider; /*!< The CMT clock divide prescaler. */ |
AnnaBridge | 145:64910690c574 | 150 | } cmt_config_t; |
AnnaBridge | 145:64910690c574 | 151 | |
AnnaBridge | 145:64910690c574 | 152 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 153 | * API |
AnnaBridge | 145:64910690c574 | 154 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 155 | |
AnnaBridge | 145:64910690c574 | 156 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 157 | extern "C" { |
AnnaBridge | 145:64910690c574 | 158 | #endif |
AnnaBridge | 145:64910690c574 | 159 | |
AnnaBridge | 145:64910690c574 | 160 | /*! |
AnnaBridge | 145:64910690c574 | 161 | * @name Initialization and deinitialization |
AnnaBridge | 145:64910690c574 | 162 | * @{ |
AnnaBridge | 145:64910690c574 | 163 | */ |
AnnaBridge | 145:64910690c574 | 164 | |
AnnaBridge | 145:64910690c574 | 165 | /*! |
AnnaBridge | 145:64910690c574 | 166 | * @brief Gets the CMT default configuration structure. This API |
AnnaBridge | 145:64910690c574 | 167 | * gets the default configuration structure for the CMT_Init(). |
AnnaBridge | 145:64910690c574 | 168 | * Use the initialized structure unchanged in CMT_Init() or modify |
AnnaBridge | 145:64910690c574 | 169 | * fields of the structure before calling the CMT_Init(). |
AnnaBridge | 145:64910690c574 | 170 | * |
AnnaBridge | 145:64910690c574 | 171 | * @param config The CMT configuration structure pointer. |
AnnaBridge | 145:64910690c574 | 172 | */ |
AnnaBridge | 145:64910690c574 | 173 | void CMT_GetDefaultConfig(cmt_config_t *config); |
AnnaBridge | 145:64910690c574 | 174 | |
AnnaBridge | 145:64910690c574 | 175 | /*! |
AnnaBridge | 145:64910690c574 | 176 | * @brief Initializes the CMT module. |
AnnaBridge | 145:64910690c574 | 177 | * |
AnnaBridge | 145:64910690c574 | 178 | * This function ungates the module clock and sets the CMT internal clock, |
AnnaBridge | 145:64910690c574 | 179 | * interrupt, and infrared output signal for the CMT module. |
AnnaBridge | 145:64910690c574 | 180 | * |
AnnaBridge | 145:64910690c574 | 181 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 182 | * @param config The CMT basic configuration structure. |
AnnaBridge | 145:64910690c574 | 183 | * @param busClock_Hz The CMT module input clock - bus clock frequency. |
AnnaBridge | 145:64910690c574 | 184 | */ |
AnnaBridge | 145:64910690c574 | 185 | void CMT_Init(CMT_Type *base, const cmt_config_t *config, uint32_t busClock_Hz); |
AnnaBridge | 145:64910690c574 | 186 | |
AnnaBridge | 145:64910690c574 | 187 | /*! |
AnnaBridge | 145:64910690c574 | 188 | * @brief Disables the CMT module and gate control. |
AnnaBridge | 145:64910690c574 | 189 | * |
AnnaBridge | 145:64910690c574 | 190 | * This function disables CMT modulator, interrupts, and gates the |
AnnaBridge | 145:64910690c574 | 191 | * CMT clock control. CMT_Init must be called to use the CMT again. |
AnnaBridge | 145:64910690c574 | 192 | * |
AnnaBridge | 145:64910690c574 | 193 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 194 | */ |
AnnaBridge | 145:64910690c574 | 195 | void CMT_Deinit(CMT_Type *base); |
AnnaBridge | 145:64910690c574 | 196 | |
AnnaBridge | 145:64910690c574 | 197 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 198 | |
AnnaBridge | 145:64910690c574 | 199 | /*! |
AnnaBridge | 145:64910690c574 | 200 | * @name Basic Control Operations |
AnnaBridge | 145:64910690c574 | 201 | * @{ |
AnnaBridge | 145:64910690c574 | 202 | */ |
AnnaBridge | 145:64910690c574 | 203 | |
AnnaBridge | 145:64910690c574 | 204 | /*! |
AnnaBridge | 145:64910690c574 | 205 | * @brief Selects the mode for CMT. |
AnnaBridge | 145:64910690c574 | 206 | * |
AnnaBridge | 145:64910690c574 | 207 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 208 | * @param mode The CMT feature mode enumeration. See "cmt_mode_t". |
AnnaBridge | 145:64910690c574 | 209 | * @param modulateConfig The carrier generation and modulator configuration. |
AnnaBridge | 145:64910690c574 | 210 | */ |
AnnaBridge | 145:64910690c574 | 211 | void CMT_SetMode(CMT_Type *base, cmt_mode_t mode, cmt_modulate_config_t *modulateConfig); |
AnnaBridge | 145:64910690c574 | 212 | |
AnnaBridge | 145:64910690c574 | 213 | /*! |
AnnaBridge | 145:64910690c574 | 214 | * @brief Gets the mode of the CMT module. |
AnnaBridge | 145:64910690c574 | 215 | * |
AnnaBridge | 145:64910690c574 | 216 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 217 | * @return The CMT mode. |
AnnaBridge | 145:64910690c574 | 218 | * kCMT_DirectIROCtl Carrier modulator is disabled; the IRO signal is directly in software control. |
AnnaBridge | 145:64910690c574 | 219 | * kCMT_TimeMode Carrier modulator is enabled in time mode. |
AnnaBridge | 145:64910690c574 | 220 | * kCMT_FSKMode Carrier modulator is enabled in FSK mode. |
AnnaBridge | 145:64910690c574 | 221 | * kCMT_BasebandMode Carrier modulator is enabled in baseband mode. |
AnnaBridge | 145:64910690c574 | 222 | */ |
AnnaBridge | 145:64910690c574 | 223 | cmt_mode_t CMT_GetMode(CMT_Type *base); |
AnnaBridge | 145:64910690c574 | 224 | |
AnnaBridge | 145:64910690c574 | 225 | /*! |
AnnaBridge | 145:64910690c574 | 226 | * @brief Gets the actual CMT clock frequency. |
AnnaBridge | 145:64910690c574 | 227 | * |
AnnaBridge | 145:64910690c574 | 228 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 229 | * @param busClock_Hz CMT module input clock - bus clock frequency. |
AnnaBridge | 145:64910690c574 | 230 | * @return The CMT clock frequency. |
AnnaBridge | 145:64910690c574 | 231 | */ |
AnnaBridge | 145:64910690c574 | 232 | uint32_t CMT_GetCMTFrequency(CMT_Type *base, uint32_t busClock_Hz); |
AnnaBridge | 145:64910690c574 | 233 | |
AnnaBridge | 145:64910690c574 | 234 | /*! |
AnnaBridge | 145:64910690c574 | 235 | * @brief Sets the primary data set for the CMT carrier generator counter. |
AnnaBridge | 145:64910690c574 | 236 | * |
AnnaBridge | 145:64910690c574 | 237 | * This function sets the high-time and low-time of the primary data set for the |
AnnaBridge | 145:64910690c574 | 238 | * CMT carrier generator counter to control the period and the duty cycle of the |
AnnaBridge | 145:64910690c574 | 239 | * output carrier signal. |
AnnaBridge | 145:64910690c574 | 240 | * If the CMT clock period is Tcmt, the period of the carrier generator signal equals |
AnnaBridge | 145:64910690c574 | 241 | * (highCount + lowCount) * Tcmt. The duty cycle equals to highCount / (highCount + lowCount). |
AnnaBridge | 145:64910690c574 | 242 | * |
AnnaBridge | 145:64910690c574 | 243 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 244 | * @param highCount The number of CMT clocks for carrier generator signal high time, |
AnnaBridge | 145:64910690c574 | 245 | * integer in the range of 1 ~ 0xFF. |
AnnaBridge | 145:64910690c574 | 246 | * @param lowCount The number of CMT clocks for carrier generator signal low time, |
AnnaBridge | 145:64910690c574 | 247 | * integer in the range of 1 ~ 0xFF. |
AnnaBridge | 145:64910690c574 | 248 | */ |
AnnaBridge | 145:64910690c574 | 249 | static inline void CMT_SetCarrirGenerateCountOne(CMT_Type *base, uint32_t highCount, uint32_t lowCount) |
AnnaBridge | 145:64910690c574 | 250 | { |
AnnaBridge | 145:64910690c574 | 251 | assert(highCount <= CMT_CGH1_PH_MASK); |
AnnaBridge | 145:64910690c574 | 252 | assert(highCount); |
AnnaBridge | 145:64910690c574 | 253 | assert(lowCount <= CMT_CGL1_PL_MASK); |
AnnaBridge | 145:64910690c574 | 254 | assert(lowCount); |
AnnaBridge | 145:64910690c574 | 255 | |
AnnaBridge | 145:64910690c574 | 256 | base->CGH1 = highCount; |
AnnaBridge | 145:64910690c574 | 257 | base->CGL1 = lowCount; |
AnnaBridge | 145:64910690c574 | 258 | } |
AnnaBridge | 145:64910690c574 | 259 | |
AnnaBridge | 145:64910690c574 | 260 | /*! |
AnnaBridge | 145:64910690c574 | 261 | * @brief Sets the secondary data set for the CMT carrier generator counter. |
AnnaBridge | 145:64910690c574 | 262 | * |
AnnaBridge | 145:64910690c574 | 263 | * This function is used for FSK mode setting the high-time and low-time of the secondary |
AnnaBridge | 145:64910690c574 | 264 | * data set CMT carrier generator counter to control the period and the duty cycle |
AnnaBridge | 145:64910690c574 | 265 | * of the output carrier signal. |
AnnaBridge | 145:64910690c574 | 266 | * If the CMT clock period is Tcmt, the period of the carrier generator signal equals |
AnnaBridge | 145:64910690c574 | 267 | * (highCount + lowCount) * Tcmt. The duty cycle equals highCount / (highCount + lowCount). |
AnnaBridge | 145:64910690c574 | 268 | * |
AnnaBridge | 145:64910690c574 | 269 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 270 | * @param highCount The number of CMT clocks for carrier generator signal high time, |
AnnaBridge | 145:64910690c574 | 271 | * integer in the range of 1 ~ 0xFF. |
AnnaBridge | 145:64910690c574 | 272 | * @param lowCount The number of CMT clocks for carrier generator signal low time, |
AnnaBridge | 145:64910690c574 | 273 | * integer in the range of 1 ~ 0xFF. |
AnnaBridge | 145:64910690c574 | 274 | */ |
AnnaBridge | 145:64910690c574 | 275 | static inline void CMT_SetCarrirGenerateCountTwo(CMT_Type *base, uint32_t highCount, uint32_t lowCount) |
AnnaBridge | 145:64910690c574 | 276 | { |
AnnaBridge | 145:64910690c574 | 277 | assert(highCount <= CMT_CGH2_SH_MASK); |
AnnaBridge | 145:64910690c574 | 278 | assert(highCount); |
AnnaBridge | 145:64910690c574 | 279 | assert(lowCount <= CMT_CGL2_SL_MASK); |
AnnaBridge | 145:64910690c574 | 280 | assert(lowCount); |
AnnaBridge | 145:64910690c574 | 281 | |
AnnaBridge | 145:64910690c574 | 282 | base->CGH2 = highCount; |
AnnaBridge | 145:64910690c574 | 283 | base->CGL2 = lowCount; |
AnnaBridge | 145:64910690c574 | 284 | } |
AnnaBridge | 145:64910690c574 | 285 | |
AnnaBridge | 145:64910690c574 | 286 | /*! |
AnnaBridge | 145:64910690c574 | 287 | * @brief Sets the modulation mark and space time period for the CMT modulator. |
AnnaBridge | 145:64910690c574 | 288 | * |
AnnaBridge | 145:64910690c574 | 289 | * This function sets the mark time period of the CMT modulator counter |
AnnaBridge | 145:64910690c574 | 290 | * to control the mark time of the output modulated signal from the carrier generator output signal. |
AnnaBridge | 145:64910690c574 | 291 | * If the CMT clock frequency is Fcmt and the carrier out signal frequency is fcg: |
AnnaBridge | 145:64910690c574 | 292 | * - In Time and Baseband mode: The mark period of the generated signal equals (markCount + 1) / (Fcmt/8). |
AnnaBridge | 145:64910690c574 | 293 | * The space period of the generated signal equals spaceCount / (Fcmt/8). |
AnnaBridge | 145:64910690c574 | 294 | * - In FSK mode: The mark period of the generated signal equals (markCount + 1)/fcg. |
AnnaBridge | 145:64910690c574 | 295 | * The space period of the generated signal equals spaceCount / fcg. |
AnnaBridge | 145:64910690c574 | 296 | * |
AnnaBridge | 145:64910690c574 | 297 | * @param base Base address for current CMT instance. |
AnnaBridge | 145:64910690c574 | 298 | * @param markCount The number of clock period for CMT modulator signal mark period, |
AnnaBridge | 145:64910690c574 | 299 | * in the range of 0 ~ 0xFFFF. |
AnnaBridge | 145:64910690c574 | 300 | * @param spaceCount The number of clock period for CMT modulator signal space period, |
AnnaBridge | 145:64910690c574 | 301 | * in the range of the 0 ~ 0xFFFF. |
AnnaBridge | 145:64910690c574 | 302 | */ |
AnnaBridge | 145:64910690c574 | 303 | void CMT_SetModulateMarkSpace(CMT_Type *base, uint32_t markCount, uint32_t spaceCount); |
AnnaBridge | 145:64910690c574 | 304 | |
AnnaBridge | 145:64910690c574 | 305 | /*! |
AnnaBridge | 145:64910690c574 | 306 | * @brief Enables or disables the extended space operation. |
AnnaBridge | 145:64910690c574 | 307 | * |
AnnaBridge | 145:64910690c574 | 308 | * This function is used to make the space period longer |
AnnaBridge | 145:64910690c574 | 309 | * for time, baseband, and FSK modes. |
AnnaBridge | 145:64910690c574 | 310 | * |
AnnaBridge | 145:64910690c574 | 311 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 312 | * @param enable True enable the extended space, false disable the extended space. |
AnnaBridge | 145:64910690c574 | 313 | */ |
AnnaBridge | 145:64910690c574 | 314 | static inline void CMT_EnableExtendedSpace(CMT_Type *base, bool enable) |
AnnaBridge | 145:64910690c574 | 315 | { |
AnnaBridge | 145:64910690c574 | 316 | if (enable) |
AnnaBridge | 145:64910690c574 | 317 | { |
AnnaBridge | 145:64910690c574 | 318 | base->MSC |= CMT_MSC_EXSPC_MASK; |
AnnaBridge | 145:64910690c574 | 319 | } |
AnnaBridge | 145:64910690c574 | 320 | else |
AnnaBridge | 145:64910690c574 | 321 | { |
AnnaBridge | 145:64910690c574 | 322 | base->MSC &= ~CMT_MSC_EXSPC_MASK; |
AnnaBridge | 145:64910690c574 | 323 | } |
AnnaBridge | 145:64910690c574 | 324 | } |
AnnaBridge | 145:64910690c574 | 325 | |
AnnaBridge | 145:64910690c574 | 326 | /*! |
AnnaBridge | 145:64910690c574 | 327 | * @brief Sets the IRO (infrared output) signal state. |
AnnaBridge | 145:64910690c574 | 328 | * |
AnnaBridge | 145:64910690c574 | 329 | * Changes the states of the IRO signal when the kCMT_DirectIROMode mode is set |
AnnaBridge | 145:64910690c574 | 330 | * and the IRO signal is enabled. |
AnnaBridge | 145:64910690c574 | 331 | * |
AnnaBridge | 145:64910690c574 | 332 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 333 | * @param state The control of the IRO signal. See "cmt_infrared_output_state_t" |
AnnaBridge | 145:64910690c574 | 334 | */ |
AnnaBridge | 145:64910690c574 | 335 | void CMT_SetIroState(CMT_Type *base, cmt_infrared_output_state_t state); |
AnnaBridge | 145:64910690c574 | 336 | |
AnnaBridge | 145:64910690c574 | 337 | /*! |
AnnaBridge | 145:64910690c574 | 338 | * @brief Enables the CMT interrupt. |
AnnaBridge | 145:64910690c574 | 339 | * |
AnnaBridge | 145:64910690c574 | 340 | * This function enables the CMT interrupts according to the provided mask if enabled. |
AnnaBridge | 145:64910690c574 | 341 | * The CMT only has the end of the cycle interrupt - an interrupt occurs at the end |
AnnaBridge | 145:64910690c574 | 342 | * of the modulator cycle. This interrupt provides a means for the user |
AnnaBridge | 145:64910690c574 | 343 | * to reload the new mark/space values into the CMT modulator data registers |
AnnaBridge | 145:64910690c574 | 344 | * and verify the modulator mark and space. |
AnnaBridge | 145:64910690c574 | 345 | * For example, to enable the end of cycle, do the following. |
AnnaBridge | 145:64910690c574 | 346 | * @code |
AnnaBridge | 145:64910690c574 | 347 | * CMT_EnableInterrupts(CMT, kCMT_EndOfCycleInterruptEnable); |
AnnaBridge | 145:64910690c574 | 348 | * @endcode |
AnnaBridge | 145:64910690c574 | 349 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 350 | * @param mask The interrupts to enable. Logical OR of @ref _cmt_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 351 | */ |
AnnaBridge | 145:64910690c574 | 352 | static inline void CMT_EnableInterrupts(CMT_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 353 | { |
AnnaBridge | 145:64910690c574 | 354 | base->MSC |= mask; |
AnnaBridge | 145:64910690c574 | 355 | } |
AnnaBridge | 145:64910690c574 | 356 | |
AnnaBridge | 145:64910690c574 | 357 | /*! |
AnnaBridge | 145:64910690c574 | 358 | * @brief Disables the CMT interrupt. |
AnnaBridge | 145:64910690c574 | 359 | * |
AnnaBridge | 145:64910690c574 | 360 | * This function disables the CMT interrupts according to the provided maskIf enabled. |
AnnaBridge | 145:64910690c574 | 361 | * The CMT only has the end of the cycle interrupt. |
AnnaBridge | 145:64910690c574 | 362 | * For example, to disable the end of cycle, do the following. |
AnnaBridge | 145:64910690c574 | 363 | * @code |
AnnaBridge | 145:64910690c574 | 364 | * CMT_DisableInterrupts(CMT, kCMT_EndOfCycleInterruptEnable); |
AnnaBridge | 145:64910690c574 | 365 | * @endcode |
AnnaBridge | 145:64910690c574 | 366 | * |
AnnaBridge | 145:64910690c574 | 367 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 368 | * @param mask The interrupts to enable. Logical OR of @ref _cmt_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 369 | */ |
AnnaBridge | 145:64910690c574 | 370 | static inline void CMT_DisableInterrupts(CMT_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 371 | { |
AnnaBridge | 145:64910690c574 | 372 | base->MSC &= ~mask; |
AnnaBridge | 145:64910690c574 | 373 | } |
AnnaBridge | 145:64910690c574 | 374 | |
AnnaBridge | 145:64910690c574 | 375 | /*! |
AnnaBridge | 145:64910690c574 | 376 | * @brief Gets the end of the cycle status flag. |
AnnaBridge | 145:64910690c574 | 377 | * |
AnnaBridge | 145:64910690c574 | 378 | * The flag is set: |
AnnaBridge | 145:64910690c574 | 379 | * - When the modulator is not currently active and carrier and modulator |
AnnaBridge | 145:64910690c574 | 380 | * are set to start the initial CMT transmission. |
AnnaBridge | 145:64910690c574 | 381 | * - At the end of each modulation cycle when the counter is reloaded and |
AnnaBridge | 145:64910690c574 | 382 | * the carrier and modulator are enabled. |
AnnaBridge | 145:64910690c574 | 383 | * @param base CMT peripheral base address. |
AnnaBridge | 145:64910690c574 | 384 | * @return Current status of the end of cycle status flag |
AnnaBridge | 145:64910690c574 | 385 | * @arg non-zero: End-of-cycle has occurred. |
AnnaBridge | 145:64910690c574 | 386 | * @arg zero: End-of-cycle has not yet occurred since the flag last cleared. |
AnnaBridge | 145:64910690c574 | 387 | */ |
AnnaBridge | 145:64910690c574 | 388 | static inline uint32_t CMT_GetStatusFlags(CMT_Type *base) |
AnnaBridge | 145:64910690c574 | 389 | { |
AnnaBridge | 145:64910690c574 | 390 | return base->MSC & CMT_MSC_EOCF_MASK; |
AnnaBridge | 145:64910690c574 | 391 | } |
AnnaBridge | 145:64910690c574 | 392 | |
AnnaBridge | 145:64910690c574 | 393 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 394 | |
AnnaBridge | 145:64910690c574 | 395 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 396 | } |
AnnaBridge | 145:64910690c574 | 397 | #endif |
AnnaBridge | 145:64910690c574 | 398 | |
AnnaBridge | 145:64910690c574 | 399 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 400 | |
AnnaBridge | 145:64910690c574 | 401 | #endif /* _FSL_CMT_H_*/ |