12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #pragma once
- #include "AP_HAL_ChibiOS.h"
- #if HAL_WITH_UAVCAN
- # include <ch.hpp>
- #include <uavcan/uavcan.hpp>
- namespace ChibiOS_CAN {
- class CanDriver;
- class BusEvent {
- chibios_rt::CounterSemaphore sem_;
- public:
- BusEvent(CanDriver& can_driver)
- : sem_(0)
- {
- (void)can_driver;
- }
- bool wait(uavcan::MonotonicDuration duration);
- void signal();
- void signalFromInterrupt();
- };
- class Mutex {
- chibios_rt::Mutex mtx_;
- public:
- void lock();
- void unlock();
- };
- class MutexLocker {
- Mutex& mutex_;
- public:
- MutexLocker(Mutex& mutex)
- : mutex_(mutex)
- {
- mutex_.lock();
- }
- ~MutexLocker()
- {
- mutex_.unlock();
- }
- };
- }
- #endif
|