Edited Version of mbed-rtos so that it actually works.

Dependents:   NervousPuppySprintOne NervousPuppySprint2602

Fork of mbed-rtos by mbed official

Committer:
emilmont
Date:
Fri Nov 23 09:57:31 2012 +0000
Revision:
6:350b53afb889
Child:
8:88a1a9c26ae3
Merge RTOS C++ API and RTX under the same library; Update RTX to version 4.60; Add proper Thread destructor;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 6:350b53afb889 1 #include "Semaphore.h"
emilmont 6:350b53afb889 2
emilmont 6:350b53afb889 3 #include <string.h>
emilmont 6:350b53afb889 4 #include "error.h"
emilmont 6:350b53afb889 5
emilmont 6:350b53afb889 6 namespace rtos {
emilmont 6:350b53afb889 7
emilmont 6:350b53afb889 8 Semaphore::Semaphore(int32_t count) {
emilmont 6:350b53afb889 9 #ifdef CMSIS_OS_RTX
emilmont 6:350b53afb889 10 memset(_semaphore_data, 0, sizeof(_semaphore_data));
emilmont 6:350b53afb889 11 _osSemaphoreDef.semaphore = _semaphore_data;
emilmont 6:350b53afb889 12 #endif
emilmont 6:350b53afb889 13 _osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
emilmont 6:350b53afb889 14 }
emilmont 6:350b53afb889 15
emilmont 6:350b53afb889 16 int32_t Semaphore::wait(uint32_t millisec) {
emilmont 6:350b53afb889 17 return osSemaphoreWait(_osSemaphoreId, millisec);
emilmont 6:350b53afb889 18 }
emilmont 6:350b53afb889 19
emilmont 6:350b53afb889 20 osStatus Semaphore::release(void) {
emilmont 6:350b53afb889 21 return osSemaphoreRelease(_osSemaphoreId);
emilmont 6:350b53afb889 22 }
emilmont 6:350b53afb889 23
emilmont 6:350b53afb889 24 Semaphore::~Semaphore() {
emilmont 6:350b53afb889 25 osSemaphoreDelete(_osSemaphoreId);
emilmont 6:350b53afb889 26 }
emilmont 6:350b53afb889 27
emilmont 6:350b53afb889 28 }