This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cMutex.h Source File

NyLPC_cMutex.h

00001 /*********************************************************************************
00002  * PROJECT: MiMic
00003  * --------------------------------------------------------------------------------
00004  *
00005  * This file is part of MiMic
00006  * Copyright (C)2011 Ryo Iizuka
00007  *
00008  * MiMic is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * For further information please contact.
00022  *  http://nyatla.jp/
00023  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
00024  *
00025  *********************************************************************************/
00026 #ifndef NYLPC_CMUTEX_H_
00027 #define NYLPC_CMUTEX_H_
00028 ////////////////////////////////////////////////////////////////////////////////
00029 // Include
00030 ////////////////////////////////////////////////////////////////////////////////
00031 #include "NyLPC_stdlib.h"
00032 #if NyLPC_ARCH==NyLPC_ARCH_FREERTOS
00033 #include "FreeRTOS.h"
00034 #include "queue.h"
00035 #include "semphr.h"
00036 #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS
00037 #elif NyLPC_ARCH==NyLPC_ARCH_WIN32
00038     //not implemented!
00039 #else
00040 #error Bad NyLPC_ARCH!
00041 #endif
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif /* __cplusplus */
00046 
00047 /**********************************************************************
00048  *
00049  * NyLPC_TcMutex class
00050  *
00051  **********************************************************************/
00052 typedef struct NyLPC_TcMutex NyLPC_TcMutex_t;
00053 
00054 #if NyLPC_ARCH==NyLPC_ARCH_FREERTOS
00055 
00056 struct NyLPC_TcMutex
00057 {
00058     xQueueHandle _mutex;
00059     NyLPC_TUInt8 _lock_count;
00060 };
00061 #elif NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS
00062 struct NyLPC_TcMutex
00063 {
00064     void* _mutex;//rtos::Mutex*
00065     NyLPC_TUInt8 _lock_count;
00066 };
00067 #elif NyLPC_ARCH==NyLPC_ARCH_WIN32
00068 //not work!
00069 struct NyLPC_TcMutex
00070 {
00071     int dummy;
00072 };
00073 #endif
00074 
00075 NyLPC_TBool NyLPC_cMutex_initialize(NyLPC_TcMutex_t* i_inst);
00076 
00077 NyLPC_TBool NyLPC_cMutex_lock(NyLPC_TcMutex_t* i_inst);
00078 
00079 NyLPC_TBool NyLPC_cMutex_unlock(NyLPC_TcMutex_t* i_inst);
00080 
00081 #define NyLPC_cMutex_isLocked(i_inst) ((i_inst)->_lock_count>0)
00082 #define NyLPC_cMutex_finalize(i_inst)
00083 
00084 #ifdef __cplusplus
00085 }
00086 #endif /* __cplusplus */
00087 
00088 #endif /* NYLPC_CMUTEX_H_ */