mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL_SITL: definitions for CAN bus
This commit is contained in:
parent
55a0bd081f
commit
d81af8700f
@ -14,4 +14,6 @@ class Util;
|
||||
class Semaphore;
|
||||
class GPIO;
|
||||
class DigitalSource;
|
||||
class HALSITLCAN;
|
||||
class HALSITLCANDriver;
|
||||
} // namespace HALSITL
|
||||
|
62
libraries/AP_HAL_SITL/CAN.h
Normal file
62
libraries/AP_HAL_SITL/CAN.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 2017 Eugene Shamaev
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AP_HAL_SITL.h"
|
||||
|
||||
#if HAL_WITH_UAVCAN
|
||||
#include <AP_HAL/CAN.h>
|
||||
|
||||
class HALSITL::HALSITLCAN : public AP_HAL::CAN {
|
||||
public:
|
||||
HALSITLCAN() { }
|
||||
~HALSITLCAN() { }
|
||||
int16_t send(const uavcan::CanFrame& frame, uavcan::MonotonicTime tx_deadline, uavcan::CanIOFlags flags) override;
|
||||
int16_t receive(uavcan::CanFrame& out_frame, uavcan::MonotonicTime& out_ts_monotonic, uavcan::UtcTime& out_ts_utc,
|
||||
uavcan::CanIOFlags& out_flags) override;
|
||||
int16_t configureFilters(const uavcan::CanFilterConfig* filter_configs, uint16_t num_configs) override;
|
||||
uint16_t getNumFilters() const override;
|
||||
uint64_t getErrorCount() const override;
|
||||
|
||||
bool begin(uint32_t bitrate) override;
|
||||
void end() override;
|
||||
void reset() override;
|
||||
bool is_initialized() override;
|
||||
int32_t tx_pending() override;
|
||||
int32_t available() override;
|
||||
|
||||
|
||||
private:
|
||||
uint32_t _baudrate;
|
||||
volatile bool _initialised;
|
||||
volatile bool _in_timer;
|
||||
};
|
||||
|
||||
class HALSITL::HALSITLCANDriver : public AP_HAL::CANManager
|
||||
{
|
||||
public:
|
||||
HALSITLCANDriver() { }
|
||||
~HALSITLCANDriver() { }
|
||||
uavcan::ICanIface* getIface(uint8_t iface_index) override;
|
||||
const uavcan::ICanIface* getIface(uint8_t iface_index) const override;
|
||||
uint8_t getNumIfaces() const override;
|
||||
int16_t select(uavcan::CanSelectMasks& inout_masks,
|
||||
const uavcan::CanFrame* (& pending_tx)[uavcan::MaxCanIfaces],
|
||||
uavcan::MonotonicTime blocking_deadline) override;
|
||||
};
|
||||
|
||||
#endif
|
@ -62,7 +62,8 @@ HAL_SITL::HAL_SITL() :
|
||||
&sitlRCOutput, /* rcoutput */
|
||||
&sitlScheduler, /* scheduler */
|
||||
&utilInstance, /* util */
|
||||
&emptyOpticalFlow), /* onboard optical flow */
|
||||
&emptyOpticalFlow, /* onboard optical flow */
|
||||
nullptr), /* CAN */
|
||||
_sitl_state(&sitlState)
|
||||
{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user