Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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:
- include "mbed.h"
- 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