mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
121 lines
2.4 KiB
C++
121 lines
2.4 KiB
C++
/**
|
|
* @file
|
|
* @brief CAN controller driver interface.
|
|
*/
|
|
#ifndef STA_CAN_CONTROLLER_HPP
|
|
#define STA_CAN_CONTROLLER_HPP
|
|
|
|
/**
|
|
* @defgroup can CAN
|
|
* @brief CAN controller driver interface.
|
|
*/
|
|
|
|
/**
|
|
* @defgroup canAPI API
|
|
* @ingroup can
|
|
* @brief Public interface.
|
|
*/
|
|
|
|
|
|
#include <sta/can/filter.hpp>
|
|
#include <sta/can/headers.hpp>
|
|
#include <sta/can/iter.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
/**
|
|
* @brief CAN controller driver interface.
|
|
*
|
|
* @ingroup canAPI
|
|
*/
|
|
class CanController
|
|
{
|
|
public:
|
|
// RX/TX
|
|
//
|
|
|
|
/**
|
|
* @brief Send frame to CAN controller for transmission.
|
|
*
|
|
* @param header CAN frame TX header
|
|
* @param payload CAN frame payload
|
|
* @return True on success
|
|
*/
|
|
virtual bool sendFrame(const CanTxHeader & header, const uint8_t * payload) = 0;
|
|
|
|
/**
|
|
* @brief Get received frame from the CAN controller.
|
|
*
|
|
* @param[in] fifo FIFO storing frame
|
|
* @param[out] header CAN frame RX header destination
|
|
* @param[out] payload CAN frame payload destination
|
|
* @return True on success
|
|
*/
|
|
virtual bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) = 0;
|
|
|
|
/**
|
|
* @brief Get RX FIFO flags.
|
|
*
|
|
* @return FIFO flags
|
|
*/
|
|
virtual uint32_t getRxFifoFlags() = 0;
|
|
|
|
/**
|
|
* @brief Get list of RX FIFO indices with pending messages.
|
|
*/
|
|
virtual CanPendingRxFifos getPendingRxFifos() = 0;
|
|
|
|
|
|
// RX filter
|
|
//
|
|
|
|
/**
|
|
* @brief Change filter settings.
|
|
*
|
|
* @param idx Filter index
|
|
* @param filter Filter configuration
|
|
* @param active Enable filter after applying settings
|
|
*/
|
|
virtual void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) = 0;
|
|
/**
|
|
* @brief Enable filter.
|
|
*
|
|
* @param idx Filter index
|
|
*/
|
|
virtual void enableFilter(uint8_t idx) = 0;
|
|
/**
|
|
* @brief Disable filter.
|
|
*
|
|
* @param idx Filter index
|
|
*/
|
|
virtual void disableFilter(uint8_t idx) = 0;
|
|
/**
|
|
* @brief Disable and clear all filters.
|
|
*/
|
|
virtual void clearFilters() = 0;
|
|
|
|
|
|
// Info
|
|
//
|
|
|
|
/**
|
|
* @brief Get number of available filters.
|
|
*/
|
|
virtual uint8_t maxFilterCount() const = 0;
|
|
|
|
/**
|
|
* @brief Get number of available FIFOs.
|
|
*/
|
|
virtual uint8_t maxFifoCount() const = 0;
|
|
|
|
/**
|
|
* @brief Get maximum supported payload size.
|
|
*/
|
|
virtual uint8_t maxPayloadSize() const = 0;
|
|
};
|
|
} // namespace sta
|
|
|
|
|
|
#endif // STA_CAN_CONTROLLER_HPP
|