OSDN Git Service

update libMiMic
[mimic/MiMicSDK.git] / lib / src / os / mbedrtos / NyLPC_cSemaphore.cpp
1 /*********************************************************************************
2  * PROJECT: MiMic
3  * --------------------------------------------------------------------------------
4  *
5  * This file is part of MiMic
6  * Copyright (C)2011 Ryo Iizuka
7  *
8  * MiMic is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published
10  * by the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  * For further information please contact.
22  *  http://nyatla.jp/
23  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
24  *
25  *********************************************************************************/
26 #include "../NyLPC_cSemaphore.h"
27
28 #if NyLPC_ARCH==NyLPC_ARCH_MBEDRTOS
29 #include "mbed.h"
30 #include "rtos.h"
31
32 void NyLPC_cSemaphore_initialize(NyLPC_TcSemaphore_t* i_inst)
33 {
34     i_inst->_handle=new Semaphore(1);
35 }
36
37
38 void NyLPC_cSemaphore_giveFromISR(const NyLPC_TcSemaphore_t* i_inst)
39 {
40     //セマフォブロックの解除
41     ((Semaphore*)(i_inst->_handle))->release();
42 }
43 /**
44  * @param i_timeout
45  * タイムアウト時間はms指定
46  */
47 void NyLPC_cSemaphore_take(const NyLPC_TcSemaphore_t* i_inst,NyLPC_TUInt32 i_timeout)
48 {
49     ((Semaphore*)(i_inst->_handle))->wait(i_timeout);
50 }
51 #endif