Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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