halx
読み取り中…
検索中…
一致する文字列を見つけられません
can.hpp
[詳解]
1#pragma once
2
3#include "can/common.hpp"
4
5#ifdef HAL_CAN_MODULE_ENABLED
6#include "can/bxcan.hpp"
7#endif
8
9#ifdef HAL_FDCAN_MODULE_ENABLED
10#include "can/fdcan.hpp"
11#endif
12
14
15template <auto *Handle, class HandleType = decltype(Handle)> class Can;
16
17#ifdef HAL_CAN_MODULE_ENABLED
18
19template <auto *Handle>
20class Can<Handle, CAN_HandleTypeDef *> : public CanBase {
21public:
23
24 bool start() override { return can_.start(); }
25 bool stop() override { return can_.stop(); }
26 bool transmit(const CanMessage &msg, uint32_t timeout) override {
27 return can_.transmit(msg, timeout);
28 }
29 std::optional<size_t> attach_rx_filter(const CanFilter &filter,
30 void (*callback)(const CanMessage &msg,
31 void *context),
32 void *context) override {
33 return can_.attach_rx_filter(filter, callback, context);
34 }
35 bool detach_rx_filter(size_t filter_index) override {
36 return can_.detach_rx_filter(filter_index);
37 }
38
39private:
40 BxCan<Handle> can_;
41};
42
43#endif
44
45#ifdef HAL_FDCAN_MODULE_ENABLED
46
47template <auto *Handle>
48class Can<Handle, FDCAN_HandleTypeDef *> : public CanBase {
49public:
51
52 bool start() override { return can_.start(); }
53 bool stop() override { return can_.stop(); }
54 bool transmit(const CanMessage &msg, uint32_t timeout) override {
55 return can_.transmit(msg, timeout);
56 }
57 std::optional<size_t> attach_rx_filter(const CanFilter &filter,
58 void (*callback)(const CanMessage &msg,
59 void *context),
60 void *context) override {
61 return can_.attach_rx_filter(filter, callback, context);
62 }
63 bool detach_rx_filter(size_t filter_index) override {
64 return can_.detach_rx_filter(filter_index);
65 }
66
67private:
68 FdCan<Handle> can_;
69};
70
71#endif
72
73} // namespace halx::peripheral
Definition bxcan.hpp:13
Definition common.hpp:81
virtual bool stop()=0
virtual std::optional< size_t > attach_rx_filter(const CanFilter &filter, void(*callback)(const CanMessage &msg, void *context), void *context)=0
Definition can.hpp:15
Definition fdcan.hpp:13
Definition can.hpp:13
Definition common.hpp:12
Definition common.hpp:18