1 /* 2 * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Lockzhiner 18 * 19 * @file mutex.h 20 */ 21 22 #ifndef LZ_HARDWARE_MUTEX_H 23 #define LZ_HARDWARE_MUTEX_H 24 25 typedef struct _ToyMutex { 26 unsigned int muxHandle; 27 } ToyMutex; 28 29 /** 30 * @par Description: 31 * This API is used to initialize the mutex. 32 * Return LZ_HARDWARE_SUCCESS on creating successful, return specific error code otherwise. 33 * 34 * @param mutex the mutex to be initialized 35 * 36 */ 37 unsigned int ToyMutexInit(ToyMutex *lock); 38 39 /** 40 * @par Description: 41 * This API is used to destroy the mutex. 42 * Return LZ_HARDWARE_SUCCESS on destroying successful, return specific error code otherwise. 43 * 44 * @param mutex the mutex to be destroied 45 * 46 */ 47 unsigned int ToyMutexDestroy(ToyMutex *lock); 48 49 /** 50 * @par Description: 51 * This API is used to lock the mutex. 52 * Return LZ_HARDWARE_SUCCESS on destroying successful, return specific error code otherwise. 53 * 54 * @param mutex the mutex to be locked 55 * 56 */ 57 unsigned int ToyMutexLock(ToyMutex *lock); 58 59 /** 60 * @par Description: 61 * This API is used to try to lock the mutex. 62 * Return LZ_HARDWARE_SUCCESS on locking successful, return specific error code otherwise. 63 * 64 * @param mutex the mutex to be locked 65 * 66 */ 67 unsigned int ToyMutexTryLock(ToyMutex *lock); 68 69 /** 70 * @par Description: 71 * This API is used to unlock the mutex. 72 * Return LZ_HARDWARE_SUCCESS on unlocking successful, return specific error code otherwise. 73 * 74 * @param mutex the mutex to be unlocked 75 * 76 */ 77 unsigned int ToyMutexUnlock(ToyMutex *lock); 78 79 #endif 80 81