HardFOC Core
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
HfCanPort.h File Reference

Transport-neutral CAN frame and the ICanPort interface for port bindings (EspTwaiPort, LinuxSocketCanPort, PipePort, later FDCAN and the wireless tunnels). More...

#include <cstdint>

Go to the source code of this file.

Classes

struct  hf::can::CanFrame
 One CAN or CAN FD frame; len is a byte count, never a DLC code. More...
 
struct  hf::can::PortCaps
 What a port binding can carry. More...
 
struct  hf::can::PortStatus
 Error counters and statistics of one port. More...
 
class  hf::can::ICanPort
 One CAN transport binding. More...
 

Namespaces

namespace  hf
 
namespace  hf::can
 
namespace  hf::can::frame_flag
 Bits of CanFrame::flags.
 

Typedefs

using hf::can::RxSink = bool(*)(void *ctx, const CanFrame &frame)
 RX sink; may run in ISR context (copy and return). Returns false if it could not take the frame.
 
using hf::can::TxDoneSink = void(*)(void *ctx)
 TX-done sink: the port has room again; may run in ISR context.
 

Enumerations

enum class  hf::can::TxResult : uint8_t { hf::can::Ok = 0 , hf::can::QueueFull , hf::can::BusOff , hf::can::NotAllowed }
 Result of a non-blocking ICanPort::Send. More...
 
enum class  hf::can::BusState : uint8_t {
  hf::can::Stopped = 0 , hf::can::ErrorActive , hf::can::ErrorWarning , hf::can::ErrorPassive ,
  hf::can::BusOff
}
 Controller error state. More...
 

Functions

constexpr bool hf::can::IsExactFdLength (uint8_t len) noexcept
 Is len an exact FD payload size (0..8, 12, 16, 20, 24, 32, 48, 64)?
 
constexpr bool hf::can::IsWellFormed (const CanFrame &f) noexcept
 Structurally valid frame (flags, id range, length for the frame kind)?
 

Variables

constexpr uint8_t hf::can::kClassicMaxLen = 8U
 Largest classic CAN payload in bytes.
 
constexpr uint8_t hf::can::kFdMaxLen = 64U
 Largest CAN FD payload in bytes.
 
constexpr uint32_t hf::can::kMaxStdId = 0x7FFU
 Largest 11-bit identifier.
 
constexpr uint32_t hf::can::kMaxExtId = 0x1FFFFFFFU
 Largest 29-bit identifier.
 
constexpr uint8_t hf::can::frame_flag::kExt = 0x01U
 29-bit identifier
 
constexpr uint8_t hf::can::frame_flag::kRtr = 0x02U
 remote request (classic only)
 
constexpr uint8_t hf::can::frame_flag::kFdf = 0x04U
 FD frame format.
 
constexpr uint8_t hf::can::frame_flag::kBrs = 0x08U
 bit-rate switch (FD only)
 
constexpr uint8_t hf::can::frame_flag::kEsi = 0x10U
 error state indicator (FD only)
 
constexpr uint8_t hf::can::frame_flag::kAll = kExt | kRtr | kFdf | kBrs | kEsi
 

Detailed Description

Transport-neutral CAN frame and the ICanPort interface for port bindings (EspTwaiPort, LinuxSocketCanPort, PipePort, later FDCAN and the wireless tunnels).

Mirrors vortex::contracts::ICanPort (hardfoc-vortex-v1 contracts/can_frame.hpp) so a product can use either: same frame layout, same flag bits, same result and state enums. Two additions:

Send never blocks. The RX sink may be called in ISR context: it copies the frame and returns.

SPDX-License-Identifier: GPL-3.0-or-later