5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

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