SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
Canbus.h
Go to the documentation of this file.
1
16#ifndef __ECU_CANBUS_H__
17#define __ECU_CANBUS_H__
18
19#include <stdint.h>
20#include <stdlib.h>
21
22#include "CanBuffer.h"
23#include "CanBusAddresses.def"
24#include "CanbusConfig.def"
25#include "FlexCAN_T4.h"
26#include "WProgram.h"
27#include "module.hpp"
28
33namespace CAN {
34
35class Canbus_t : public Module::Module_t {
36public:
37 inline static LOG_TAG ID = "Canbus";
38
39 using Module::Module_t::Module_t;
40
44 void setup(void);
45
49 void run(void);
50
57 static void enableInterrupts(bool enable);
58
67 static void getData(const uint32_t address, uint8_t buf[8]);
68
78 static constexpr Buffer *getBuffer(const uint32_t address);
79
90 static void setCallback(const uint32_t address, canCallback callback);
91
98 static void pushData(const uint32_t address);
99
105 static void sendData(Buffer &buf);
106
115 static void sendData(const uint32_t address, uint8_t buf[8]);
116
132 static void sendData(const uint32_t address, const uint8_t buf_0 = 0, const uint8_t buf_1 = 0, const uint8_t buf_2 = 0, const uint8_t buf_3 = 0, const uint8_t buf_4 = 0, const uint8_t buf_5 = 0, const uint8_t buf_6 = 0, const uint8_t buf_7 = 0);
133
138 static void enableCanbusSniffer(bool enable);
139};
140
141} // namespace CAN
142
143const CAN::Canbus_t Canbus;
144
145#endif // __ECU_CANBUS_H__
Define incoming CAN line addresses.
Configure canbus functionality.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Definition Log.h:48
static void enableCanbusSniffer(bool enable)
continuously prints out strings of any message that is received through canbus. As such,...
static void sendData(const uint32_t address, const uint8_t buf_0=0, const uint8_t buf_1=0, const uint8_t buf_2=0, const uint8_t buf_3=0, const uint8_t buf_4=0, const uint8_t buf_5=0, const uint8_t buf_6=0, const uint8_t buf_7=0)
Send raw data over a given canbus address using given values.
static void sendData(Buffer &buf)
Send data given a buffer object.
static void sendData(const uint32_t address, uint8_t buf[8])
Send raw data over a given canbus address using a given array.
void setup(void)
Setup the Canbus line.
static void setCallback(const uint32_t address, canCallback callback)
Set a callback to an incoming address. If an incoming address buffer is updated it will call the give...
static void getData(const uint32_t address, uint8_t buf[8])
Get raw data from a canbus address.
void run(void)
Run the teensy Canbus line.
static constexpr Buffer * getBuffer(const uint32_t address)
Get the buffer of an any address. If it is outgoing, use pushData to push the data after modifying th...
static void pushData(const uint32_t address)
queue and address's buffer to be pushed. Invalid addresses will not do anything.
static void enableInterrupts(bool enable)
Enable mailbox interrupts, allowing values to automaticaly update. Enabled by default.
Module_t should be used for major components of a framework, it is used to isolate,...
Canbus functionality. Refer to Canbus.h for more info.
Definition CanBuffer.cpp:4
void(* canCallback)(uint32_t, volatile uint8_t *)
The function type to pass to addCallback.
Definition CanBuffer.h:17
An incoming canbus message, allows the message data to be interpreted through a simple wrapper class.
Definition CanBuffer.h:23