temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IKobayashi 0:c88c3b616c00 1
IKobayashi 0:c88c3b616c00 2 /** \addtogroup platform */
IKobayashi 0:c88c3b616c00 3 /** @{*/
IKobayashi 0:c88c3b616c00 4 /*
IKobayashi 0:c88c3b616c00 5 * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
IKobayashi 0:c88c3b616c00 6 * SPDX-License-Identifier: Apache-2.0
IKobayashi 0:c88c3b616c00 7 *
IKobayashi 0:c88c3b616c00 8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
IKobayashi 0:c88c3b616c00 9 * not use this file except in compliance with the License.
IKobayashi 0:c88c3b616c00 10 * You may obtain a copy of the License at
IKobayashi 0:c88c3b616c00 11 *
IKobayashi 0:c88c3b616c00 12 * http://www.apache.org/licenses/LICENSE-2.0
IKobayashi 0:c88c3b616c00 13 *
IKobayashi 0:c88c3b616c00 14 * Unless required by applicable law or agreed to in writing, software
IKobayashi 0:c88c3b616c00 15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
IKobayashi 0:c88c3b616c00 16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
IKobayashi 0:c88c3b616c00 17 * See the License for the specific language governing permissions and
IKobayashi 0:c88c3b616c00 18 * limitations under the License.
IKobayashi 0:c88c3b616c00 19 */
IKobayashi 0:c88c3b616c00 20
IKobayashi 0:c88c3b616c00 21 #ifndef __MBED_UTIL_CRITICAL_H__
IKobayashi 0:c88c3b616c00 22 #define __MBED_UTIL_CRITICAL_H__
IKobayashi 0:c88c3b616c00 23
IKobayashi 0:c88c3b616c00 24 #include <stdbool.h>
IKobayashi 0:c88c3b616c00 25 #include <stdint.h>
IKobayashi 0:c88c3b616c00 26 #include <stddef.h>
IKobayashi 0:c88c3b616c00 27
IKobayashi 0:c88c3b616c00 28 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 29 extern "C" {
IKobayashi 0:c88c3b616c00 30 #endif
IKobayashi 0:c88c3b616c00 31
IKobayashi 0:c88c3b616c00 32
IKobayashi 0:c88c3b616c00 33 /** Determine the current interrupts enabled state
IKobayashi 0:c88c3b616c00 34 *
IKobayashi 0:c88c3b616c00 35 * This function can be called to determine whether or not interrupts are currently enabled.
IKobayashi 0:c88c3b616c00 36 * \note
IKobayashi 0:c88c3b616c00 37 * NOTE:
IKobayashi 0:c88c3b616c00 38 * This function works for both cortex-A and cortex-M, although the underlyng implementation
IKobayashi 0:c88c3b616c00 39 * differs.
IKobayashi 0:c88c3b616c00 40 * @return true if interrupts are enabled, false otherwise
IKobayashi 0:c88c3b616c00 41 */
IKobayashi 0:c88c3b616c00 42 bool core_util_are_interrupts_enabled(void);
IKobayashi 0:c88c3b616c00 43
IKobayashi 0:c88c3b616c00 44 /** Mark the start of a critical section
IKobayashi 0:c88c3b616c00 45 *
IKobayashi 0:c88c3b616c00 46 * This function should be called to mark the start of a critical section of code.
IKobayashi 0:c88c3b616c00 47 * \note
IKobayashi 0:c88c3b616c00 48 * NOTES:
IKobayashi 0:c88c3b616c00 49 * 1) The use of this style of critical section is targetted at C based implementations.
IKobayashi 0:c88c3b616c00 50 * 2) These critical sections can be nested.
IKobayashi 0:c88c3b616c00 51 * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
IKobayashi 0:c88c3b616c00 52 * section) will be preserved on exit from the section.
IKobayashi 0:c88c3b616c00 53 * 4) This implementation will currently only work on code running in privileged mode.
IKobayashi 0:c88c3b616c00 54 */
IKobayashi 0:c88c3b616c00 55 void core_util_critical_section_enter(void);
IKobayashi 0:c88c3b616c00 56
IKobayashi 0:c88c3b616c00 57 /** Mark the end of a critical section
IKobayashi 0:c88c3b616c00 58 *
IKobayashi 0:c88c3b616c00 59 * This function should be called to mark the end of a critical section of code.
IKobayashi 0:c88c3b616c00 60 * \note
IKobayashi 0:c88c3b616c00 61 * NOTES:
IKobayashi 0:c88c3b616c00 62 * 1) The use of this style of critical section is targetted at C based implementations.
IKobayashi 0:c88c3b616c00 63 * 2) These critical sections can be nested.
IKobayashi 0:c88c3b616c00 64 * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
IKobayashi 0:c88c3b616c00 65 * section) will be preserved on exit from the section.
IKobayashi 0:c88c3b616c00 66 * 4) This implementation will currently only work on code running in privileged mode.
IKobayashi 0:c88c3b616c00 67 */
IKobayashi 0:c88c3b616c00 68 void core_util_critical_section_exit(void);
IKobayashi 0:c88c3b616c00 69
IKobayashi 0:c88c3b616c00 70 /**
IKobayashi 0:c88c3b616c00 71 * Atomic compare and set. It compares the contents of a memory location to a
IKobayashi 0:c88c3b616c00 72 * given value and, only if they are the same, modifies the contents of that
IKobayashi 0:c88c3b616c00 73 * memory location to a given new value. This is done as a single atomic
IKobayashi 0:c88c3b616c00 74 * operation. The atomicity guarantees that the new value is calculated based on
IKobayashi 0:c88c3b616c00 75 * up-to-date information; if the value had been updated by another thread in
IKobayashi 0:c88c3b616c00 76 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
IKobayashi 0:c88c3b616c00 77 *
IKobayashi 0:c88c3b616c00 78 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
IKobayashi 0:c88c3b616c00 79 * you to the article on compare-and swap].
IKobayashi 0:c88c3b616c00 80 *
IKobayashi 0:c88c3b616c00 81 * @param ptr The target memory location.
IKobayashi 0:c88c3b616c00 82 * @param[in,out] expectedCurrentValue A pointer to some location holding the
IKobayashi 0:c88c3b616c00 83 * expected current value of the data being set atomically.
IKobayashi 0:c88c3b616c00 84 * The computed 'desiredValue' should be a function of this current value.
IKobayashi 0:c88c3b616c00 85 * @Note: This is an in-out parameter. In the
IKobayashi 0:c88c3b616c00 86 * failure case of atomic_cas (where the
IKobayashi 0:c88c3b616c00 87 * destination isn't set), the pointee of expectedCurrentValue is
IKobayashi 0:c88c3b616c00 88 * updated with the current value.
IKobayashi 0:c88c3b616c00 89 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
IKobayashi 0:c88c3b616c00 90 *
IKobayashi 0:c88c3b616c00 91 * @return true if the memory location was atomically
IKobayashi 0:c88c3b616c00 92 * updated with the desired value (after verifying
IKobayashi 0:c88c3b616c00 93 * that it contained the expectedCurrentValue),
IKobayashi 0:c88c3b616c00 94 * false otherwise. In the failure case,
IKobayashi 0:c88c3b616c00 95 * exepctedCurrentValue is updated with the new
IKobayashi 0:c88c3b616c00 96 * value of the target memory location.
IKobayashi 0:c88c3b616c00 97 *
IKobayashi 0:c88c3b616c00 98 * pseudocode:
IKobayashi 0:c88c3b616c00 99 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
IKobayashi 0:c88c3b616c00 100 * if *p != *old {
IKobayashi 0:c88c3b616c00 101 * *old = *p
IKobayashi 0:c88c3b616c00 102 * return false
IKobayashi 0:c88c3b616c00 103 * }
IKobayashi 0:c88c3b616c00 104 * *p = new
IKobayashi 0:c88c3b616c00 105 * return true
IKobayashi 0:c88c3b616c00 106 * }
IKobayashi 0:c88c3b616c00 107 *
IKobayashi 0:c88c3b616c00 108 * @Note: In the failure case (where the destination isn't set), the value
IKobayashi 0:c88c3b616c00 109 * pointed to by expectedCurrentValue is still updated with the current value.
IKobayashi 0:c88c3b616c00 110 * This property helps writing concise code for the following incr:
IKobayashi 0:c88c3b616c00 111 *
IKobayashi 0:c88c3b616c00 112 * function incr(p : pointer to int, a : int) returns int {
IKobayashi 0:c88c3b616c00 113 * done = false
IKobayashi 0:c88c3b616c00 114 * value = *p // This fetch operation need not be atomic.
IKobayashi 0:c88c3b616c00 115 * while not done {
IKobayashi 0:c88c3b616c00 116 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
IKobayashi 0:c88c3b616c00 117 * }
IKobayashi 0:c88c3b616c00 118 * return value + a
IKobayashi 0:c88c3b616c00 119 * }
IKobayashi 0:c88c3b616c00 120 */
IKobayashi 0:c88c3b616c00 121 bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue);
IKobayashi 0:c88c3b616c00 122
IKobayashi 0:c88c3b616c00 123 /**
IKobayashi 0:c88c3b616c00 124 * Atomic compare and set. It compares the contents of a memory location to a
IKobayashi 0:c88c3b616c00 125 * given value and, only if they are the same, modifies the contents of that
IKobayashi 0:c88c3b616c00 126 * memory location to a given new value. This is done as a single atomic
IKobayashi 0:c88c3b616c00 127 * operation. The atomicity guarantees that the new value is calculated based on
IKobayashi 0:c88c3b616c00 128 * up-to-date information; if the value had been updated by another thread in
IKobayashi 0:c88c3b616c00 129 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
IKobayashi 0:c88c3b616c00 130 *
IKobayashi 0:c88c3b616c00 131 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
IKobayashi 0:c88c3b616c00 132 * you to the article on compare-and swap].
IKobayashi 0:c88c3b616c00 133 *
IKobayashi 0:c88c3b616c00 134 * @param ptr The target memory location.
IKobayashi 0:c88c3b616c00 135 * @param[in,out] expectedCurrentValue A pointer to some location holding the
IKobayashi 0:c88c3b616c00 136 * expected current value of the data being set atomically.
IKobayashi 0:c88c3b616c00 137 * The computed 'desiredValue' should be a function of this current value.
IKobayashi 0:c88c3b616c00 138 * @Note: This is an in-out parameter. In the
IKobayashi 0:c88c3b616c00 139 * failure case of atomic_cas (where the
IKobayashi 0:c88c3b616c00 140 * destination isn't set), the pointee of expectedCurrentValue is
IKobayashi 0:c88c3b616c00 141 * updated with the current value.
IKobayashi 0:c88c3b616c00 142 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
IKobayashi 0:c88c3b616c00 143 *
IKobayashi 0:c88c3b616c00 144 * @return true if the memory location was atomically
IKobayashi 0:c88c3b616c00 145 * updated with the desired value (after verifying
IKobayashi 0:c88c3b616c00 146 * that it contained the expectedCurrentValue),
IKobayashi 0:c88c3b616c00 147 * false otherwise. In the failure case,
IKobayashi 0:c88c3b616c00 148 * exepctedCurrentValue is updated with the new
IKobayashi 0:c88c3b616c00 149 * value of the target memory location.
IKobayashi 0:c88c3b616c00 150 *
IKobayashi 0:c88c3b616c00 151 * pseudocode:
IKobayashi 0:c88c3b616c00 152 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
IKobayashi 0:c88c3b616c00 153 * if *p != *old {
IKobayashi 0:c88c3b616c00 154 * *old = *p
IKobayashi 0:c88c3b616c00 155 * return false
IKobayashi 0:c88c3b616c00 156 * }
IKobayashi 0:c88c3b616c00 157 * *p = new
IKobayashi 0:c88c3b616c00 158 * return true
IKobayashi 0:c88c3b616c00 159 * }
IKobayashi 0:c88c3b616c00 160 *
IKobayashi 0:c88c3b616c00 161 * @Note: In the failure case (where the destination isn't set), the value
IKobayashi 0:c88c3b616c00 162 * pointed to by expectedCurrentValue is still updated with the current value.
IKobayashi 0:c88c3b616c00 163 * This property helps writing concise code for the following incr:
IKobayashi 0:c88c3b616c00 164 *
IKobayashi 0:c88c3b616c00 165 * function incr(p : pointer to int, a : int) returns int {
IKobayashi 0:c88c3b616c00 166 * done = false
IKobayashi 0:c88c3b616c00 167 * value = *p // This fetch operation need not be atomic.
IKobayashi 0:c88c3b616c00 168 * while not done {
IKobayashi 0:c88c3b616c00 169 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
IKobayashi 0:c88c3b616c00 170 * }
IKobayashi 0:c88c3b616c00 171 * return value + a
IKobayashi 0:c88c3b616c00 172 * }
IKobayashi 0:c88c3b616c00 173 */
IKobayashi 0:c88c3b616c00 174 bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue);
IKobayashi 0:c88c3b616c00 175
IKobayashi 0:c88c3b616c00 176 /**
IKobayashi 0:c88c3b616c00 177 * Atomic compare and set. It compares the contents of a memory location to a
IKobayashi 0:c88c3b616c00 178 * given value and, only if they are the same, modifies the contents of that
IKobayashi 0:c88c3b616c00 179 * memory location to a given new value. This is done as a single atomic
IKobayashi 0:c88c3b616c00 180 * operation. The atomicity guarantees that the new value is calculated based on
IKobayashi 0:c88c3b616c00 181 * up-to-date information; if the value had been updated by another thread in
IKobayashi 0:c88c3b616c00 182 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
IKobayashi 0:c88c3b616c00 183 *
IKobayashi 0:c88c3b616c00 184 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
IKobayashi 0:c88c3b616c00 185 * you to the article on compare-and swap].
IKobayashi 0:c88c3b616c00 186 *
IKobayashi 0:c88c3b616c00 187 * @param ptr The target memory location.
IKobayashi 0:c88c3b616c00 188 * @param[in,out] expectedCurrentValue A pointer to some location holding the
IKobayashi 0:c88c3b616c00 189 * expected current value of the data being set atomically.
IKobayashi 0:c88c3b616c00 190 * The computed 'desiredValue' should be a function of this current value.
IKobayashi 0:c88c3b616c00 191 * @Note: This is an in-out parameter. In the
IKobayashi 0:c88c3b616c00 192 * failure case of atomic_cas (where the
IKobayashi 0:c88c3b616c00 193 * destination isn't set), the pointee of expectedCurrentValue is
IKobayashi 0:c88c3b616c00 194 * updated with the current value.
IKobayashi 0:c88c3b616c00 195 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
IKobayashi 0:c88c3b616c00 196 *
IKobayashi 0:c88c3b616c00 197 * @return true if the memory location was atomically
IKobayashi 0:c88c3b616c00 198 * updated with the desired value (after verifying
IKobayashi 0:c88c3b616c00 199 * that it contained the expectedCurrentValue),
IKobayashi 0:c88c3b616c00 200 * false otherwise. In the failure case,
IKobayashi 0:c88c3b616c00 201 * exepctedCurrentValue is updated with the new
IKobayashi 0:c88c3b616c00 202 * value of the target memory location.
IKobayashi 0:c88c3b616c00 203 *
IKobayashi 0:c88c3b616c00 204 * pseudocode:
IKobayashi 0:c88c3b616c00 205 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
IKobayashi 0:c88c3b616c00 206 * if *p != *old {
IKobayashi 0:c88c3b616c00 207 * *old = *p
IKobayashi 0:c88c3b616c00 208 * return false
IKobayashi 0:c88c3b616c00 209 * }
IKobayashi 0:c88c3b616c00 210 * *p = new
IKobayashi 0:c88c3b616c00 211 * return true
IKobayashi 0:c88c3b616c00 212 * }
IKobayashi 0:c88c3b616c00 213 *
IKobayashi 0:c88c3b616c00 214 * @Note: In the failure case (where the destination isn't set), the value
IKobayashi 0:c88c3b616c00 215 * pointed to by expectedCurrentValue is still updated with the current value.
IKobayashi 0:c88c3b616c00 216 * This property helps writing concise code for the following incr:
IKobayashi 0:c88c3b616c00 217 *
IKobayashi 0:c88c3b616c00 218 * function incr(p : pointer to int, a : int) returns int {
IKobayashi 0:c88c3b616c00 219 * done = false
IKobayashi 0:c88c3b616c00 220 * value = *p // This fetch operation need not be atomic.
IKobayashi 0:c88c3b616c00 221 * while not done {
IKobayashi 0:c88c3b616c00 222 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
IKobayashi 0:c88c3b616c00 223 * }
IKobayashi 0:c88c3b616c00 224 * return value + a
IKobayashi 0:c88c3b616c00 225 * }
IKobayashi 0:c88c3b616c00 226 */
IKobayashi 0:c88c3b616c00 227 bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue);
IKobayashi 0:c88c3b616c00 228
IKobayashi 0:c88c3b616c00 229 /**
IKobayashi 0:c88c3b616c00 230 * Atomic compare and set. It compares the contents of a memory location to a
IKobayashi 0:c88c3b616c00 231 * given value and, only if they are the same, modifies the contents of that
IKobayashi 0:c88c3b616c00 232 * memory location to a given new value. This is done as a single atomic
IKobayashi 0:c88c3b616c00 233 * operation. The atomicity guarantees that the new value is calculated based on
IKobayashi 0:c88c3b616c00 234 * up-to-date information; if the value had been updated by another thread in
IKobayashi 0:c88c3b616c00 235 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
IKobayashi 0:c88c3b616c00 236 *
IKobayashi 0:c88c3b616c00 237 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
IKobayashi 0:c88c3b616c00 238 * you to the article on compare-and swap].
IKobayashi 0:c88c3b616c00 239 *
IKobayashi 0:c88c3b616c00 240 * @param ptr The target memory location.
IKobayashi 0:c88c3b616c00 241 * @param[in,out] expectedCurrentValue A pointer to some location holding the
IKobayashi 0:c88c3b616c00 242 * expected current value of the data being set atomically.
IKobayashi 0:c88c3b616c00 243 * The computed 'desiredValue' should be a function of this current value.
IKobayashi 0:c88c3b616c00 244 * @Note: This is an in-out parameter. In the
IKobayashi 0:c88c3b616c00 245 * failure case of atomic_cas (where the
IKobayashi 0:c88c3b616c00 246 * destination isn't set), the pointee of expectedCurrentValue is
IKobayashi 0:c88c3b616c00 247 * updated with the current value.
IKobayashi 0:c88c3b616c00 248 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
IKobayashi 0:c88c3b616c00 249 *
IKobayashi 0:c88c3b616c00 250 * @return true if the memory location was atomically
IKobayashi 0:c88c3b616c00 251 * updated with the desired value (after verifying
IKobayashi 0:c88c3b616c00 252 * that it contained the expectedCurrentValue),
IKobayashi 0:c88c3b616c00 253 * false otherwise. In the failure case,
IKobayashi 0:c88c3b616c00 254 * exepctedCurrentValue is updated with the new
IKobayashi 0:c88c3b616c00 255 * value of the target memory location.
IKobayashi 0:c88c3b616c00 256 *
IKobayashi 0:c88c3b616c00 257 * pseudocode:
IKobayashi 0:c88c3b616c00 258 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
IKobayashi 0:c88c3b616c00 259 * if *p != *old {
IKobayashi 0:c88c3b616c00 260 * *old = *p
IKobayashi 0:c88c3b616c00 261 * return false
IKobayashi 0:c88c3b616c00 262 * }
IKobayashi 0:c88c3b616c00 263 * *p = new
IKobayashi 0:c88c3b616c00 264 * return true
IKobayashi 0:c88c3b616c00 265 * }
IKobayashi 0:c88c3b616c00 266 *
IKobayashi 0:c88c3b616c00 267 * @Note: In the failure case (where the destination isn't set), the value
IKobayashi 0:c88c3b616c00 268 * pointed to by expectedCurrentValue is still updated with the current value.
IKobayashi 0:c88c3b616c00 269 * This property helps writing concise code for the following incr:
IKobayashi 0:c88c3b616c00 270 *
IKobayashi 0:c88c3b616c00 271 * function incr(p : pointer to int, a : int) returns int {
IKobayashi 0:c88c3b616c00 272 * done = false
IKobayashi 0:c88c3b616c00 273 * value = *p // This fetch operation need not be atomic.
IKobayashi 0:c88c3b616c00 274 * while not done {
IKobayashi 0:c88c3b616c00 275 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
IKobayashi 0:c88c3b616c00 276 * }
IKobayashi 0:c88c3b616c00 277 * return value + a
IKobayashi 0:c88c3b616c00 278 * }
IKobayashi 0:c88c3b616c00 279 */
IKobayashi 0:c88c3b616c00 280 bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue);
IKobayashi 0:c88c3b616c00 281
IKobayashi 0:c88c3b616c00 282 /**
IKobayashi 0:c88c3b616c00 283 * Atomic increment.
IKobayashi 0:c88c3b616c00 284 * @param valuePtr Target memory location being incremented.
IKobayashi 0:c88c3b616c00 285 * @param delta The amount being incremented.
IKobayashi 0:c88c3b616c00 286 * @return The new incremented value.
IKobayashi 0:c88c3b616c00 287 */
IKobayashi 0:c88c3b616c00 288 uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta);
IKobayashi 0:c88c3b616c00 289
IKobayashi 0:c88c3b616c00 290 /**
IKobayashi 0:c88c3b616c00 291 * Atomic increment.
IKobayashi 0:c88c3b616c00 292 * @param valuePtr Target memory location being incremented.
IKobayashi 0:c88c3b616c00 293 * @param delta The amount being incremented.
IKobayashi 0:c88c3b616c00 294 * @return The new incremented value.
IKobayashi 0:c88c3b616c00 295 */
IKobayashi 0:c88c3b616c00 296 uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta);
IKobayashi 0:c88c3b616c00 297
IKobayashi 0:c88c3b616c00 298 /**
IKobayashi 0:c88c3b616c00 299 * Atomic increment.
IKobayashi 0:c88c3b616c00 300 * @param valuePtr Target memory location being incremented.
IKobayashi 0:c88c3b616c00 301 * @param delta The amount being incremented.
IKobayashi 0:c88c3b616c00 302 * @return The new incremented value.
IKobayashi 0:c88c3b616c00 303 */
IKobayashi 0:c88c3b616c00 304 uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta);
IKobayashi 0:c88c3b616c00 305
IKobayashi 0:c88c3b616c00 306 /**
IKobayashi 0:c88c3b616c00 307 * Atomic increment.
IKobayashi 0:c88c3b616c00 308 * @param valuePtr Target memory location being incremented.
IKobayashi 0:c88c3b616c00 309 * @param delta The amount being incremented in bytes.
IKobayashi 0:c88c3b616c00 310 * @return The new incremented value.
IKobayashi 0:c88c3b616c00 311 *
IKobayashi 0:c88c3b616c00 312 * @note The type of the pointer argument is not taken into account
IKobayashi 0:c88c3b616c00 313 * and the pointer is incremented by bytes.
IKobayashi 0:c88c3b616c00 314 */
IKobayashi 0:c88c3b616c00 315 void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta);
IKobayashi 0:c88c3b616c00 316
IKobayashi 0:c88c3b616c00 317 /**
IKobayashi 0:c88c3b616c00 318 * Atomic decrement.
IKobayashi 0:c88c3b616c00 319 * @param valuePtr Target memory location being decremented.
IKobayashi 0:c88c3b616c00 320 * @param delta The amount being decremented.
IKobayashi 0:c88c3b616c00 321 * @return The new decremented value.
IKobayashi 0:c88c3b616c00 322 */
IKobayashi 0:c88c3b616c00 323 uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta);
IKobayashi 0:c88c3b616c00 324
IKobayashi 0:c88c3b616c00 325 /**
IKobayashi 0:c88c3b616c00 326 * Atomic decrement.
IKobayashi 0:c88c3b616c00 327 * @param valuePtr Target memory location being decremented.
IKobayashi 0:c88c3b616c00 328 * @param delta The amount being decremented.
IKobayashi 0:c88c3b616c00 329 * @return The new decremented value.
IKobayashi 0:c88c3b616c00 330 */
IKobayashi 0:c88c3b616c00 331 uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta);
IKobayashi 0:c88c3b616c00 332
IKobayashi 0:c88c3b616c00 333 /**
IKobayashi 0:c88c3b616c00 334 * Atomic decrement.
IKobayashi 0:c88c3b616c00 335 * @param valuePtr Target memory location being decremented.
IKobayashi 0:c88c3b616c00 336 * @param delta The amount being decremented.
IKobayashi 0:c88c3b616c00 337 * @return The new decremented value.
IKobayashi 0:c88c3b616c00 338 */
IKobayashi 0:c88c3b616c00 339 uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta);
IKobayashi 0:c88c3b616c00 340
IKobayashi 0:c88c3b616c00 341 /**
IKobayashi 0:c88c3b616c00 342 * Atomic decrement.
IKobayashi 0:c88c3b616c00 343 * @param valuePtr Target memory location being decremented.
IKobayashi 0:c88c3b616c00 344 * @param delta The amount being decremented in bytes.
IKobayashi 0:c88c3b616c00 345 * @return The new decremented value.
IKobayashi 0:c88c3b616c00 346 *
IKobayashi 0:c88c3b616c00 347 * @note The type of the pointer argument is not taken into account
IKobayashi 0:c88c3b616c00 348 * and the pointer is decremented by bytes
IKobayashi 0:c88c3b616c00 349 */
IKobayashi 0:c88c3b616c00 350 void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta);
IKobayashi 0:c88c3b616c00 351
IKobayashi 0:c88c3b616c00 352 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 353 } // extern "C"
IKobayashi 0:c88c3b616c00 354 #endif
IKobayashi 0:c88c3b616c00 355
IKobayashi 0:c88c3b616c00 356
IKobayashi 0:c88c3b616c00 357 #endif // __MBED_UTIL_CRITICAL_H__
IKobayashi 0:c88c3b616c00 358
IKobayashi 0:c88c3b616c00 359 /** @}*/