mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 18:23:33 +08:00
STM32: simplified abort handling
This commit is contained in:
@@ -95,7 +95,6 @@ class CanIface : public uavcan::ICanIface, uavcan::Noncopyable
|
|||||||
enum { NumFilters = 14 };
|
enum { NumFilters = 14 };
|
||||||
|
|
||||||
static const uavcan::uint32_t TSR_ABRQx[NumTxMailboxes];
|
static const uavcan::uint32_t TSR_ABRQx[NumTxMailboxes];
|
||||||
static const uavcan::uint32_t TSR_TERRx[NumTxMailboxes];
|
|
||||||
|
|
||||||
RxQueue rx_queue_;
|
RxQueue rx_queue_;
|
||||||
bxcan::CanType* const can_;
|
bxcan::CanType* const can_;
|
||||||
|
|||||||
@@ -170,13 +170,6 @@ const uavcan::uint32_t CanIface::TSR_ABRQx[CanIface::NumTxMailboxes] =
|
|||||||
bxcan::TSR_ABRQ2
|
bxcan::TSR_ABRQ2
|
||||||
};
|
};
|
||||||
|
|
||||||
const uavcan::uint32_t CanIface::TSR_TERRx[CanIface::NumTxMailboxes] =
|
|
||||||
{
|
|
||||||
bxcan::TSR_TERR0,
|
|
||||||
bxcan::TSR_TERR1,
|
|
||||||
bxcan::TSR_TERR2
|
|
||||||
};
|
|
||||||
|
|
||||||
int CanIface::computeTimings(const uavcan::uint32_t target_bitrate, Timings& out_timings)
|
int CanIface::computeTimings(const uavcan::uint32_t target_bitrate, Timings& out_timings)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -574,30 +567,23 @@ void CanIface::handleStatusChangeInterrupt()
|
|||||||
{
|
{
|
||||||
can_->MSR = bxcan::MSR_ERRI; // Clear error
|
can_->MSR = bxcan::MSR_ERRI; // Clear error
|
||||||
|
|
||||||
/*
|
|
||||||
* General error counter
|
|
||||||
*/
|
|
||||||
const uavcan::uint8_t lec = uavcan::uint8_t((can_->ESR & bxcan::ESR_LEC_MASK) >> bxcan::ESR_LEC_SHIFT);
|
const uavcan::uint8_t lec = uavcan::uint8_t((can_->ESR & bxcan::ESR_LEC_MASK) >> bxcan::ESR_LEC_SHIFT);
|
||||||
if (lec != 0)
|
if (lec != 0)
|
||||||
{
|
{
|
||||||
last_hw_error_code_ = lec;
|
last_hw_error_code_ = lec;
|
||||||
can_->ESR = 0;
|
can_->ESR = 0;
|
||||||
error_cnt_++;
|
error_cnt_++;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// Serving abort requests
|
||||||
* Serving abort requests
|
for (int i = 0; i < NumTxMailboxes; i++) // Dear compiler, may I suggest you to unroll this loop please.
|
||||||
*/
|
|
||||||
for (int i = 0; i < NumTxMailboxes; i++) // Dear compiler, may I suggest you to unroll this loop please.
|
|
||||||
{
|
|
||||||
TxItem& txi = pending_tx_[i];
|
|
||||||
if ((can_->TSR & TSR_TERRx[i]) != 0 &&
|
|
||||||
txi.pending &&
|
|
||||||
txi.abort_on_error)
|
|
||||||
{
|
{
|
||||||
can_->TSR = TSR_ABRQx[i];
|
TxItem& txi = pending_tx_[i];
|
||||||
txi.pending = false;
|
if (txi.pending && txi.abort_on_error)
|
||||||
served_aborts_cnt_++;
|
{
|
||||||
|
can_->TSR = TSR_ABRQx[i];
|
||||||
|
txi.pending = false;
|
||||||
|
served_aborts_cnt_++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user