retval fix, unittest running again
This commit is contained in:
@ -9,7 +9,6 @@ BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() {
|
||||
"constructor was called inside a task." << std::endl;
|
||||
}
|
||||
xTaskNotifyGive(handle);
|
||||
locked = false;
|
||||
}
|
||||
|
||||
BinarySemaphoreUsingTask::~BinarySemaphoreUsingTask() {
|
||||
@ -32,7 +31,6 @@ ReturnValue_t BinarySemaphoreUsingTask::acquireWithTickTimeout(
|
||||
TickType_t timeoutTicks) {
|
||||
BaseType_t returncode = ulTaskNotifyTake(pdTRUE, timeoutTicks);
|
||||
if (returncode == pdPASS) {
|
||||
locked = true;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
@ -41,43 +39,14 @@ ReturnValue_t BinarySemaphoreUsingTask::acquireWithTickTimeout(
|
||||
}
|
||||
|
||||
ReturnValue_t BinarySemaphoreUsingTask::release() {
|
||||
if(not locked) {
|
||||
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
|
||||
}
|
||||
BaseType_t returncode = xTaskNotifyGive(handle);
|
||||
if (returncode == pdPASS) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
// This should never happen
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
TaskHandle_t BinarySemaphoreUsingTask::getTaskHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
uint8_t BinarySemaphoreUsingTask::getSemaphoreCounter() const {
|
||||
uint32_t notificationValue;
|
||||
xTaskNotifyAndQuery(handle, 0, eNoAction, ¬ificationValue);
|
||||
return notificationValue;
|
||||
}
|
||||
|
||||
|
||||
uint8_t BinarySemaphoreUsingTask::getSemaphoreCounterFromISR(
|
||||
TaskHandle_t taskHandle) {
|
||||
uint32_t notificationValue;
|
||||
BaseType_t higherPriorityTaskWoken;
|
||||
xTaskNotifyAndQueryFromISR(taskHandle, 0, eNoAction, ¬ificationValue,
|
||||
&higherPriorityTaskWoken);
|
||||
if(higherPriorityTaskWoken) {
|
||||
TaskManagement::requestContextSwitch(CallContext::isr);
|
||||
}
|
||||
return notificationValue;
|
||||
return release(this->handle);
|
||||
}
|
||||
|
||||
ReturnValue_t BinarySemaphoreUsingTask::release(
|
||||
TaskHandle_t taskHandle) {
|
||||
if(getSemaphoreCounter(taskHandle) == 1) {
|
||||
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
|
||||
}
|
||||
BaseType_t returncode = xTaskNotifyGive(taskHandle);
|
||||
if (returncode == pdPASS) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -88,14 +57,36 @@ ReturnValue_t BinarySemaphoreUsingTask::release(
|
||||
}
|
||||
}
|
||||
|
||||
TaskHandle_t BinarySemaphoreUsingTask::getTaskHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
uint8_t BinarySemaphoreUsingTask::getSemaphoreCounter() const {
|
||||
return getSemaphoreCounter(this->handle);
|
||||
}
|
||||
|
||||
uint8_t BinarySemaphoreUsingTask::getSemaphoreCounter(
|
||||
TaskHandle_t taskHandle) {
|
||||
uint32_t notificationValue;
|
||||
xTaskNotifyAndQuery(taskHandle, 0, eNoAction, ¬ificationValue);
|
||||
return notificationValue;
|
||||
}
|
||||
|
||||
// Be careful with the stack size here. This is called from an ISR!
|
||||
ReturnValue_t BinarySemaphoreUsingTask::releaseFromISR(
|
||||
TaskHandle_t taskHandle, BaseType_t * higherPriorityTaskWoken) {
|
||||
vTaskNotifyGiveFromISR(taskHandle, higherPriorityTaskWoken);
|
||||
if(*higherPriorityTaskWoken == pdPASS) {
|
||||
// Request context switch because unblocking the semaphore
|
||||
// caused a high priority task unblock.
|
||||
TaskManagement::requestContextSwitch(CallContext::isr);
|
||||
if(getSemaphoreCounterFromISR(taskHandle) == 1) {
|
||||
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
|
||||
}
|
||||
vTaskNotifyGiveFromISR(taskHandle, higherPriorityTaskWoken);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint8_t BinarySemaphoreUsingTask::getSemaphoreCounterFromISR(
|
||||
TaskHandle_t taskHandle) {
|
||||
uint32_t notificationValue;
|
||||
BaseType_t higherPriorityTaskWoken;
|
||||
xTaskNotifyAndQueryFromISR(taskHandle, 0, eNoAction, ¬ificationValue,
|
||||
&higherPriorityTaskWoken);
|
||||
return notificationValue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user