From 22dd70cb706eeab335271ac4ac26be655cd25ee5 Mon Sep 17 00:00:00 2001 From: "@CarlWachter" Date: Wed, 25 Oct 2023 15:57:52 +0200 Subject: [PATCH] CAN bus completion of abstract class Can additions --- include/sta/devices/stm32/can.hpp | 8 ++++++++ src/devices/stm32/can.cpp | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/sta/devices/stm32/can.hpp b/include/sta/devices/stm32/can.hpp index e935cf5..cd75304 100644 --- a/include/sta/devices/stm32/can.hpp +++ b/include/sta/devices/stm32/can.hpp @@ -80,6 +80,14 @@ namespace sta void disableFilter(uint8_t idx) override; void clearFilters() override; + // TODO + CanPendingRxFifos getPendingRxFifos() override; + + // Const getters + uint8_t maxFilterCount() const override; + uint8_t maxFifoCount() const override; + uint8_t maxPayloadSize() const override; + private: /** * @brief Initialize filter settings. diff --git a/src/devices/stm32/can.cpp b/src/devices/stm32/can.cpp index 0c485ea..66b07ac 100644 --- a/src/devices/stm32/can.cpp +++ b/src/devices/stm32/can.cpp @@ -168,6 +168,29 @@ namespace sta config->SlaveStartFilterBank = MAX_FILTER_COUNT; } } + + CanPendingRxFifos STM32CanController::getPendingRxFifos(){ + CanPendingRxFifos pendingFifos(42, 3); + + // Example implementation: + //pendingFifos.fifo0Pending = HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0; + //pendingFifos.fifo1Pending = HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0; + + return pendingFifos; + } + + uint8_t STM32CanController::maxFilterCount() const{ + return MAX_FILTER_COUNT; + } + + uint8_t STM32CanController::maxFifoCount() const { + return MAX_FIFO_COUNT; + } + + uint8_t STM32CanController::maxPayloadSize() const { + return MAX_PAYLOAD_SIZE; + } + } // namespace sta