mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 21:03:34 +08:00
Revert "STM32 NuttX driver: Edge-triggered poll(), sort of fixes #35"
This reverts commit 22787651e6.
This commit is contained in:
@@ -99,7 +99,7 @@ int BusEvent::poll(::file* filp, ::pollfd* fds, bool setup)
|
||||
ret = addPollWaiter(fds);
|
||||
if (ret == 0)
|
||||
{
|
||||
fds->revents |= fds->events & POLLIN;
|
||||
fds->revents |= fds->events & makePollMask();
|
||||
if (fds->revents != 0)
|
||||
{
|
||||
(void)sem_post(fds->sem);
|
||||
@@ -114,11 +114,26 @@ int BusEvent::poll(::file* filp, ::pollfd* fds, bool setup)
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned BusEvent::makePollMask() const
|
||||
{
|
||||
const uavcan::CanSelectMasks select_masks = can_driver_.makeSelectMasks();
|
||||
unsigned poll_mask = 0;
|
||||
if (select_masks.read != 0)
|
||||
{
|
||||
poll_mask |= POLLIN;
|
||||
}
|
||||
if (select_masks.write != 0)
|
||||
{
|
||||
poll_mask |= POLLOUT;
|
||||
}
|
||||
return poll_mask;
|
||||
}
|
||||
|
||||
int BusEvent::addPollWaiter(::pollfd* fds)
|
||||
{
|
||||
for (unsigned i = 0; i < MaxPollWaiters; i++)
|
||||
{
|
||||
if (pollset_[i] == NULL)
|
||||
if (pollset_[i] == nullptr)
|
||||
{
|
||||
pollset_[i] = fds;
|
||||
return 0;
|
||||
@@ -133,15 +148,16 @@ int BusEvent::removePollWaiter(::pollfd* fds)
|
||||
{
|
||||
if (fds == pollset_[i])
|
||||
{
|
||||
pollset_[i] = NULL;
|
||||
pollset_[i] = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
BusEvent::BusEvent()
|
||||
: signal_(false)
|
||||
BusEvent::BusEvent(CanDriver& can_driver)
|
||||
: can_driver_(can_driver)
|
||||
, signal_(false)
|
||||
{
|
||||
std::memset(&file_ops_, 0, sizeof(file_ops_));
|
||||
std::memset(pollset_, 0, sizeof(pollset_));
|
||||
@@ -185,9 +201,9 @@ void BusEvent::signalFromInterrupt()
|
||||
for (unsigned i = 0; i < MaxPollWaiters; i++)
|
||||
{
|
||||
::pollfd* const fd = pollset_[i];
|
||||
if (fd != NULL)
|
||||
if (fd != nullptr)
|
||||
{
|
||||
fd->revents |= fd->events & POLLIN;
|
||||
fd->revents = fd->events & makePollMask();
|
||||
if ((fd->revents != 0) && (fd->sem->semcount <= 0))
|
||||
{
|
||||
(void)sem_post(fd->sem);
|
||||
|
||||
Reference in New Issue
Block a user