-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8330c32
commit 999b292
Showing
12 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "concurrency/BinarySemaphoreFreeRTOS.h" | ||
#include "configuration.h" | ||
|
||
#ifdef HAS_FREE_RTOS | ||
|
||
namespace concurrency | ||
{ | ||
|
||
BinarySemaphoreFreeRTOS::BinarySemaphoreFreeRTOS() | ||
{ | ||
semaphore = xSemaphoreCreateBinary(); | ||
} | ||
|
||
BinarySemaphoreFreeRTOS::~BinarySemaphoreFreeRTOS() | ||
{ | ||
vSemaphoreDelete(semaphore); | ||
} | ||
|
||
/** | ||
* Returns false if we were interrupted | ||
*/ | ||
bool BinarySemaphoreFreeRTOS::take(uint32_t msec) | ||
{ | ||
return xSemaphoreTake(semaphore, pdMS_TO_TICKS(msec)); | ||
} | ||
|
||
void BinarySemaphoreFreeRTOS::give() | ||
{ | ||
xSemaphoreGive(semaphore); | ||
} | ||
|
||
IRAM_ATTR void BinarySemaphoreFreeRTOS::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) | ||
{ | ||
xSemaphoreGiveFromISR(semaphore, pxHigherPriorityTaskWoken); | ||
} | ||
|
||
} // namespace concurrency | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "configuration.h" | ||
#include "../freertosinc.h" | ||
|
||
namespace concurrency | ||
{ | ||
|
||
#ifdef HAS_FREE_RTOS | ||
|
||
class BinarySemaphoreFreeRTOS | ||
{ | ||
SemaphoreHandle_t semaphore; | ||
|
||
public: | ||
BinarySemaphoreFreeRTOS(); | ||
~BinarySemaphoreFreeRTOS(); | ||
|
||
/** | ||
* Returns false if we timed out | ||
*/ | ||
bool take(uint32_t msec); | ||
|
||
void give(); | ||
|
||
void giveFromISR(BaseType_t *pxHigherPriorityTaskWoken); | ||
}; | ||
|
||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "concurrency/BinarySemaphorePosix.h" | ||
#include "configuration.h" | ||
|
||
#ifndef HAS_FREE_RTOS | ||
|
||
namespace concurrency | ||
{ | ||
|
||
BinarySemaphorePosix::BinarySemaphorePosix() | ||
{ | ||
} | ||
|
||
BinarySemaphorePosix::~BinarySemaphorePosix() | ||
{ | ||
} | ||
|
||
/** | ||
* Returns false if we timed out | ||
*/ | ||
bool BinarySemaphorePosix::take(uint32_t msec) | ||
{ | ||
delay(msec); // FIXME | ||
return false; | ||
} | ||
|
||
void BinarySemaphorePosix::give() | ||
{ | ||
} | ||
|
||
IRAM_ATTR void BinarySemaphorePosix::giveFromISR(BaseType_t *pxHigherPriorityTaskWoken) | ||
{ | ||
} | ||
|
||
} // namespace concurrency | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "configuration.h" | ||
#include "../freertosinc.h" | ||
|
||
namespace concurrency | ||
{ | ||
|
||
#ifndef HAS_FREE_RTOS | ||
|
||
class BinarySemaphorePosix | ||
{ | ||
// SemaphoreHandle_t semaphore; | ||
|
||
public: | ||
BinarySemaphorePosix(); | ||
~BinarySemaphorePosix(); | ||
|
||
/** | ||
* Returns false if we timed out | ||
*/ | ||
bool take(uint32_t msec); | ||
|
||
void give(); | ||
|
||
void giveFromISR(BaseType_t *pxHigherPriorityTaskWoken); | ||
}; | ||
|
||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters