20#ifndef MBED_INTERFACE_CAN_H_
21#define MBED_INTERFACE_CAN_H_
23#include "hal/can_helper.h"
27#include "platform/Callback.h"
31#ifndef FEATURE_EXPERIMENTAL_API
72 CANMessage(
unsigned int _id,
const unsigned char *_data,
unsigned char _len = 8,
CANType _type = CANData,
CANFormat _format = CANStandard)
74 len = (_len > 8) ? 8 : _len;
78 memcpy(data, _data, len);
92 len = (_len > 8) ? 8 : _len;
96 memcpy(data, _data, len);
124 if (format != b.format) {
127 if (type != b.type) {
130 if (memcmp(data, b.data, len) != 0) {
139 return !(*
this == b);
181 can(
const can &) =
delete;
182 can &operator=(
const can &) =
delete;
186#ifdef FEATURE_EXPERIMENTAL_API
191 virtual ~CAN() =
default;
192 virtual int frequency(
int hz) = 0;
194 virtual int read(
CANMessage &msg,
int handle = 0) = 0;
195 virtual void reset() = 0;
196 virtual void monitor(
bool silent) = 0;
197 virtual int mode(Mode mode) = 0;
198 virtual int filter(
unsigned int id,
unsigned int mask,
CANFormat format = CANAny,
int handle = 0) = 0;
199 virtual unsigned char rderror() = 0;
200 virtual unsigned char tderror() = 0;
201 virtual void attach(
Callback<
void()> func, IrqType type = IrqType::RxIrq) = 0;
210#if defined(FEATURE_EXPERIMENTAL_API) && !DEVICE_CAN
211using CAN = interface::CAN;
A can bus client, used for communicating with can devices.
CANMessage(unsigned int _id, const char *_data, unsigned char _len=8, CANType _type=CANData, CANFormat _format=CANStandard)
Creates CAN message with specific content.
bool operator==(const CANMessage &b) const
"Deep" comparison operator (ie: compare value of each data member)
CANMessage(unsigned int _id, CANFormat _format=CANStandard)
Creates CAN remote message.
CANMessage()
Creates empty CAN message.
CANMessage(unsigned int _id, const unsigned char *_data, unsigned char _len=8, CANType _type=CANData, CANFormat _format=CANStandard)
Creates CAN message with specific content.
Callback class based on template specialization.
CANType
Values that represent CAN Type.
CANFormat
Values that represent CAN Format.
Holder for single CAN message.