tarask
6 days ago 532005c6573d95199ce0ffbc33df4c7a0a4c3ef9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "Mutex.h"
Mutex::Mutex()
{
    m_pMutex=xSemaphoreCreateMutex();
}
void Mutex::Lock()
{
    do {} while (xSemaphoreTake(m_pMutex, portMAX_DELAY)!= pdPASS);
}
void Mutex::Unlock()
{
    xSemaphoreGive(m_pMutex);
}
bool Mutex::isLock(TickType_t time)
{
    if ( xSemaphoreTake( m_pMutex, time) == pdTRUE )
    {
        xSemaphoreGive(m_pMutex);
        return false;
    }
    else
    {
        return true;    
    }
}