7 years, 2 months ago.

Take I2C Data and trasmit to CAN

Hello,

Doing a university project using a time of flight sensor which uses the I2C protocol. I am getting it printing on a terminal output (coolterm), however, I want to transmit the data onto the CAN bus. I have attached my code that I have started assembling:

  1. include "mbed.h"
  2. include "main.cpp"

Ticker ticker; CAN can1(p30, p29); rd, td

int main() { char data[1] = {0}; can.frequency(125000); CANMessage msg(&sensor); msg.data[0] = 7; 8 bits while(1) { can.write(&msg); } }

  • &sensor is a reference to what is being printed on the screen from my main programme, so hopefully the numbers which the sensor is retrieving
Be the first to answer this question.