mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins
Fork of mbed-dev by
targets/TARGET_Maxim/TARGET_MAX32620C/mxc/pmu.c@188:3f10722804f9, 2018-07-30 (annotated)
- Committer:
- ua1arn
- Date:
- Mon Jul 30 12:31:10 2018 +0000
- Revision:
- 188:3f10722804f9
- Parent:
- 186:707f6e361f3e
before add multi-configuration USB descriptors
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
186:707f6e361f3e | 1 | /** |
Anna Bridge |
186:707f6e361f3e | 2 | * @file |
Anna Bridge |
186:707f6e361f3e | 3 | * @brief Peripheral Management Unit (PMU) Function Implementations. |
Anna Bridge |
186:707f6e361f3e | 4 | */ |
Anna Bridge |
186:707f6e361f3e | 5 | /* ***************************************************************************** |
Anna Bridge |
186:707f6e361f3e | 6 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
186:707f6e361f3e | 7 | * |
Anna Bridge |
186:707f6e361f3e | 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
186:707f6e361f3e | 9 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
186:707f6e361f3e | 10 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
186:707f6e361f3e | 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
186:707f6e361f3e | 12 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
186:707f6e361f3e | 13 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
186:707f6e361f3e | 14 | * |
Anna Bridge |
186:707f6e361f3e | 15 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
186:707f6e361f3e | 16 | * in all copies or substantial portions of the Software. |
Anna Bridge |
186:707f6e361f3e | 17 | * |
Anna Bridge |
186:707f6e361f3e | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
186:707f6e361f3e | 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
186:707f6e361f3e | 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
186:707f6e361f3e | 21 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
186:707f6e361f3e | 22 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
186:707f6e361f3e | 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
186:707f6e361f3e | 24 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
186:707f6e361f3e | 25 | * |
Anna Bridge |
186:707f6e361f3e | 26 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 27 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 28 | * Products, Inc. Branding Policy. |
Anna Bridge |
186:707f6e361f3e | 29 | * |
Anna Bridge |
186:707f6e361f3e | 30 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
186:707f6e361f3e | 31 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
186:707f6e361f3e | 32 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
186:707f6e361f3e | 33 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
186:707f6e361f3e | 34 | * ownership rights. |
Anna Bridge |
186:707f6e361f3e | 35 | * |
Anna Bridge |
186:707f6e361f3e | 36 | * $Date: 2016-09-08 17:44:03 -0500 (Thu, 08 Sep 2016) $ |
Anna Bridge |
186:707f6e361f3e | 37 | * $Revision: 24328 $ |
Anna Bridge |
186:707f6e361f3e | 38 | * |
Anna Bridge |
186:707f6e361f3e | 39 | **************************************************************************** */ |
Anna Bridge |
186:707f6e361f3e | 40 | |
Anna Bridge |
186:707f6e361f3e | 41 | /* **** Includes **** */ |
Anna Bridge |
186:707f6e361f3e | 42 | #include <stdio.h> |
Anna Bridge |
186:707f6e361f3e | 43 | #include <stddef.h> |
Anna Bridge |
186:707f6e361f3e | 44 | #include "mxc_config.h" |
Anna Bridge |
186:707f6e361f3e | 45 | #include "mxc_assert.h" |
Anna Bridge |
186:707f6e361f3e | 46 | #include "pmu.h" |
Anna Bridge |
186:707f6e361f3e | 47 | /** |
Anna Bridge |
186:707f6e361f3e | 48 | * @ingroup pmuGroup |
Anna Bridge |
186:707f6e361f3e | 49 | * @{ |
Anna Bridge |
186:707f6e361f3e | 50 | */ |
Anna Bridge |
186:707f6e361f3e | 51 | |
Anna Bridge |
186:707f6e361f3e | 52 | #if (MXC_PMU_REV == 0) |
Anna Bridge |
186:707f6e361f3e | 53 | /* MAX32630 A1 & A2 Erratum #6: PMU only supports channels 0-4 -- workaround */ |
Anna Bridge |
186:707f6e361f3e | 54 | #include "clkman_regs.h" |
Anna Bridge |
186:707f6e361f3e | 55 | /* Channel 5 infinite loop program */ |
Anna Bridge |
186:707f6e361f3e | 56 | static const uint32_t pmu_0[] = { |
Anna Bridge |
186:707f6e361f3e | 57 | PMU_JUMP(0, 0, (uint32_t)pmu_0) |
Anna Bridge |
186:707f6e361f3e | 58 | }; |
Anna Bridge |
186:707f6e361f3e | 59 | #endif |
Anna Bridge |
186:707f6e361f3e | 60 | |
Anna Bridge |
186:707f6e361f3e | 61 | /* **** Local Function Prototypes **** */ |
Anna Bridge |
186:707f6e361f3e | 62 | static void (*callbacks[MXC_CFG_PMU_CHANNELS])(int); |
Anna Bridge |
186:707f6e361f3e | 63 | |
Anna Bridge |
186:707f6e361f3e | 64 | |
Anna Bridge |
186:707f6e361f3e | 65 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 66 | void PMU_Handler(void) |
Anna Bridge |
186:707f6e361f3e | 67 | { |
Anna Bridge |
186:707f6e361f3e | 68 | int channel; |
Anna Bridge |
186:707f6e361f3e | 69 | uint32_t cfg1, cfg2; |
Anna Bridge |
186:707f6e361f3e | 70 | mxc_pmu_regs_t *MXC_PMUn; |
Anna Bridge |
186:707f6e361f3e | 71 | |
Anna Bridge |
186:707f6e361f3e | 72 | for (channel = 0; channel < MXC_CFG_PMU_CHANNELS; channel++) { |
Anna Bridge |
186:707f6e361f3e | 73 | MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 74 | |
Anna Bridge |
186:707f6e361f3e | 75 | if (MXC_PMUn->cfg & MXC_F_PMU_CFG_INTERRUPT) { |
Anna Bridge |
186:707f6e361f3e | 76 | cfg1 = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 77 | /* Since any set flags will be cleared by the write-back below, mask them off */ |
Anna Bridge |
186:707f6e361f3e | 78 | cfg2 = cfg1 & ~(MXC_F_PMU_CFG_LL_STOPPED | MXC_F_PMU_CFG_BUS_ERROR | MXC_F_PMU_CFG_TO_STAT); |
Anna Bridge |
186:707f6e361f3e | 79 | |
Anna Bridge |
186:707f6e361f3e | 80 | /* Clear the interrupt flag */ |
Anna Bridge |
186:707f6e361f3e | 81 | MXC_PMUn->cfg = cfg2 | MXC_F_PMU_CFG_INTERRUPT; |
Anna Bridge |
186:707f6e361f3e | 82 | |
Anna Bridge |
186:707f6e361f3e | 83 | if (callbacks[channel]) { |
Anna Bridge |
186:707f6e361f3e | 84 | callbacks[channel](cfg1); |
Anna Bridge |
186:707f6e361f3e | 85 | } |
Anna Bridge |
186:707f6e361f3e | 86 | } |
Anna Bridge |
186:707f6e361f3e | 87 | } |
Anna Bridge |
186:707f6e361f3e | 88 | } |
Anna Bridge |
186:707f6e361f3e | 89 | |
Anna Bridge |
186:707f6e361f3e | 90 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 91 | int PMU_Start(unsigned int channel, const void *program_address, pmu_callback callback) |
Anna Bridge |
186:707f6e361f3e | 92 | { |
Anna Bridge |
186:707f6e361f3e | 93 | if(channel >= MXC_CFG_PMU_CHANNELS) |
Anna Bridge |
186:707f6e361f3e | 94 | return E_BAD_PARAM; |
Anna Bridge |
186:707f6e361f3e | 95 | |
Anna Bridge |
186:707f6e361f3e | 96 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 97 | uint32_t cfg = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 98 | |
Anna Bridge |
186:707f6e361f3e | 99 | /* is this channel already running? */ |
Anna Bridge |
186:707f6e361f3e | 100 | if (cfg & MXC_F_PMU_CFG_ENABLE) { |
Anna Bridge |
186:707f6e361f3e | 101 | return E_BUSY; |
Anna Bridge |
186:707f6e361f3e | 102 | } |
Anna Bridge |
186:707f6e361f3e | 103 | |
Anna Bridge |
186:707f6e361f3e | 104 | #if (MXC_PMU_REV == 0) |
Anna Bridge |
186:707f6e361f3e | 105 | /* MAX32630 A1 & A2 Erratum #6: PMU only supports channels 0-4 */ |
Anna Bridge |
186:707f6e361f3e | 106 | if (channel == 5) { |
Anna Bridge |
186:707f6e361f3e | 107 | /* Channel 5 is used for the work-around */ |
Anna Bridge |
186:707f6e361f3e | 108 | return E_BUSY; |
Anna Bridge |
186:707f6e361f3e | 109 | } |
Anna Bridge |
186:707f6e361f3e | 110 | /* Select always-ON clock for PMU */ |
Anna Bridge |
186:707f6e361f3e | 111 | MXC_CLKMAN->clk_gate_ctrl0 |= MXC_F_CLKMAN_CLK_GATE_CTRL0_PMU_CLK_GATER; |
Anna Bridge |
186:707f6e361f3e | 112 | /* Start channel 5 with infinite-loop program */ |
Anna Bridge |
186:707f6e361f3e | 113 | MXC_PMU5->cfg &= ~MXC_F_PMU_CFG_ENABLE; /* Clear enable and wipe W1C flags */ |
Anna Bridge |
186:707f6e361f3e | 114 | MXC_PMU5->dscadr = (uint32_t)pmu_0; |
Anna Bridge |
186:707f6e361f3e | 115 | MXC_PMU5->cfg = MXC_F_PMU_CFG_ENABLE | (0x1c << MXC_F_PMU_CFG_BURST_SIZE_POS); |
Anna Bridge |
186:707f6e361f3e | 116 | #endif |
Anna Bridge |
186:707f6e361f3e | 117 | /* Set callback */ |
Anna Bridge |
186:707f6e361f3e | 118 | callbacks[channel] = callback; |
Anna Bridge |
186:707f6e361f3e | 119 | |
Anna Bridge |
186:707f6e361f3e | 120 | /* Set start op-code */ |
Anna Bridge |
186:707f6e361f3e | 121 | MXC_PMUn->dscadr = (uint32_t)program_address; |
Anna Bridge |
186:707f6e361f3e | 122 | |
Anna Bridge |
186:707f6e361f3e | 123 | /* Configure the channel */ |
Anna Bridge |
186:707f6e361f3e | 124 | cfg = (cfg & ~(MXC_F_PMU_CFG_MANUAL | MXC_F_PMU_CFG_BURST_SIZE)) | (0x1c << MXC_F_PMU_CFG_BURST_SIZE_POS); |
Anna Bridge |
186:707f6e361f3e | 125 | |
Anna Bridge |
186:707f6e361f3e | 126 | /* Enable if necessary */ |
Anna Bridge |
186:707f6e361f3e | 127 | if (callback) { |
Anna Bridge |
186:707f6e361f3e | 128 | cfg |= MXC_F_PMU_CFG_INT_EN; |
Anna Bridge |
186:707f6e361f3e | 129 | } else { |
Anna Bridge |
186:707f6e361f3e | 130 | cfg &= ~MXC_F_PMU_CFG_INT_EN; |
Anna Bridge |
186:707f6e361f3e | 131 | } |
Anna Bridge |
186:707f6e361f3e | 132 | |
Anna Bridge |
186:707f6e361f3e | 133 | /* Start the channel */ |
Anna Bridge |
186:707f6e361f3e | 134 | cfg |= MXC_F_PMU_CFG_ENABLE; |
Anna Bridge |
186:707f6e361f3e | 135 | |
Anna Bridge |
186:707f6e361f3e | 136 | /*If any W1C flags are set, this write will clear them */ |
Anna Bridge |
186:707f6e361f3e | 137 | MXC_PMUn->cfg = cfg; |
Anna Bridge |
186:707f6e361f3e | 138 | |
Anna Bridge |
186:707f6e361f3e | 139 | return E_NO_ERROR; |
Anna Bridge |
186:707f6e361f3e | 140 | } |
Anna Bridge |
186:707f6e361f3e | 141 | |
Anna Bridge |
186:707f6e361f3e | 142 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 143 | void PMU_Stop(unsigned int channel) |
Anna Bridge |
186:707f6e361f3e | 144 | { |
Anna Bridge |
186:707f6e361f3e | 145 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 146 | uint32_t cfg = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 147 | |
Anna Bridge |
186:707f6e361f3e | 148 | /* Since any set flags will be cleared by the write-back below, mask them off */ |
Anna Bridge |
186:707f6e361f3e | 149 | cfg &= ~(MXC_F_PMU_CFG_LL_STOPPED | MXC_F_PMU_CFG_BUS_ERROR | MXC_F_PMU_CFG_TO_STAT | MXC_F_PMU_CFG_INTERRUPT); |
Anna Bridge |
186:707f6e361f3e | 150 | |
Anna Bridge |
186:707f6e361f3e | 151 | /* Clear the enable bit to stop the channel */ |
Anna Bridge |
186:707f6e361f3e | 152 | cfg &= ~MXC_F_PMU_CFG_ENABLE; |
Anna Bridge |
186:707f6e361f3e | 153 | |
Anna Bridge |
186:707f6e361f3e | 154 | MXC_PMUn->cfg = cfg; |
Anna Bridge |
186:707f6e361f3e | 155 | |
Anna Bridge |
186:707f6e361f3e | 156 | /* Remove callback */ |
Anna Bridge |
186:707f6e361f3e | 157 | callbacks[channel] = NULL; |
Anna Bridge |
186:707f6e361f3e | 158 | |
Anna Bridge |
186:707f6e361f3e | 159 | #if (MXC_PMU_REV == 0) |
Anna Bridge |
186:707f6e361f3e | 160 | /* MAX32630 A1 & A2 Erratum #6: PMU only supports channels 0-4 */ |
Anna Bridge |
186:707f6e361f3e | 161 | /* Check channels 0-4 for any running channels. If none found, stop channel 5 */ |
Anna Bridge |
186:707f6e361f3e | 162 | if ((MXC_PMU0->cfg & MXC_F_PMU_CFG_ENABLE) == 0 && |
Anna Bridge |
186:707f6e361f3e | 163 | (MXC_PMU1->cfg & MXC_F_PMU_CFG_ENABLE) == 0 && |
Anna Bridge |
186:707f6e361f3e | 164 | (MXC_PMU2->cfg & MXC_F_PMU_CFG_ENABLE) == 0 && |
Anna Bridge |
186:707f6e361f3e | 165 | (MXC_PMU3->cfg & MXC_F_PMU_CFG_ENABLE) == 0 && |
Anna Bridge |
186:707f6e361f3e | 166 | (MXC_PMU4->cfg & MXC_F_PMU_CFG_ENABLE) == 0) { |
Anna Bridge |
186:707f6e361f3e | 167 | MXC_PMU5->cfg &= ~MXC_F_PMU_CFG_ENABLE; |
Anna Bridge |
186:707f6e361f3e | 168 | } |
Anna Bridge |
186:707f6e361f3e | 169 | #endif |
Anna Bridge |
186:707f6e361f3e | 170 | |
Anna Bridge |
186:707f6e361f3e | 171 | } |
Anna Bridge |
186:707f6e361f3e | 172 | |
Anna Bridge |
186:707f6e361f3e | 173 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 174 | int PMU_SetCounter(unsigned int channel, unsigned int counter, uint16_t value) |
Anna Bridge |
186:707f6e361f3e | 175 | { |
Anna Bridge |
186:707f6e361f3e | 176 | if((channel >= MXC_CFG_PMU_CHANNELS) || counter > 1) |
Anna Bridge |
186:707f6e361f3e | 177 | return E_BAD_PARAM; |
Anna Bridge |
186:707f6e361f3e | 178 | |
Anna Bridge |
186:707f6e361f3e | 179 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 180 | |
Anna Bridge |
186:707f6e361f3e | 181 | if (counter == 0) { |
Anna Bridge |
186:707f6e361f3e | 182 | MXC_PMUn->loop = (MXC_PMUn->loop & ~MXC_F_PMU_LOOP_COUNTER_0) | (value << MXC_F_PMU_LOOP_COUNTER_0_POS); |
Anna Bridge |
186:707f6e361f3e | 183 | } else { |
Anna Bridge |
186:707f6e361f3e | 184 | MXC_PMUn->loop = (MXC_PMUn->loop & ~MXC_F_PMU_LOOP_COUNTER_1) | (value << MXC_F_PMU_LOOP_COUNTER_1_POS); |
Anna Bridge |
186:707f6e361f3e | 185 | } |
Anna Bridge |
186:707f6e361f3e | 186 | |
Anna Bridge |
186:707f6e361f3e | 187 | return E_NO_ERROR; |
Anna Bridge |
186:707f6e361f3e | 188 | } |
Anna Bridge |
186:707f6e361f3e | 189 | |
Anna Bridge |
186:707f6e361f3e | 190 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 191 | int PMU_SetTimeout(unsigned int channel, pmu_ps_sel_t timeoutClkScale, pmu_to_sel_t timeoutTicks) |
Anna Bridge |
186:707f6e361f3e | 192 | { |
Anna Bridge |
186:707f6e361f3e | 193 | if(channel >= MXC_CFG_PMU_CHANNELS) |
Anna Bridge |
186:707f6e361f3e | 194 | return E_BAD_PARAM; |
Anna Bridge |
186:707f6e361f3e | 195 | |
Anna Bridge |
186:707f6e361f3e | 196 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 197 | uint32_t cfg = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 198 | |
Anna Bridge |
186:707f6e361f3e | 199 | /* Since any set flags will be cleared by the write-back below, mask them off */ |
Anna Bridge |
186:707f6e361f3e | 200 | cfg &= ~(MXC_F_PMU_CFG_LL_STOPPED | MXC_F_PMU_CFG_BUS_ERROR | MXC_F_PMU_CFG_TO_STAT | MXC_F_PMU_CFG_INTERRUPT); |
Anna Bridge |
186:707f6e361f3e | 201 | |
Anna Bridge |
186:707f6e361f3e | 202 | /* Adjust timeout settings */ |
Anna Bridge |
186:707f6e361f3e | 203 | cfg &= ~(MXC_F_PMU_CFG_TO_SEL | MXC_F_PMU_CFG_PS_SEL); |
Anna Bridge |
186:707f6e361f3e | 204 | cfg |= ((timeoutClkScale << MXC_F_PMU_CFG_PS_SEL_POS) & MXC_F_PMU_CFG_PS_SEL) | |
Anna Bridge |
186:707f6e361f3e | 205 | ((timeoutTicks << MXC_F_PMU_CFG_TO_SEL_POS) & MXC_F_PMU_CFG_TO_SEL); |
Anna Bridge |
186:707f6e361f3e | 206 | |
Anna Bridge |
186:707f6e361f3e | 207 | MXC_PMUn->cfg = cfg; |
Anna Bridge |
186:707f6e361f3e | 208 | |
Anna Bridge |
186:707f6e361f3e | 209 | return E_NO_ERROR; |
Anna Bridge |
186:707f6e361f3e | 210 | } |
Anna Bridge |
186:707f6e361f3e | 211 | |
Anna Bridge |
186:707f6e361f3e | 212 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 213 | uint32_t PMU_GetFlags(unsigned int channel) |
Anna Bridge |
186:707f6e361f3e | 214 | { |
Anna Bridge |
186:707f6e361f3e | 215 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 216 | uint32_t cfg = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 217 | |
Anna Bridge |
186:707f6e361f3e | 218 | /* Mask off configuration bits leaving only flag bits */ |
Anna Bridge |
186:707f6e361f3e | 219 | cfg &= ~(MXC_F_PMU_CFG_ENABLE | MXC_F_PMU_CFG_MANUAL | MXC_F_PMU_CFG_TO_SEL | MXC_F_PMU_CFG_PS_SEL | |
Anna Bridge |
186:707f6e361f3e | 220 | MXC_F_PMU_CFG_INT_EN | MXC_F_PMU_CFG_BURST_SIZE); |
Anna Bridge |
186:707f6e361f3e | 221 | |
Anna Bridge |
186:707f6e361f3e | 222 | return cfg; |
Anna Bridge |
186:707f6e361f3e | 223 | } |
Anna Bridge |
186:707f6e361f3e | 224 | |
Anna Bridge |
186:707f6e361f3e | 225 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 226 | void PMU_ClearFlags(unsigned int channel, unsigned int mask) |
Anna Bridge |
186:707f6e361f3e | 227 | { |
Anna Bridge |
186:707f6e361f3e | 228 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 229 | uint32_t cfg = MXC_PMUn->cfg; |
Anna Bridge |
186:707f6e361f3e | 230 | |
Anna Bridge |
186:707f6e361f3e | 231 | /* Since any set flags will be cleared by the write-back below, mask them off */ |
Anna Bridge |
186:707f6e361f3e | 232 | cfg &= ~(MXC_F_PMU_CFG_LL_STOPPED | MXC_F_PMU_CFG_BUS_ERROR | MXC_F_PMU_CFG_TO_STAT | MXC_F_PMU_CFG_INTERRUPT); |
Anna Bridge |
186:707f6e361f3e | 233 | |
Anna Bridge |
186:707f6e361f3e | 234 | /* Now, apply the caller-supplied bits to clear */ |
Anna Bridge |
186:707f6e361f3e | 235 | cfg |= mask; |
Anna Bridge |
186:707f6e361f3e | 236 | |
Anna Bridge |
186:707f6e361f3e | 237 | MXC_PMUn->cfg = cfg; |
Anna Bridge |
186:707f6e361f3e | 238 | } |
Anna Bridge |
186:707f6e361f3e | 239 | |
Anna Bridge |
186:707f6e361f3e | 240 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 241 | uint32_t PMU_IsActive(unsigned int channel) |
Anna Bridge |
186:707f6e361f3e | 242 | { |
Anna Bridge |
186:707f6e361f3e | 243 | mxc_pmu_regs_t *MXC_PMUn = &MXC_PMU0[channel]; |
Anna Bridge |
186:707f6e361f3e | 244 | return (MXC_PMUn->cfg & MXC_F_PMU_CFG_ENABLE); |
Anna Bridge |
186:707f6e361f3e | 245 | } |
Anna Bridge |
186:707f6e361f3e | 246 | /**@} end of ingroup pmuGroup */ |