Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
can.h
1#pragma once
2#include <utils/queue.h>
3#include <comm/can.h>
4
5#include "gpio.h"
6#include "registry.h"
7
8namespace CAN {
10struct HW : public CAN {
11 inline static Registry<HW, CAN_HandleTypeDef, 2> reg;
12 struct Config {
13 CAN_TypeDef *can;
14 AFIO rx, tx;
15 uint32_t kbaud;
16 };
17 HW(const Config &);
18 ~HW();
19 bool full() override;
20 void push(Message &&) override;
21 using Sink::push;
22 Message pop() override { return rx.pop(); };
23 bool empty() override { return rx.empty(); };
24
26
27 struct TX {
29 uint8_t active;
30 } tx{};
31
32 void irqHandler() { HAL_CAN_IRQHandler(&handle); };
33 CAN_HandleTypeDef handle{};
34};
35}
Wrapper class for pins in alternate configuration mode.
Definition gpio.h:60
simple Buffer backed queue implementation
Definition queue.h:12
T pop() override
remove front of queue and return it
Definition queue.h:65
bool empty() override
check if queue is empty
Definition queue.h:83
registry that maps classes to HAL handles
Definition registry.h:13
Copyright (c) 2020 IACE.
Copyright (c) 2023 IACE.
Copyright (c) 2023 IACE.
Message pop() override
pull object from source does not check for data. guard by using 'if (!empty) { ......
Definition can.h:22
bool full() override
check if sink is full
bool empty() override
check if source is empty
Definition can.h:23
virtual void push(const T &t)
copy semantics does not check for space. guard by using 'if (!full) { ... }'
Definition streams.h:20