mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 02:53:33 +08:00
added support for FreeRTOS
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <uavcan_stm32/can.hpp>
|
||||
#include "internal.hpp"
|
||||
|
||||
|
||||
namespace uavcan_stm32
|
||||
{
|
||||
|
||||
@@ -79,6 +80,56 @@ void Mutex::unlock()
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
#elif UAVCAN_STM32_FREERTOS
|
||||
|
||||
bool BusEvent::wait(uavcan::MonotonicDuration duration)
|
||||
{
|
||||
static const uavcan::int64_t MaxDelayMSec = 0x000FFFFF;
|
||||
|
||||
const uavcan::int64_t msec = duration.toMSec();
|
||||
|
||||
BaseType_t ret;
|
||||
|
||||
if (msec <= 0)
|
||||
{
|
||||
ret = xSemaphoreTake( sem_, ( TickType_t ) 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = xSemaphoreTake( sem_, (msec > MaxDelayMSec) ? (MaxDelayMSec/portTICK_RATE_MS) : (msec/portTICK_RATE_MS));
|
||||
}
|
||||
return ret == pdTRUE;
|
||||
}
|
||||
|
||||
void BusEvent::signal()
|
||||
{
|
||||
xSemaphoreGive( sem_ );
|
||||
}
|
||||
|
||||
void BusEvent::signalFromInterrupt()
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
xSemaphoreGiveFromISR( sem_, &xHigherPriorityTaskWoken );
|
||||
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
/*
|
||||
* Mutex
|
||||
*/
|
||||
void Mutex::lock()
|
||||
{
|
||||
xSemaphoreTake( mtx_, portMAX_DELAY );
|
||||
}
|
||||
|
||||
void Mutex::unlock()
|
||||
{
|
||||
xSemaphoreGive( mtx_ );
|
||||
}
|
||||
|
||||
|
||||
#elif UAVCAN_STM32_NUTTX
|
||||
|
||||
const unsigned BusEvent::MaxPollWaiters;
|
||||
|
||||
Reference in New Issue
Block a user