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:
- 2020-03-04
- Revision:
- 0:33432ad74af7
- Child:
- 1:32f484ba74a2
File content as of revision 0:33432ad74af7:
#include "mbed.h"
CAN can1(PB_5,PB_13);
Ticker ticker;
DigitalIn button(USER_BUTTON);
int x;
char can_data2[2]= {0,0};
int data2;
void can_read()
{
x=100;
CANMessage msg;
if(can1.read(msg)) {
if(msg.id == 1) {
x=(short)((msg.data[0]<<8)|msg.data[1]);
} else {
x=200;
}
}
printf("%d\r\n",x);
data2=1000;
can_data2[0]=data2>>8;
can_data2[1]=data2&255;
if(can1.write(CANMessage(2,can_data2,2))) {
printf("send\r\n");
}
}
int main()
{
can1.frequency(1000000);
ticker.attach(&can_read,0.01);
}