72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "common.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
#include <zephyr/drivers/can.h>
|
|
#include <zephyr/kernel.h>
|
|
|
|
namespace rims {
|
|
|
|
/* only temperature subsystem receives this, there is no need for point-to-multipoint, yet :) */
|
|
extern k_msgq can_temperature_ingress_queue;
|
|
extern k_msgq can_config_ingress_queue;
|
|
extern k_msgq can_ctrl_ingress_queue;
|
|
|
|
class CAN_RX {
|
|
public:
|
|
CAN_RX(ZephyrThread &parent) : _parent{parent} {
|
|
}
|
|
|
|
void loop();
|
|
|
|
protected:
|
|
bool Setup();
|
|
ZephyrThread &_parent;
|
|
};
|
|
|
|
class CAN_RXThread : public ZephyrThread {
|
|
public:
|
|
CAN_RXThread(TStackBase &stack) : ZephyrThread(stack, 7, 0){};
|
|
|
|
// ZephyrThread interface
|
|
protected:
|
|
void threadMain() {
|
|
/// runs in context of new thread, on new thread stack etc.
|
|
CAN_RX thread{*this};
|
|
thread.loop();
|
|
}
|
|
};
|
|
|
|
class CAN_TX {
|
|
public:
|
|
// adds data to CAN_TX message queue
|
|
static void send(uint32_t senderId, const void *data, std::size_t messageLength);
|
|
|
|
CAN_TX(ZephyrThread &parent) : _parent{parent} {
|
|
}
|
|
|
|
void loop();
|
|
|
|
protected:
|
|
bool Setup();
|
|
ZephyrThread &_parent;
|
|
};
|
|
|
|
class CAN_TXThread : public ZephyrThread {
|
|
public:
|
|
CAN_TXThread(TStackBase &stack) : ZephyrThread(stack, 7, 0){};
|
|
|
|
// ZephyrThread interface
|
|
protected:
|
|
void threadMain() {
|
|
/// runs in context of new thread, on new thread stack etc.
|
|
CAN_TX thread{*this};
|
|
thread.loop();
|
|
}
|
|
};
|
|
|
|
} // namespace rims
|