The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 167:84c0a372a020 1 /**
AnnaBridge 167:84c0a372a020 2 * @file
AnnaBridge 167:84c0a372a020 3 * @brief Exclusive access lock utility functions.
AnnaBridge 167:84c0a372a020 4 */
AnnaBridge 167:84c0a372a020 5 /* ****************************************************************************
AnnaBridge 167:84c0a372a020 6 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
AnnaBridge 167:84c0a372a020 7 *
AnnaBridge 167:84c0a372a020 8 * Permission is hereby granted, free of charge, to any person obtaining a
AnnaBridge 167:84c0a372a020 9 * copy of this software and associated documentation files (the "Software"),
AnnaBridge 167:84c0a372a020 10 * to deal in the Software without restriction, including without limitation
AnnaBridge 167:84c0a372a020 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
AnnaBridge 167:84c0a372a020 12 * and/or sell copies of the Software, and to permit persons to whom the
AnnaBridge 167:84c0a372a020 13 * Software is furnished to do so, subject to the following conditions:
AnnaBridge 167:84c0a372a020 14 *
AnnaBridge 167:84c0a372a020 15 * The above copyright notice and this permission notice shall be included
AnnaBridge 167:84c0a372a020 16 * in all copies or substantial portions of the Software.
AnnaBridge 167:84c0a372a020 17 *
AnnaBridge 167:84c0a372a020 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
AnnaBridge 167:84c0a372a020 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
AnnaBridge 167:84c0a372a020 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
AnnaBridge 167:84c0a372a020 21 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
AnnaBridge 167:84c0a372a020 22 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
AnnaBridge 167:84c0a372a020 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
AnnaBridge 167:84c0a372a020 24 * OTHER DEALINGS IN THE SOFTWARE.
AnnaBridge 167:84c0a372a020 25 *
AnnaBridge 167:84c0a372a020 26 * Except as contained in this notice, the name of Maxim Integrated
AnnaBridge 167:84c0a372a020 27 * Products, Inc. shall not be used except as stated in the Maxim Integrated
AnnaBridge 167:84c0a372a020 28 * Products, Inc. Branding Policy.
AnnaBridge 167:84c0a372a020 29 *
AnnaBridge 167:84c0a372a020 30 * The mere transfer of this software does not imply any licenses
AnnaBridge 167:84c0a372a020 31 * of trade secrets, proprietary technology, copyrights, patents,
AnnaBridge 167:84c0a372a020 32 * trademarks, maskwork rights, or any other form of intellectual
AnnaBridge 167:84c0a372a020 33 * property whatsoever. Maxim Integrated Products, Inc. retains all
AnnaBridge 167:84c0a372a020 34 * ownership rights.
AnnaBridge 167:84c0a372a020 35 *
AnnaBridge 167:84c0a372a020 36 * $Date: 2017-02-27 14:38:42 -0600 (Mon, 27 Feb 2017) $
AnnaBridge 167:84c0a372a020 37 * $Revision: 26655 $
AnnaBridge 167:84c0a372a020 38 *
AnnaBridge 167:84c0a372a020 39 *************************************************************************** */
AnnaBridge 167:84c0a372a020 40
AnnaBridge 167:84c0a372a020 41 /* Define to prevent redundant inclusion */
AnnaBridge 167:84c0a372a020 42 #ifndef _MXC_LOCK_H_
AnnaBridge 167:84c0a372a020 43 #define _MXC_LOCK_H_
AnnaBridge 167:84c0a372a020 44
AnnaBridge 167:84c0a372a020 45 /* **** Includes **** */
AnnaBridge 167:84c0a372a020 46 #include "mxc_config.h"
AnnaBridge 167:84c0a372a020 47
AnnaBridge 167:84c0a372a020 48 #ifdef __cplusplus
AnnaBridge 167:84c0a372a020 49 extern "C" {
AnnaBridge 167:84c0a372a020 50 #endif
AnnaBridge 167:84c0a372a020 51
AnnaBridge 167:84c0a372a020 52 /**
AnnaBridge 167:84c0a372a020 53 * @ingroup syscfg
AnnaBridge 167:84c0a372a020 54 * @defgroup mxc_lock_utilities Exclusive Access Locks
AnnaBridge 167:84c0a372a020 55 * @brief Lock functions to obtain and release a variable for exclusive
AnnaBridge 167:84c0a372a020 56 * access. These functions are marked interrupt safe if they are
AnnaBridge 167:84c0a372a020 57 * interrupt safe.
AnnaBridge 167:84c0a372a020 58 * @{
AnnaBridge 167:84c0a372a020 59 */
AnnaBridge 167:84c0a372a020 60
AnnaBridge 167:84c0a372a020 61 /* **** Definitions **** */
AnnaBridge 167:84c0a372a020 62
AnnaBridge 167:84c0a372a020 63 /* **** Globals **** */
AnnaBridge 167:84c0a372a020 64
AnnaBridge 167:84c0a372a020 65 /* **** Function Prototypes **** */
AnnaBridge 167:84c0a372a020 66
AnnaBridge 167:84c0a372a020 67 /**
AnnaBridge 167:84c0a372a020 68 * @brief Attempts to acquire the lock.
AnnaBridge 167:84c0a372a020 69 * @details This in an interrupt safe function that can be used as a mutex.
AnnaBridge 167:84c0a372a020 70 * The lock variable must remain in scope until the lock is
AnnaBridge 167:84c0a372a020 71 * released. Will not block if another thread has already acquired
AnnaBridge 167:84c0a372a020 72 * the lock.
AnnaBridge 167:84c0a372a020 73 * @param lock Pointer to variable that is used for the lock.
AnnaBridge 167:84c0a372a020 74 * @param value Value to be place in the lock. Can not be 0.
AnnaBridge 167:84c0a372a020 75 *
AnnaBridge 167:84c0a372a020 76 * @return #E_NO_ERROR if everything successful, #E_BUSY if lock is taken.
AnnaBridge 167:84c0a372a020 77 */
AnnaBridge 167:84c0a372a020 78 int mxc_get_lock(uint32_t *lock, uint32_t value);
AnnaBridge 167:84c0a372a020 79
AnnaBridge 167:84c0a372a020 80 /**
AnnaBridge 167:84c0a372a020 81 * @brief Free the given lock.
AnnaBridge 167:84c0a372a020 82 * @param[in,out] lock Pointer to the variable used for the lock. When the lock
AnnaBridge 167:84c0a372a020 83 * is free, the value pointed to by @p lock is set to zero.
AnnaBridge 167:84c0a372a020 84 */
AnnaBridge 167:84c0a372a020 85 void mxc_free_lock(uint32_t *lock);
AnnaBridge 167:84c0a372a020 86
AnnaBridge 167:84c0a372a020 87 /**@} end of group mxc_lock_utilities */
AnnaBridge 167:84c0a372a020 88
AnnaBridge 167:84c0a372a020 89 #ifdef __cplusplus
AnnaBridge 167:84c0a372a020 90 }
AnnaBridge 167:84c0a372a020 91 #endif
AnnaBridge 167:84c0a372a020 92
AnnaBridge 167:84c0a372a020 93 #endif /* _MXC_LOCK_H_ */