diff --git a/libraries/AP_HAL_ChibiOS/CANIface.h b/libraries/AP_HAL_ChibiOS/CANIface.h index 188ddbe88d..47b5a80ae7 100644 --- a/libraries/AP_HAL_ChibiOS/CANIface.h +++ b/libraries/AP_HAL_ChibiOS/CANIface.h @@ -97,6 +97,11 @@ class ChibiOS::CANIface : public AP_HAL::CANIface ChibiOS::bxcan::CanType* can_; + // state for ISR RX handler. We put this in the class to avoid + // having to expand the stack size for all threads + AP_HAL::CANFrame isr_rx_frame; + CanRxItem isr_rx_item; + CanRxItem rx_buffer[HAL_CAN_RX_QUEUE_SIZE]; ByteBuffer rx_bytebuffer_; ObjectBuffer rx_queue_; diff --git a/libraries/AP_HAL_ChibiOS/CanIface.cpp b/libraries/AP_HAL_ChibiOS/CanIface.cpp index 81d1405f02..d2d920cd23 100644 --- a/libraries/AP_HAL_ChibiOS/CanIface.cpp +++ b/libraries/AP_HAL_ChibiOS/CanIface.cpp @@ -519,7 +519,7 @@ void CANIface::handleRxInterrupt(uint8_t fifo_index, uint64_t timestamp_us) /* * Read the frame contents */ - AP_HAL::CANFrame frame; + AP_HAL::CANFrame &frame = isr_rx_frame; const bxcan::RxMailboxType& rf = can_->RxMailbox[fifo_index]; if ((rf.RIR & bxcan::RIR_IDE) == 0) { @@ -549,7 +549,7 @@ void CANIface::handleRxInterrupt(uint8_t fifo_index, uint64_t timestamp_us) /* * Store with timeout into the FIFO buffer and signal update event */ - CanRxItem rx_item; + CanRxItem &rx_item = isr_rx_item; rx_item.frame = frame; rx_item.timestamp_us = timestamp_us; rx_item.flags = 0;