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
Revision 1:f0e74f06b93b, committed 2021-12-15
- Comitter:
- maxnagazumi
- Date:
- Wed Dec 15 09:51:00 2021 +0000
- Parent:
- 0:33432ad74af7
- Commit message:
- a
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Mar 04 09:33:28 2020 +0000 +++ b/main.cpp Wed Dec 15 09:51:00 2021 +0000 @@ -1,34 +1,41 @@ #include "mbed.h" - -CAN can1(PB_5,PB_13); +Serial pc(USBTX, USBRX); +CAN can1(p30,p29); +//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() +DigitalOut led1(LED1); +//DigitalOut led2(LED2); +//DigitalOut led3(LED3); +//DigitalOut led4(LED4); + +char can_data1[1]; +int data1=10; +CANMessage msg1; +void cansend() { - 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"); + can_data1[0]=data1&255; + if(can1.write(CANMessage(0,can_data1,1))) { + led1=1; + //led2=0; + //led3=0; + //led4=0; + pc.printf("can1 send\r\n"); + } else { + led1=0; + pc.printf("can1 no send\r\n"); } } - int main() { + led1=1; + /*led2=1; + led3=1; + led4=1;*/ + wait(0.5); + led1=0; + /*led2=0; + led3=0; + led4=0;*/ can1.frequency(1000000); - ticker.attach(&can_read,0.01); -} + ticker.attach(&cansend,0.001); +} \ No newline at end of file