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_SDT32625B/TOOLCHAIN_IAR/pt.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_MAX32625PICO/TARGET_Maxim/TARGET_MAX32625/mxc/pt.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
169:a7c7b631e539 | 1 | /******************************************************************************* |
Anna Bridge |
169:a7c7b631e539 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
169:a7c7b631e539 | 3 | * |
Anna Bridge |
169:a7c7b631e539 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
169:a7c7b631e539 | 5 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
169:a7c7b631e539 | 6 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
169:a7c7b631e539 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
169:a7c7b631e539 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
169:a7c7b631e539 | 9 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
169:a7c7b631e539 | 10 | * |
Anna Bridge |
169:a7c7b631e539 | 11 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
169:a7c7b631e539 | 12 | * in all copies or substantial portions of the Software. |
Anna Bridge |
169:a7c7b631e539 | 13 | * |
Anna Bridge |
169:a7c7b631e539 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
169:a7c7b631e539 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
169:a7c7b631e539 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
169:a7c7b631e539 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
169:a7c7b631e539 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
169:a7c7b631e539 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
169:a7c7b631e539 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
169:a7c7b631e539 | 21 | * |
Anna Bridge |
169:a7c7b631e539 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 24 | * Products, Inc. Branding Policy. |
Anna Bridge |
169:a7c7b631e539 | 25 | * |
Anna Bridge |
169:a7c7b631e539 | 26 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
169:a7c7b631e539 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
169:a7c7b631e539 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
169:a7c7b631e539 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
169:a7c7b631e539 | 30 | * ownership rights. |
Anna Bridge |
169:a7c7b631e539 | 31 | * |
Anna Bridge |
169:a7c7b631e539 | 32 | * $Date: 2016-03-21 14:44:55 -0500 (Mon, 21 Mar 2016) $ |
Anna Bridge |
169:a7c7b631e539 | 33 | * $Revision: 22017 $ |
Anna Bridge |
169:a7c7b631e539 | 34 | * |
Anna Bridge |
169:a7c7b631e539 | 35 | ******************************************************************************/ |
Anna Bridge |
169:a7c7b631e539 | 36 | |
Anna Bridge |
169:a7c7b631e539 | 37 | /** |
Anna Bridge |
169:a7c7b631e539 | 38 | * @file pt.h |
Anna Bridge |
169:a7c7b631e539 | 39 | * @addtogroup pt Pulse Train |
Anna Bridge |
169:a7c7b631e539 | 40 | * @brief This is the high level API for the pulse train module |
Anna Bridge |
169:a7c7b631e539 | 41 | * @{ |
Anna Bridge |
169:a7c7b631e539 | 42 | * |
Anna Bridge |
169:a7c7b631e539 | 43 | */ |
Anna Bridge |
169:a7c7b631e539 | 44 | |
Anna Bridge |
169:a7c7b631e539 | 45 | #ifndef _PT_H |
Anna Bridge |
169:a7c7b631e539 | 46 | #define _PT_H |
Anna Bridge |
169:a7c7b631e539 | 47 | |
Anna Bridge |
169:a7c7b631e539 | 48 | #include "mxc_config.h" |
Anna Bridge |
169:a7c7b631e539 | 49 | #include "pt_regs.h" |
Anna Bridge |
169:a7c7b631e539 | 50 | #include "mxc_assert.h" |
Anna Bridge |
169:a7c7b631e539 | 51 | #include "mxc_sys.h" |
Anna Bridge |
169:a7c7b631e539 | 52 | |
Anna Bridge |
169:a7c7b631e539 | 53 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 54 | extern "C" { |
Anna Bridge |
169:a7c7b631e539 | 55 | #endif |
Anna Bridge |
169:a7c7b631e539 | 56 | |
Anna Bridge |
169:a7c7b631e539 | 57 | /// @struct pt_pt_cfg_t |
Anna Bridge |
169:a7c7b631e539 | 58 | /// Pulse train mode configuration structure. @note Do not use for square wave |
Anna Bridge |
169:a7c7b631e539 | 59 | typedef struct { |
Anna Bridge |
169:a7c7b631e539 | 60 | uint32_t bps; ///< pulse train bit rate |
Anna Bridge |
169:a7c7b631e539 | 61 | uint32_t pattern; ///< Output pattern to shift out, starts at LSB |
Anna Bridge |
169:a7c7b631e539 | 62 | uint8_t ptLength; ///< Number of bits in pulse train, 0 = 32bits, 1 = non valid , 2 = 2 bits, ... |
Anna Bridge |
169:a7c7b631e539 | 63 | uint16_t loop; ///< Number of times to repeat the train, 0 = continuous |
Anna Bridge |
169:a7c7b631e539 | 64 | uint16_t loopDelay; ///< Delay between loops specified in bits Example: loopDelay = 4, delays time = time it takes to shift out 4 bits |
Anna Bridge |
169:a7c7b631e539 | 65 | } pt_pt_cfg_t; |
Anna Bridge |
169:a7c7b631e539 | 66 | |
Anna Bridge |
169:a7c7b631e539 | 67 | /** |
Anna Bridge |
169:a7c7b631e539 | 68 | * @brief This function initializes pulse train modules to a known stopped state |
Anna Bridge |
169:a7c7b631e539 | 69 | * and sets the global PT clock scale |
Anna Bridge |
169:a7c7b631e539 | 70 | * @param clk_scale scale the system clock for the global PT clock |
Anna Bridge |
169:a7c7b631e539 | 71 | */ |
Anna Bridge |
169:a7c7b631e539 | 72 | void PT_Init(sys_pt_clk_scale clk_scale); |
Anna Bridge |
169:a7c7b631e539 | 73 | |
Anna Bridge |
169:a7c7b631e539 | 74 | /** |
Anna Bridge |
169:a7c7b631e539 | 75 | * @brief Configures the pulse train in the specified mode. |
Anna Bridge |
169:a7c7b631e539 | 76 | * @details The parameters in config structure must be set before calling this function. |
Anna Bridge |
169:a7c7b631e539 | 77 | * This function should be used for configuring pulse train mode only. |
Anna Bridge |
169:a7c7b631e539 | 78 | * @note The pulse train cannot be running when this function is called |
Anna Bridge |
169:a7c7b631e539 | 79 | * |
Anna Bridge |
169:a7c7b631e539 | 80 | * @param pt pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 81 | * @param cfg pointer to pulse train configuration |
Anna Bridge |
169:a7c7b631e539 | 82 | * @param sysCfg pointer to pulse train system GPIO configuration |
Anna Bridge |
169:a7c7b631e539 | 83 | * |
Anna Bridge |
169:a7c7b631e539 | 84 | * @returns E_NO_ERROR if everything is successful, error if unsuccessful. |
Anna Bridge |
169:a7c7b631e539 | 85 | */ |
Anna Bridge |
169:a7c7b631e539 | 86 | int PT_PTConfig(mxc_pt_regs_t *pt, pt_pt_cfg_t *cfg, const sys_cfg_pt_t *sysCfg); |
Anna Bridge |
169:a7c7b631e539 | 87 | |
Anna Bridge |
169:a7c7b631e539 | 88 | /** |
Anna Bridge |
169:a7c7b631e539 | 89 | * @brief Configures the pulse train in the square wave mode. |
Anna Bridge |
169:a7c7b631e539 | 90 | * @details This function should be used for configuring square wave mode only. |
Anna Bridge |
169:a7c7b631e539 | 91 | * @note The pulse train cannot be running when this function is called |
Anna Bridge |
169:a7c7b631e539 | 92 | * |
Anna Bridge |
169:a7c7b631e539 | 93 | * @param pt pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 94 | * @param freq square wave output frequency in Hz |
Anna Bridge |
169:a7c7b631e539 | 95 | * @param sysCfg pointer to pulse train system GPIO configuration |
Anna Bridge |
169:a7c7b631e539 | 96 | * |
Anna Bridge |
169:a7c7b631e539 | 97 | * @returns E_NO_ERROR if everything is successful, error if unsuccessful. |
Anna Bridge |
169:a7c7b631e539 | 98 | */ |
Anna Bridge |
169:a7c7b631e539 | 99 | int PT_SqrWaveConfig(mxc_pt_regs_t *pt, uint32_t freq, const sys_cfg_pt_t *sysCfg); |
Anna Bridge |
169:a7c7b631e539 | 100 | |
Anna Bridge |
169:a7c7b631e539 | 101 | /** |
Anna Bridge |
169:a7c7b631e539 | 102 | * @brief Starts the pulse train specified |
Anna Bridge |
169:a7c7b631e539 | 103 | * |
Anna Bridge |
169:a7c7b631e539 | 104 | * @param pt pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 105 | */ |
Anna Bridge |
169:a7c7b631e539 | 106 | __STATIC_INLINE void PT_Start(mxc_pt_regs_t *pt) |
Anna Bridge |
169:a7c7b631e539 | 107 | { |
Anna Bridge |
169:a7c7b631e539 | 108 | int ptIndex = MXC_PT_GET_IDX(pt); |
Anna Bridge |
169:a7c7b631e539 | 109 | |
Anna Bridge |
169:a7c7b631e539 | 110 | MXC_PTG->enable |= (1 << ptIndex); |
Anna Bridge |
169:a7c7b631e539 | 111 | |
Anna Bridge |
169:a7c7b631e539 | 112 | //wait for PT to start |
Anna Bridge |
169:a7c7b631e539 | 113 | while( (MXC_PTG->enable & (1 << ptIndex)) == 0 ); |
Anna Bridge |
169:a7c7b631e539 | 114 | } |
Anna Bridge |
169:a7c7b631e539 | 115 | |
Anna Bridge |
169:a7c7b631e539 | 116 | /** |
Anna Bridge |
169:a7c7b631e539 | 117 | * @brief Start multiple pulse train modules together. |
Anna Bridge |
169:a7c7b631e539 | 118 | * |
Anna Bridge |
169:a7c7b631e539 | 119 | * @param pts set the bits of pulse trains to start |
Anna Bridge |
169:a7c7b631e539 | 120 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 121 | */ |
Anna Bridge |
169:a7c7b631e539 | 122 | __STATIC_INLINE void PT_StartMulti(uint32_t pts) |
Anna Bridge |
169:a7c7b631e539 | 123 | { |
Anna Bridge |
169:a7c7b631e539 | 124 | MXC_PTG->enable |= pts; |
Anna Bridge |
169:a7c7b631e539 | 125 | |
Anna Bridge |
169:a7c7b631e539 | 126 | //wait for PTs to start |
Anna Bridge |
169:a7c7b631e539 | 127 | while( (MXC_PTG->enable & pts) != pts ); |
Anna Bridge |
169:a7c7b631e539 | 128 | } |
Anna Bridge |
169:a7c7b631e539 | 129 | |
Anna Bridge |
169:a7c7b631e539 | 130 | /** |
Anna Bridge |
169:a7c7b631e539 | 131 | * @brief Stops a pulse train |
Anna Bridge |
169:a7c7b631e539 | 132 | * |
Anna Bridge |
169:a7c7b631e539 | 133 | * @param pt pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 134 | */ |
Anna Bridge |
169:a7c7b631e539 | 135 | __STATIC_INLINE void PT_Stop(mxc_pt_regs_t *pt) |
Anna Bridge |
169:a7c7b631e539 | 136 | { |
Anna Bridge |
169:a7c7b631e539 | 137 | int ptIndex = MXC_PT_GET_IDX(pt); |
Anna Bridge |
169:a7c7b631e539 | 138 | |
Anna Bridge |
169:a7c7b631e539 | 139 | MXC_PTG->enable &= ~(1 << ptIndex); |
Anna Bridge |
169:a7c7b631e539 | 140 | } |
Anna Bridge |
169:a7c7b631e539 | 141 | |
Anna Bridge |
169:a7c7b631e539 | 142 | /** |
Anna Bridge |
169:a7c7b631e539 | 143 | * @brief Stop multiple pulse trains together |
Anna Bridge |
169:a7c7b631e539 | 144 | * |
Anna Bridge |
169:a7c7b631e539 | 145 | * @param pts set the bits of pulse trains to stop |
Anna Bridge |
169:a7c7b631e539 | 146 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 147 | */ |
Anna Bridge |
169:a7c7b631e539 | 148 | __STATIC_INLINE void PT_StopMulti(uint32_t pts) |
Anna Bridge |
169:a7c7b631e539 | 149 | { |
Anna Bridge |
169:a7c7b631e539 | 150 | MXC_PTG->enable &= ~(pts); |
Anna Bridge |
169:a7c7b631e539 | 151 | } |
Anna Bridge |
169:a7c7b631e539 | 152 | |
Anna Bridge |
169:a7c7b631e539 | 153 | /** |
Anna Bridge |
169:a7c7b631e539 | 154 | * @brief Determines if the pulse train is running |
Anna Bridge |
169:a7c7b631e539 | 155 | * |
Anna Bridge |
169:a7c7b631e539 | 156 | * @param pt pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 157 | * |
Anna Bridge |
169:a7c7b631e539 | 158 | * @return 0 = pulse train is off, non-zero = pulse train is on |
Anna Bridge |
169:a7c7b631e539 | 159 | */ |
Anna Bridge |
169:a7c7b631e539 | 160 | __STATIC_INLINE uint32_t PT_IsActive(mxc_pt_regs_t *pt) |
Anna Bridge |
169:a7c7b631e539 | 161 | { |
Anna Bridge |
169:a7c7b631e539 | 162 | int ptIndex = MXC_PT_GET_IDX(pt); |
Anna Bridge |
169:a7c7b631e539 | 163 | |
Anna Bridge |
169:a7c7b631e539 | 164 | return (!!(MXC_PTG->enable & (1 << ptIndex))); |
Anna Bridge |
169:a7c7b631e539 | 165 | } |
Anna Bridge |
169:a7c7b631e539 | 166 | |
Anna Bridge |
169:a7c7b631e539 | 167 | /** |
Anna Bridge |
169:a7c7b631e539 | 168 | * @brief Determines if the pulse trains selected are running |
Anna Bridge |
169:a7c7b631e539 | 169 | * |
Anna Bridge |
169:a7c7b631e539 | 170 | * @param pts set the bits of pulse trains to check |
Anna Bridge |
169:a7c7b631e539 | 171 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 172 | * |
Anna Bridge |
169:a7c7b631e539 | 173 | * @return 0 = all pulse trains are off, non-zero = at least one pulse train is on |
Anna Bridge |
169:a7c7b631e539 | 174 | */ |
Anna Bridge |
169:a7c7b631e539 | 175 | __STATIC_INLINE uint32_t PT_IsActiveMulti(uint32_t pts) |
Anna Bridge |
169:a7c7b631e539 | 176 | { |
Anna Bridge |
169:a7c7b631e539 | 177 | return (MXC_PTG->enable & pts); |
Anna Bridge |
169:a7c7b631e539 | 178 | } |
Anna Bridge |
169:a7c7b631e539 | 179 | |
Anna Bridge |
169:a7c7b631e539 | 180 | /** |
Anna Bridge |
169:a7c7b631e539 | 181 | * @brief Sets the pattern of the pulse train |
Anna Bridge |
169:a7c7b631e539 | 182 | * |
Anna Bridge |
169:a7c7b631e539 | 183 | * @param pt Pointer to pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 184 | * @param pattern output pattern |
Anna Bridge |
169:a7c7b631e539 | 185 | * |
Anna Bridge |
169:a7c7b631e539 | 186 | */ |
Anna Bridge |
169:a7c7b631e539 | 187 | __STATIC_INLINE void PT_SetPattern(mxc_pt_regs_t *pt, uint32_t pattern) |
Anna Bridge |
169:a7c7b631e539 | 188 | { |
Anna Bridge |
169:a7c7b631e539 | 189 | pt->train = pattern; |
Anna Bridge |
169:a7c7b631e539 | 190 | } |
Anna Bridge |
169:a7c7b631e539 | 191 | |
Anna Bridge |
169:a7c7b631e539 | 192 | /** |
Anna Bridge |
169:a7c7b631e539 | 193 | * @brief Enable pulse train interrupt |
Anna Bridge |
169:a7c7b631e539 | 194 | * |
Anna Bridge |
169:a7c7b631e539 | 195 | * @param pts Pointer to pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 196 | */ |
Anna Bridge |
169:a7c7b631e539 | 197 | __STATIC_INLINE void PT_EnableINT(mxc_pt_regs_t *pt) |
Anna Bridge |
169:a7c7b631e539 | 198 | { |
Anna Bridge |
169:a7c7b631e539 | 199 | int ptIndex = MXC_PT_GET_IDX(pt); |
Anna Bridge |
169:a7c7b631e539 | 200 | |
Anna Bridge |
169:a7c7b631e539 | 201 | MXC_PTG->inten |= (1 << ptIndex); |
Anna Bridge |
169:a7c7b631e539 | 202 | } |
Anna Bridge |
169:a7c7b631e539 | 203 | |
Anna Bridge |
169:a7c7b631e539 | 204 | /** |
Anna Bridge |
169:a7c7b631e539 | 205 | * @brief Enable interrupts for the pulse trains selected |
Anna Bridge |
169:a7c7b631e539 | 206 | * |
Anna Bridge |
169:a7c7b631e539 | 207 | * @param pts set the bits of pulse trains to enable |
Anna Bridge |
169:a7c7b631e539 | 208 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 209 | */ |
Anna Bridge |
169:a7c7b631e539 | 210 | __STATIC_INLINE void PT_EnableINTMulti(uint32_t pts) |
Anna Bridge |
169:a7c7b631e539 | 211 | { |
Anna Bridge |
169:a7c7b631e539 | 212 | MXC_PTG->inten |= pts; |
Anna Bridge |
169:a7c7b631e539 | 213 | } |
Anna Bridge |
169:a7c7b631e539 | 214 | |
Anna Bridge |
169:a7c7b631e539 | 215 | /** |
Anna Bridge |
169:a7c7b631e539 | 216 | * @brief Disable pulse train interrupt |
Anna Bridge |
169:a7c7b631e539 | 217 | * |
Anna Bridge |
169:a7c7b631e539 | 218 | * @param pts pulse train to operate on |
Anna Bridge |
169:a7c7b631e539 | 219 | */ |
Anna Bridge |
169:a7c7b631e539 | 220 | __STATIC_INLINE void PT_DisableINT(mxc_pt_regs_t *pt) |
Anna Bridge |
169:a7c7b631e539 | 221 | { |
Anna Bridge |
169:a7c7b631e539 | 222 | int ptIndex = MXC_PT_GET_IDX(pt); |
Anna Bridge |
169:a7c7b631e539 | 223 | |
Anna Bridge |
169:a7c7b631e539 | 224 | MXC_PTG->inten &= ~(1 << ptIndex); |
Anna Bridge |
169:a7c7b631e539 | 225 | } |
Anna Bridge |
169:a7c7b631e539 | 226 | |
Anna Bridge |
169:a7c7b631e539 | 227 | /** |
Anna Bridge |
169:a7c7b631e539 | 228 | * @brief Disable interrupts for the pulse trains selected |
Anna Bridge |
169:a7c7b631e539 | 229 | * |
Anna Bridge |
169:a7c7b631e539 | 230 | * @param pts set the bits of pulse trains to enable |
Anna Bridge |
169:a7c7b631e539 | 231 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 232 | */ |
Anna Bridge |
169:a7c7b631e539 | 233 | __STATIC_INLINE void PT_DisableINTMulti(uint32_t pts) |
Anna Bridge |
169:a7c7b631e539 | 234 | { |
Anna Bridge |
169:a7c7b631e539 | 235 | MXC_PTG->inten &= ~pts; |
Anna Bridge |
169:a7c7b631e539 | 236 | } |
Anna Bridge |
169:a7c7b631e539 | 237 | /** |
Anna Bridge |
169:a7c7b631e539 | 238 | * @brief Gets the pulse trains's interrupt flags |
Anna Bridge |
169:a7c7b631e539 | 239 | * |
Anna Bridge |
169:a7c7b631e539 | 240 | * @return The Pulse Train Flags, bits that are 1 are set. |
Anna Bridge |
169:a7c7b631e539 | 241 | */ |
Anna Bridge |
169:a7c7b631e539 | 242 | __STATIC_INLINE uint32_t PT_GetFlags(void) |
Anna Bridge |
169:a7c7b631e539 | 243 | { |
Anna Bridge |
169:a7c7b631e539 | 244 | return MXC_PTG->intfl; |
Anna Bridge |
169:a7c7b631e539 | 245 | } |
Anna Bridge |
169:a7c7b631e539 | 246 | |
Anna Bridge |
169:a7c7b631e539 | 247 | /** |
Anna Bridge |
169:a7c7b631e539 | 248 | * @brief Clears the pulse train's interrupt flag |
Anna Bridge |
169:a7c7b631e539 | 249 | * |
Anna Bridge |
169:a7c7b631e539 | 250 | * @param mask bits to clear |
Anna Bridge |
169:a7c7b631e539 | 251 | * |
Anna Bridge |
169:a7c7b631e539 | 252 | */ |
Anna Bridge |
169:a7c7b631e539 | 253 | __STATIC_INLINE void PT_ClearFlags(uint32_t mask) |
Anna Bridge |
169:a7c7b631e539 | 254 | { |
Anna Bridge |
169:a7c7b631e539 | 255 | MXC_PTG->intfl = mask; |
Anna Bridge |
169:a7c7b631e539 | 256 | } |
Anna Bridge |
169:a7c7b631e539 | 257 | |
Anna Bridge |
169:a7c7b631e539 | 258 | /** |
Anna Bridge |
169:a7c7b631e539 | 259 | * @brief Setup and enables a pulse train to restart after another pulse train has exited its loop. |
Anna Bridge |
169:a7c7b631e539 | 260 | * Each pulse train can have up to two restart triggers. |
Anna Bridge |
169:a7c7b631e539 | 261 | * |
Anna Bridge |
169:a7c7b631e539 | 262 | * @param ptToRestart pulse train to restart after \a ptStop ends |
Anna Bridge |
169:a7c7b631e539 | 263 | * @param ptStop pulse train that stops and triggers \a ptToRestart to begin |
Anna Bridge |
169:a7c7b631e539 | 264 | * @param restartIndex selects which restart trigger to set (0 or 1) |
Anna Bridge |
169:a7c7b631e539 | 265 | */ |
Anna Bridge |
169:a7c7b631e539 | 266 | __STATIC_INLINE void PT_SetRestart(mxc_pt_regs_t *ptToRestart, mxc_pt_regs_t *ptStop, uint8_t restartIndex) |
Anna Bridge |
169:a7c7b631e539 | 267 | { |
Anna Bridge |
169:a7c7b631e539 | 268 | int ptStopIndex = MXC_PT_GET_IDX(ptStop); |
Anna Bridge |
169:a7c7b631e539 | 269 | |
Anna Bridge |
169:a7c7b631e539 | 270 | MXC_ASSERT(ptStopIndex >= 0); |
Anna Bridge |
169:a7c7b631e539 | 271 | |
Anna Bridge |
169:a7c7b631e539 | 272 | if(restartIndex) { |
Anna Bridge |
169:a7c7b631e539 | 273 | ptToRestart->restart |= (ptStopIndex << MXC_F_PT_RESTART_PT_Y_SELECT_POS) | |
Anna Bridge |
169:a7c7b631e539 | 274 | MXC_F_PT_RESTART_ON_PT_Y_LOOP_EXIT; |
Anna Bridge |
169:a7c7b631e539 | 275 | } else { |
Anna Bridge |
169:a7c7b631e539 | 276 | ptToRestart->restart |= (ptStopIndex << MXC_F_PT_RESTART_PT_X_SELECT_POS) | |
Anna Bridge |
169:a7c7b631e539 | 277 | MXC_F_PT_RESTART_ON_PT_X_LOOP_EXIT; |
Anna Bridge |
169:a7c7b631e539 | 278 | } |
Anna Bridge |
169:a7c7b631e539 | 279 | } |
Anna Bridge |
169:a7c7b631e539 | 280 | |
Anna Bridge |
169:a7c7b631e539 | 281 | /** |
Anna Bridge |
169:a7c7b631e539 | 282 | * @brief Disable the restart for the specified pulse train |
Anna Bridge |
169:a7c7b631e539 | 283 | * |
Anna Bridge |
169:a7c7b631e539 | 284 | * @param ptToRestart pulse train to disable the restart |
Anna Bridge |
169:a7c7b631e539 | 285 | * @param restartIndex selects which restart trigger to disable (0 or 1) |
Anna Bridge |
169:a7c7b631e539 | 286 | */ |
Anna Bridge |
169:a7c7b631e539 | 287 | __STATIC_INLINE void PT_RestartDisable(mxc_pt_regs_t *ptToRestart, uint8_t restartIndex) |
Anna Bridge |
169:a7c7b631e539 | 288 | { |
Anna Bridge |
169:a7c7b631e539 | 289 | if(restartIndex) |
Anna Bridge |
169:a7c7b631e539 | 290 | ptToRestart->restart &= ~MXC_F_PT_RESTART_ON_PT_Y_LOOP_EXIT; |
Anna Bridge |
169:a7c7b631e539 | 291 | else |
Anna Bridge |
169:a7c7b631e539 | 292 | ptToRestart->restart &= ~MXC_F_PT_RESTART_ON_PT_X_LOOP_EXIT; |
Anna Bridge |
169:a7c7b631e539 | 293 | } |
Anna Bridge |
169:a7c7b631e539 | 294 | |
Anna Bridge |
169:a7c7b631e539 | 295 | /** |
Anna Bridge |
169:a7c7b631e539 | 296 | * @brief Resynchronize individual pulse trains together. |
Anna Bridge |
169:a7c7b631e539 | 297 | * Resync will stop those resync_pts; others will be still running |
Anna Bridge |
169:a7c7b631e539 | 298 | * |
Anna Bridge |
169:a7c7b631e539 | 299 | * @param resyncPts pulse train modules that need to be re-synced by bit number. |
Anna Bridge |
169:a7c7b631e539 | 300 | * Bit0-\>pt0, Bit1-\>pt1... etc. |
Anna Bridge |
169:a7c7b631e539 | 301 | */ |
Anna Bridge |
169:a7c7b631e539 | 302 | __STATIC_INLINE void PT_Resync(uint32_t resyncPts) |
Anna Bridge |
169:a7c7b631e539 | 303 | { |
Anna Bridge |
169:a7c7b631e539 | 304 | MXC_PTG->resync = resyncPts; |
Anna Bridge |
169:a7c7b631e539 | 305 | while(MXC_PTG->resync); |
Anna Bridge |
169:a7c7b631e539 | 306 | } |
Anna Bridge |
169:a7c7b631e539 | 307 | |
Anna Bridge |
169:a7c7b631e539 | 308 | /**@}*/ |
Anna Bridge |
169:a7c7b631e539 | 309 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 310 | } |
Anna Bridge |
169:a7c7b631e539 | 311 | #endif |
Anna Bridge |
169:a7c7b631e539 | 312 | |
Anna Bridge |
169:a7c7b631e539 | 313 | #endif /* _PT_H_ */ |