Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- maxnagazumi
- Date:
- 2021-12-15
- Revision:
- 1:32f484ba74a2
- Parent:
- 0:33432ad74af7
File content as of revision 1:32f484ba74a2:
#include "mbed.h"
CAN can(p30,p29);
Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
char can_data1[2]= {0,0};
int data1=0;
CANMessage msg1;
int y;
void can1()
{
can_data1[0]=data1>>8;
can_data1[1]=data1&255;
if(can.write(CANMessage(1,can_data1,2))) {
led1 =1;
led2=0;
printf("can1 send\r\n");
} else {
led1=0;
led2=1;
printf("can1 no send\r\n");
}
if (can1.read(msg1))
{
if (msg1.id == 2)
{
y = (short)((msg1.data[0] << 8) | msg1.data[1]);
if(y==1000){
printf("get responese from can2\r\n");
data1++;
if(data1>1000)data1=1000;
}
}
}
}
int main()
{
can1.frequency(1000000);
ticker.attach(&can1,0.001);
}