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