STM32: simplified abort handling

This commit is contained in:
Pavel Kirienko
2015-07-07 19:05:09 +03:00
parent d3a1c84f27
commit 4247087e5e
2 changed files with 9 additions and 24 deletions
@@ -95,7 +95,6 @@ class CanIface : public uavcan::ICanIface, uavcan::Noncopyable
enum { NumFilters = 14 };
static const uavcan::uint32_t TSR_ABRQx[NumTxMailboxes];
static const uavcan::uint32_t TSR_TERRx[NumTxMailboxes];
RxQueue rx_queue_;
bxcan::CanType* const can_;
@@ -170,13 +170,6 @@ const uavcan::uint32_t CanIface::TSR_ABRQx[CanIface::NumTxMailboxes] =
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)
{
/*
@@ -574,30 +567,23 @@ void CanIface::handleStatusChangeInterrupt()
{
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);
if (lec != 0)
{
last_hw_error_code_ = lec;
can_->ESR = 0;
error_cnt_++;
}
/*
* Serving abort requests
*/
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)
// Serving abort requests
for (int i = 0; i < NumTxMailboxes; i++) // Dear compiler, may I suggest you to unroll this loop please.
{
can_->TSR = TSR_ABRQx[i];
txi.pending = false;
served_aborts_cnt_++;
TxItem& txi = pending_tx_[i];
if (txi.pending && txi.abort_on_error)
{
can_->TSR = TSR_ABRQx[i];
txi.pending = false;
served_aborts_cnt_++;
}
}
}
}