Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 /**************************************************************************//**
switches 0:5c4d7b2438d3 2 * @file core_cmSecureAccess.h
switches 0:5c4d7b2438d3 3 * @brief CMSIS Cortex-M Core Secure Access Header File
switches 0:5c4d7b2438d3 4 * @version XXX
switches 0:5c4d7b2438d3 5 * @date 10. June 2016
switches 0:5c4d7b2438d3 6 *
switches 0:5c4d7b2438d3 7 * @note
switches 0:5c4d7b2438d3 8 *
switches 0:5c4d7b2438d3 9 ******************************************************************************/
switches 0:5c4d7b2438d3 10 /* Copyright (c) 2016 ARM LIMITED
switches 0:5c4d7b2438d3 11
switches 0:5c4d7b2438d3 12 All rights reserved.
switches 0:5c4d7b2438d3 13 Redistribution and use in source and binary forms, with or without
switches 0:5c4d7b2438d3 14 modification, are permitted provided that the following conditions are met:
switches 0:5c4d7b2438d3 15 - Redistributions of source code must retain the above copyright
switches 0:5c4d7b2438d3 16 notice, this list of conditions and the following disclaimer.
switches 0:5c4d7b2438d3 17 - Redistributions in binary form must reproduce the above copyright
switches 0:5c4d7b2438d3 18 notice, this list of conditions and the following disclaimer in the
switches 0:5c4d7b2438d3 19 documentation and/or other materials provided with the distribution.
switches 0:5c4d7b2438d3 20 - Neither the name of ARM nor the names of its contributors may be used
switches 0:5c4d7b2438d3 21 to endorse or promote products derived from this software without
switches 0:5c4d7b2438d3 22 specific prior written permission.
switches 0:5c4d7b2438d3 23 *
switches 0:5c4d7b2438d3 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
switches 0:5c4d7b2438d3 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
switches 0:5c4d7b2438d3 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
switches 0:5c4d7b2438d3 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
switches 0:5c4d7b2438d3 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
switches 0:5c4d7b2438d3 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
switches 0:5c4d7b2438d3 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
switches 0:5c4d7b2438d3 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
switches 0:5c4d7b2438d3 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
switches 0:5c4d7b2438d3 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
switches 0:5c4d7b2438d3 34 POSSIBILITY OF SUCH DAMAGE.
switches 0:5c4d7b2438d3 35 ---------------------------------------------------------------------------*/
switches 0:5c4d7b2438d3 36
switches 0:5c4d7b2438d3 37
switches 0:5c4d7b2438d3 38 #ifndef __CORE_CM_SECURE_ACCESS_H
switches 0:5c4d7b2438d3 39 #define __CORE_CM_SECURE_ACCESS_H
switches 0:5c4d7b2438d3 40
switches 0:5c4d7b2438d3 41
switches 0:5c4d7b2438d3 42 /* ########################### Core Secure Access ########################### */
switches 0:5c4d7b2438d3 43
switches 0:5c4d7b2438d3 44 #ifdef FEATURE_UVISOR
switches 0:5c4d7b2438d3 45 #include "uvisor-lib.h"
switches 0:5c4d7b2438d3 46
switches 0:5c4d7b2438d3 47 /* Secure uVisor implementation. */
switches 0:5c4d7b2438d3 48
switches 0:5c4d7b2438d3 49 /** Set the value at the target address.
switches 0:5c4d7b2438d3 50 *
switches 0:5c4d7b2438d3 51 * Equivalent to: `*address = value`.
switches 0:5c4d7b2438d3 52 * @param address[in] Target address
switches 0:5c4d7b2438d3 53 * @param value[in] Value to write at the address location.
switches 0:5c4d7b2438d3 54 */
switches 0:5c4d7b2438d3 55 #define SECURE_WRITE(address, value) \
switches 0:5c4d7b2438d3 56 uvisor_write(main, UVISOR_RGW_SHARED, address, value, UVISOR_RGW_OP_WRITE, 0xFFFFFFFFUL)
switches 0:5c4d7b2438d3 57
switches 0:5c4d7b2438d3 58 /** Get the value at the target address.
switches 0:5c4d7b2438d3 59 *
switches 0:5c4d7b2438d3 60 * @param address[in] Target address
switches 0:5c4d7b2438d3 61 * @returns The value `*address`.
switches 0:5c4d7b2438d3 62 */
switches 0:5c4d7b2438d3 63 #define SECURE_READ(address) \
switches 0:5c4d7b2438d3 64 uvisor_read(main, UVISOR_RGW_SHARED, address, UVISOR_RGW_OP_READ, 0xFFFFFFFFUL)
switches 0:5c4d7b2438d3 65
switches 0:5c4d7b2438d3 66 /** Get the selected bits at the target address.
switches 0:5c4d7b2438d3 67 *
switches 0:5c4d7b2438d3 68 * @param address[in] Target address
switches 0:5c4d7b2438d3 69 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 70 * @returns The value `*address & mask`.
switches 0:5c4d7b2438d3 71 */
switches 0:5c4d7b2438d3 72 #define SECURE_BITS_GET(address, mask) \
switches 0:5c4d7b2438d3 73 UVISOR_BITS_GET(main, UVISOR_RGW_SHARED, address, mask)
switches 0:5c4d7b2438d3 74
switches 0:5c4d7b2438d3 75 /** Check the selected bits at the target address.
switches 0:5c4d7b2438d3 76 *
switches 0:5c4d7b2438d3 77 * @param address[in] Address at which to check the bits
switches 0:5c4d7b2438d3 78 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 79 * @returns The value `((*address & mask) == mask)`.
switches 0:5c4d7b2438d3 80 */
switches 0:5c4d7b2438d3 81 #define SECURE_BITS_CHECK(address, mask) \
switches 0:5c4d7b2438d3 82 UVISOR_BITS_CHECK(main, UVISOR_RGW_SHARED, address, mask)
switches 0:5c4d7b2438d3 83
switches 0:5c4d7b2438d3 84 /** Set the selected bits to 1 at the target address.
switches 0:5c4d7b2438d3 85 *
switches 0:5c4d7b2438d3 86 * Equivalent to: `*address |= mask`.
switches 0:5c4d7b2438d3 87 * @param address[in] Target address
switches 0:5c4d7b2438d3 88 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 89 */
switches 0:5c4d7b2438d3 90 #define SECURE_BITS_SET(address, mask) \
switches 0:5c4d7b2438d3 91 UVISOR_BITS_SET(main, UVISOR_RGW_SHARED, address, mask)
switches 0:5c4d7b2438d3 92
switches 0:5c4d7b2438d3 93 /** Clear the selected bits at the target address.
switches 0:5c4d7b2438d3 94 *
switches 0:5c4d7b2438d3 95 * Equivalent to: `*address &= ~mask`.
switches 0:5c4d7b2438d3 96 * @param address[in] Target address
switches 0:5c4d7b2438d3 97 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 98 */
switches 0:5c4d7b2438d3 99 #define SECURE_BITS_CLEAR(address, mask) \
switches 0:5c4d7b2438d3 100 UVISOR_BITS_CLEAR(main, UVISOR_RGW_SHARED, address, mask)
switches 0:5c4d7b2438d3 101
switches 0:5c4d7b2438d3 102 /** Set the selected bits at the target address to the given value.
switches 0:5c4d7b2438d3 103 *
switches 0:5c4d7b2438d3 104 * Equivalent to: `*address = (*address & ~mask) | (value & mask)`.
switches 0:5c4d7b2438d3 105 * @param address[in] Target address
switches 0:5c4d7b2438d3 106 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 107 * @param value[in] Value to write at the address location. Note: The value
switches 0:5c4d7b2438d3 108 * must be already shifted to the correct bit position
switches 0:5c4d7b2438d3 109 */
switches 0:5c4d7b2438d3 110 #define SECURE_BITS_SET_VALUE(address, mask, value) \
switches 0:5c4d7b2438d3 111 UVISOR_BITS_SET_VALUE(main, UVISOR_RGW_SHARED, address, mask, value)
switches 0:5c4d7b2438d3 112
switches 0:5c4d7b2438d3 113 /** Toggle the selected bits at the target address.
switches 0:5c4d7b2438d3 114 *
switches 0:5c4d7b2438d3 115 * Equivalent to: `*address ^= mask`.
switches 0:5c4d7b2438d3 116 * @param address[in] Target address
switches 0:5c4d7b2438d3 117 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 118 */
switches 0:5c4d7b2438d3 119 #define SECURE_BITS_TOGGLE(address, mask) \
switches 0:5c4d7b2438d3 120 UVISOR_BITS_TOGGLE(main, UVISOR_RGW_SHARED, address, mask)
switches 0:5c4d7b2438d3 121
switches 0:5c4d7b2438d3 122 #else
switches 0:5c4d7b2438d3 123
switches 0:5c4d7b2438d3 124 /* Insecure fallback implementation. */
switches 0:5c4d7b2438d3 125
switches 0:5c4d7b2438d3 126 /** Set the value at the target address.
switches 0:5c4d7b2438d3 127 *
switches 0:5c4d7b2438d3 128 * Equivalent to: `*address = value`.
switches 0:5c4d7b2438d3 129 * @param address[in] Target address
switches 0:5c4d7b2438d3 130 * @param value[in] Value to write at the address location.
switches 0:5c4d7b2438d3 131 */
switches 0:5c4d7b2438d3 132 #define SECURE_WRITE(address, value) \
switches 0:5c4d7b2438d3 133 *(address) = (value)
switches 0:5c4d7b2438d3 134
switches 0:5c4d7b2438d3 135 /** Get the value at the target address.
switches 0:5c4d7b2438d3 136 *
switches 0:5c4d7b2438d3 137 * @param address[in] Target address
switches 0:5c4d7b2438d3 138 * @returns The value `*address`.
switches 0:5c4d7b2438d3 139 */
switches 0:5c4d7b2438d3 140 #define SECURE_READ(address) \
switches 0:5c4d7b2438d3 141 (*(address))
switches 0:5c4d7b2438d3 142
switches 0:5c4d7b2438d3 143 /** Get the selected bits at the target address.
switches 0:5c4d7b2438d3 144 *
switches 0:5c4d7b2438d3 145 * @param address[in] Target address
switches 0:5c4d7b2438d3 146 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 147 * @returns The value `*address & mask`.
switches 0:5c4d7b2438d3 148 */
switches 0:5c4d7b2438d3 149 #define SECURE_BITS_GET(address, mask) \
switches 0:5c4d7b2438d3 150 (*(address) & (mask))
switches 0:5c4d7b2438d3 151
switches 0:5c4d7b2438d3 152 /** Check the selected bits at the target address.
switches 0:5c4d7b2438d3 153 *
switches 0:5c4d7b2438d3 154 * @param address[in] Address at which to check the bits
switches 0:5c4d7b2438d3 155 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 156 * @returns The value `((*address & mask) == mask)`.
switches 0:5c4d7b2438d3 157 */
switches 0:5c4d7b2438d3 158 #define SECURE_BITS_CHECK(address, mask) \
switches 0:5c4d7b2438d3 159 ((*(address) & (mask)) == (mask))
switches 0:5c4d7b2438d3 160
switches 0:5c4d7b2438d3 161 /** Set the selected bits to 1 at the target address.
switches 0:5c4d7b2438d3 162 *
switches 0:5c4d7b2438d3 163 * Equivalent to: `*address |= mask`.
switches 0:5c4d7b2438d3 164 * @param address[in] Target address
switches 0:5c4d7b2438d3 165 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 166 */
switches 0:5c4d7b2438d3 167 #define SECURE_BITS_SET(address, mask) \
switches 0:5c4d7b2438d3 168 *(address) |= (mask)
switches 0:5c4d7b2438d3 169
switches 0:5c4d7b2438d3 170 /** Clear the selected bits at the target address.
switches 0:5c4d7b2438d3 171 *
switches 0:5c4d7b2438d3 172 * Equivalent to: `*address &= ~mask`.
switches 0:5c4d7b2438d3 173 * @param address[in] Target address
switches 0:5c4d7b2438d3 174 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 175 */
switches 0:5c4d7b2438d3 176 #define SECURE_BITS_CLEAR(address, mask) \
switches 0:5c4d7b2438d3 177 *(address) &= ~(mask)
switches 0:5c4d7b2438d3 178
switches 0:5c4d7b2438d3 179 /** Set the selected bits at the target address to the given value.
switches 0:5c4d7b2438d3 180 *
switches 0:5c4d7b2438d3 181 * Equivalent to: `*address = (*address & ~mask) | (value & mask)`.
switches 0:5c4d7b2438d3 182 * @param address[in] Target address
switches 0:5c4d7b2438d3 183 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 184 * @param value[in] Value to write at the address location. Note: The value
switches 0:5c4d7b2438d3 185 * must be already shifted to the correct bit position
switches 0:5c4d7b2438d3 186 */
switches 0:5c4d7b2438d3 187 #define SECURE_BITS_SET_VALUE(address, mask, value) \
switches 0:5c4d7b2438d3 188 *(address) = (*(address) & ~(mask)) | ((value) & (mask))
switches 0:5c4d7b2438d3 189
switches 0:5c4d7b2438d3 190 /** Toggle the selected bits at the target address.
switches 0:5c4d7b2438d3 191 *
switches 0:5c4d7b2438d3 192 * Equivalent to: `*address ^= mask`.
switches 0:5c4d7b2438d3 193 * @param address[in] Target address
switches 0:5c4d7b2438d3 194 * @param mask[in] Bits to select out of the target address
switches 0:5c4d7b2438d3 195 */
switches 0:5c4d7b2438d3 196 #define SECURE_BITS_TOGGLE(address, mask) \
switches 0:5c4d7b2438d3 197 *(address) ^= (mask)
switches 0:5c4d7b2438d3 198
switches 0:5c4d7b2438d3 199 #endif
switches 0:5c4d7b2438d3 200
switches 0:5c4d7b2438d3 201 #endif /* __CORE_CM_SECURE_ACCESS_H */