james kain / Mbed 2 deprecated GPS_Incremental

Dependencies:   mbed

Fork of GPS_Incremental by Dan Matthews

mbed-rtos/rtos/Semaphore.cpp

Committer:
dannyman939
Date:
2013-03-19
Revision:
0:c746ee34feae

File content as of revision 0:c746ee34feae:

#include "Semaphore.h"

#include <string.h>
#include "error.h"

namespace rtos {

Semaphore::Semaphore(int32_t count) {
#ifdef CMSIS_OS_RTX
    memset(_semaphore_data, 0, sizeof(_semaphore_data));
    _osSemaphoreDef.semaphore = _semaphore_data;
#endif
    _osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
}

int32_t Semaphore::wait(uint32_t millisec) {
    return osSemaphoreWait(_osSemaphoreId, millisec);
}

osStatus Semaphore::release(void) {
    return osSemaphoreRelease(_osSemaphoreId);
}

Semaphore::~Semaphore() {
    osSemaphoreDelete(_osSemaphoreId);
}

}