Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

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