MCU driver/HAL for the Picocell Gateway concentrator board. The firmware implements either a USB CDC protocol or a UART protocol to bridge commands coming from host to the SX1308 SPI interface.

Committer:
dgabino
Date:
Wed Apr 11 14:42:47 2018 +0000
Revision:
0:c76361bd82e8
Initial commit

Who changed what in which revision?

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