AP_HAL_ChibiOS: disable EventSource only when CH_CFG_USE_EVENTS is false
(cherry picked from commit 6e7542a70ca2343ab8d18470deaf5fc2d27390af) from bugobliterator
This commit is contained in:
parent
f09abc705b
commit
f764bd6547
@ -94,7 +94,7 @@ static_assert(STM32_FDCANCLK <= 80U*1000U*1000U, "FDCAN clock must be max 80MHz"
|
|||||||
|
|
||||||
using namespace ChibiOS;
|
using namespace ChibiOS;
|
||||||
|
|
||||||
#if HAL_MAX_CAN_PROTOCOL_DRIVERS
|
#if HAL_MAX_CAN_PROTOCOL_DRIVERS && !defined(HAL_BUILD_AP_PERIPH)
|
||||||
#define Debug(fmt, args...) do { AP::can().log_text(AP_CANManager::LOG_DEBUG, "CANFDIface", fmt, ##args); } while (0)
|
#define Debug(fmt, args...) do { AP::can().log_text(AP_CANManager::LOG_DEBUG, "CANFDIface", fmt, ##args); } while (0)
|
||||||
#else
|
#else
|
||||||
#define Debug(fmt, args...)
|
#define Debug(fmt, args...)
|
||||||
@ -763,7 +763,7 @@ void CANIface::handleTxCompleteInterrupt(const uint64_t timestamp_us)
|
|||||||
}
|
}
|
||||||
if (event_handle_ != nullptr) {
|
if (event_handle_ != nullptr) {
|
||||||
stats.num_events++;
|
stats.num_events++;
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
evt_src_.signalI(1 << self_index_);
|
evt_src_.signalI(1 << self_index_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -868,7 +868,7 @@ void CANIface::handleRxInterrupt(uint8_t fifo_index)
|
|||||||
}
|
}
|
||||||
if (event_handle_ != nullptr) {
|
if (event_handle_ != nullptr) {
|
||||||
stats.num_events++;
|
stats.num_events++;
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
evt_src_.signalI(1 << self_index_);
|
evt_src_.signalI(1 << self_index_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -936,7 +936,7 @@ uint32_t CANIface::getErrorCount() const
|
|||||||
stats.tx_timedout;
|
stats.tx_timedout;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
ChibiOS::EventSource CANIface::evt_src_;
|
ChibiOS::EventSource CANIface::evt_src_;
|
||||||
bool CANIface::set_event_handle(AP_HAL::EventHandle* handle)
|
bool CANIface::set_event_handle(AP_HAL::EventHandle* handle)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ class ChibiOS::CANIface : public AP_HAL::CANIface
|
|||||||
bool initialised_;
|
bool initialised_;
|
||||||
bool had_activity_;
|
bool had_activity_;
|
||||||
AP_HAL::EventHandle* event_handle_;
|
AP_HAL::EventHandle* event_handle_;
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
static ChibiOS::EventSource evt_src_;
|
static ChibiOS::EventSource evt_src_;
|
||||||
#endif
|
#endif
|
||||||
const uint8_t self_index_;
|
const uint8_t self_index_;
|
||||||
@ -216,10 +216,12 @@ public:
|
|||||||
const AP_HAL::CANFrame* const pending_tx,
|
const AP_HAL::CANFrame* const pending_tx,
|
||||||
uint64_t blocking_deadline) override;
|
uint64_t blocking_deadline) override;
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
// setup event handle for waiting on events
|
// setup event handle for waiting on events
|
||||||
bool set_event_handle(AP_HAL::EventHandle* handle) override;
|
bool set_event_handle(AP_HAL::EventHandle* handle) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
||||||
// fetch stats text and return the size of the same,
|
// fetch stats text and return the size of the same,
|
||||||
// results available via @SYS/can0_stats.txt or @SYS/can1_stats.txt
|
// results available via @SYS/can0_stats.txt or @SYS/can1_stats.txt
|
||||||
void get_stats(ExpandingString &str) override;
|
void get_stats(ExpandingString &str) override;
|
||||||
|
@ -109,7 +109,7 @@ class ChibiOS::CANIface : public AP_HAL::CANIface
|
|||||||
bool irq_init_:1;
|
bool irq_init_:1;
|
||||||
bool initialised_:1;
|
bool initialised_:1;
|
||||||
bool had_activity_:1;
|
bool had_activity_:1;
|
||||||
#ifndef HAL_BUILD_AP_PERIPH
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
AP_HAL::EventHandle* event_handle_;
|
AP_HAL::EventHandle* event_handle_;
|
||||||
static ChibiOS::EventSource evt_src_;
|
static ChibiOS::EventSource evt_src_;
|
||||||
#endif
|
#endif
|
||||||
@ -217,10 +217,11 @@ public:
|
|||||||
const AP_HAL::CANFrame* const pending_tx,
|
const AP_HAL::CANFrame* const pending_tx,
|
||||||
uint64_t blocking_deadline) override;
|
uint64_t blocking_deadline) override;
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
// setup event handle for waiting on events
|
// setup event handle for waiting on events
|
||||||
bool set_event_handle(AP_HAL::EventHandle* handle) override;
|
bool set_event_handle(AP_HAL::EventHandle* handle) override;
|
||||||
|
#endif
|
||||||
|
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
||||||
// fetch stats text and return the size of the same,
|
// fetch stats text and return the size of the same,
|
||||||
// results available via @SYS/can0_stats.txt or @SYS/can1_stats.txt
|
// results available via @SYS/can0_stats.txt or @SYS/can1_stats.txt
|
||||||
void get_stats(ExpandingString &str) override;
|
void get_stats(ExpandingString &str) override;
|
||||||
|
@ -509,7 +509,7 @@ void CANIface::handleTxInterrupt(const uint64_t utc_usec)
|
|||||||
handleTxMailboxInterrupt(2, txok, utc_usec);
|
handleTxMailboxInterrupt(2, txok, utc_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
if (event_handle_ != nullptr) {
|
if (event_handle_ != nullptr) {
|
||||||
PERF_STATS(stats.num_events);
|
PERF_STATS(stats.num_events);
|
||||||
evt_src_.signalI(1 << self_index_);
|
evt_src_.signalI(1 << self_index_);
|
||||||
@ -577,7 +577,7 @@ void CANIface::handleRxInterrupt(uint8_t fifo_index, uint64_t timestamp_us)
|
|||||||
|
|
||||||
had_activity_ = true;
|
had_activity_ = true;
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
if (event_handle_ != nullptr) {
|
if (event_handle_ != nullptr) {
|
||||||
PERF_STATS(stats.num_events);
|
PERF_STATS(stats.num_events);
|
||||||
evt_src_.signalI(1 << self_index_);
|
evt_src_.signalI(1 << self_index_);
|
||||||
@ -687,6 +687,9 @@ uint32_t CANIface::getErrorCount() const
|
|||||||
stats.tx_timedout;
|
stats.tx_timedout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
||||||
|
|
||||||
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
ChibiOS::EventSource CANIface::evt_src_;
|
ChibiOS::EventSource CANIface::evt_src_;
|
||||||
bool CANIface::set_event_handle(AP_HAL::EventHandle* handle)
|
bool CANIface::set_event_handle(AP_HAL::EventHandle* handle)
|
||||||
{
|
{
|
||||||
@ -696,7 +699,7 @@ bool CANIface::set_event_handle(AP_HAL::EventHandle* handle)
|
|||||||
return event_handle_->register_event(1 << self_index_);
|
return event_handle_->register_event(1 << self_index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#endif // #if CH_CFG_USE_EVENTS == TRUE
|
||||||
|
|
||||||
void CANIface::checkAvailable(bool& read, bool& write, const AP_HAL::CANFrame* pending_tx) const
|
void CANIface::checkAvailable(bool& read, bool& write, const AP_HAL::CANFrame* pending_tx) const
|
||||||
{
|
{
|
||||||
@ -729,7 +732,7 @@ bool CANIface::select(bool &read, bool &write,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
// we don't support blocking select in AP_Periph and bootloader
|
// we don't support blocking select in AP_Periph and bootloader
|
||||||
while (time < blocking_deadline) {
|
while (time < blocking_deadline) {
|
||||||
if (event_handle_ == nullptr) {
|
if (event_handle_ == nullptr) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "EventSource.h"
|
#include "EventSource.h"
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
|
||||||
|
|
||||||
using namespace ChibiOS;
|
using namespace ChibiOS;
|
||||||
|
|
||||||
#if CH_CFG_USE_EVENTS == TRUE
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
@ -33,4 +31,3 @@ void EventSource::signalI(uint32_t evt_mask)
|
|||||||
chSysUnlockFromISR();
|
chSysUnlockFromISR();
|
||||||
}
|
}
|
||||||
#endif //#if CH_CFG_USE_EVENTS == TRUE
|
#endif //#if CH_CFG_USE_EVENTS == TRUE
|
||||||
#endif //#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
|
|
||||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <AP_HAL/AP_HAL_Boards.h>
|
#include <AP_HAL/AP_HAL_Boards.h>
|
||||||
#include <AP_HAL/AP_HAL_Macros.h>
|
#include <AP_HAL/AP_HAL_Macros.h>
|
||||||
@ -25,4 +24,3 @@ public:
|
|||||||
bool wait(uint64_t duration, AP_HAL::EventHandle* evt_handle) override;
|
bool wait(uint64_t duration, AP_HAL::EventHandle* evt_handle) override;
|
||||||
};
|
};
|
||||||
#endif //#if CH_CFG_USE_EVENTS == TRUE
|
#endif //#if CH_CFG_USE_EVENTS == TRUE
|
||||||
#endif //#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user