SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
CAN::Canbus_t Class Reference
Inheritance diagram for CAN::Canbus_t:
Module::Module_t

Public Member Functions

void setup (void)
 Setup the Canbus line.
 
void run (void)
 Run the teensy Canbus line.
 
- Public Member Functions inherited from Module::Module_t
virtual int getClassID () const
 
template<typename... T>
 Module_t (T *...mods)
 

Static Public Member Functions

static void enableInterrupts (bool enable)
 Enable mailbox interrupts, allowing values to automaticaly update. Enabled by default.
 
static void getData (const uint32_t address, uint8_t buf[8])
 Get raw data from a canbus address.
 
static constexpr BuffergetBuffer (const uint32_t address)
 Get the buffer of an any address. If it is outgoing, use pushData to push the data after modifying the buffer. Invalid addresses will return a buffer that is ignored.
 
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 given function. Keep callbacks quick and simple.
 
static void pushData (const uint32_t address)
 queue and address's buffer to be pushed. Invalid addresses will not do anything.
 
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.
 
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 enableCanbusSniffer (bool enable)
 continuously prints out strings of any message that is received through canbus. As such, this function only works when the ECU is in ascii debug mode.
 

Static Public Attributes

static LOG_TAG ID = "Canbus"
 
- Static Public Attributes inherited from Module::Module_t
static const int classID = 0
 

Additional Inherited Members

- Protected Member Functions inherited from Module::Module_t
virtual void print ()
 
- Protected Attributes inherited from Module::Module_t
const bitmapVal_t id
 

Detailed Description

Definition at line 35 of file Canbus.h.

Member Function Documentation

◆ enableInterrupts()

static void CAN::Canbus_t::enableInterrupts ( bool  enable)
static

Enable mailbox interrupts, allowing values to automaticaly update. Enabled by default.

Parameters
enableboolean

◆ getBuffer()

static constexpr Buffer * CAN::Canbus_t::getBuffer ( const uint32_t  address)
staticconstexpr

Get the buffer of an any address. If it is outgoing, use pushData to push the data after modifying the buffer. Invalid addresses will return a buffer that is ignored.

Note
buffers that are for incoming addresses should not be modified, but can be monitored
use setSemaphore before using the given pointer while interrupts are active as undefined behavior may occur, alternatively, use a Buffer struct
Parameters
addressThe address
Returns
volatile uint8_t[8] buffer array of the message, length 8

◆ getData()

static void CAN::Canbus_t::getData ( const uint32_t  address,
uint8_t  buf[8] 
)
static

Get raw data from a canbus address.

Note
Only valid incoming addresses will put data onto the given buffer
Parameters
addressThe incoming address
bufthe buffer to copy data to

◆ pushData()

static void CAN::Canbus_t::pushData ( const uint32_t  address)
static

queue and address's buffer to be pushed. Invalid addresses will not do anything.

Parameters
addressThe outgoing address

◆ sendData() [1/3]

static void CAN::Canbus_t::sendData ( Buffer buf)
static

Send data given a buffer object.

Parameters
bufThe buffer object to use

◆ sendData() [2/3]

static void CAN::Canbus_t::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 
)
static

Send raw data over a given canbus address using given values.

Note
Function does not verify that address is outgoing, undefined behavior may occur if data is sent thorugh an incoming address
Parameters
addressThe outgoing address
buf_0byte 0 of the outgoing buffer
buf_1byte 1 of the outgoing buffer
buf_2byte 2 of the outgoing buffer
buf_3byte 3 of the outgoing buffer
buf_4byte 4 of the outgoing buffer
buf_5byte 5 of the outgoing buffer
buf_6byte 6 of the outgoing buffer
buf_7byte 7 of the outgoing buffer

◆ sendData() [3/3]

static void CAN::Canbus_t::sendData ( const uint32_t  address,
uint8_t  buf[8] 
)
static

Send raw data over a given canbus address using a given array.

Note
Function does not verify that address is outgoing, undefined behavior will occur if data is sent thorugh an incoming address
Parameters
addressThe outgoing address
bufThe buffer array to be sent

◆ setCallback()

static void CAN::Canbus_t::setCallback ( const uint32_t  address,
canCallback  callback 
)
static

Set a callback to an incoming address. If an incoming address buffer is updated it will call the given function. Keep callbacks quick and simple.

Note
Only one callback per address

If the semaphore is set to the given address the callback will not be called. Semaphores do not have to be used within the function to read from the given buffer.

Parameters
addressThe incoming address
callbackThe callback function, refer to canCallback

◆ setup()

void CAN::Canbus_t::setup ( void  )
virtual

Setup the Canbus line.

Reimplemented from Module::Module_t.

Member Data Documentation

◆ ID

LOG_TAG CAN::Canbus_t::ID = "Canbus"
inlinestatic

Definition at line 37 of file Canbus.h.


The documentation for this class was generated from the following file: