Browse Source

HAL_ChibiOS: reduced stack usage in CAN RX handler

zr-v5.1
Andrew Tridgell 4 years ago
parent
commit
2d459dccc3
  1. 5
      libraries/AP_HAL_ChibiOS/CANIface.h
  2. 4
      libraries/AP_HAL_ChibiOS/CanIface.cpp

5
libraries/AP_HAL_ChibiOS/CANIface.h

@ -97,6 +97,11 @@ class ChibiOS::CANIface : public AP_HAL::CANIface @@ -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<CanRxItem> rx_queue_;

4
libraries/AP_HAL_ChibiOS/CanIface.cpp

@ -519,7 +519,7 @@ void CANIface::handleRxInterrupt(uint8_t fifo_index, uint64_t timestamp_us) @@ -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) @@ -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;

Loading…
Cancel
Save