
ECU Test FSRA 2020/2021
Revision 0:bf53f0550be8, committed 2021-04-14
- Comitter:
- minamax
- Date:
- Wed Apr 14 12:47:50 2021 +0000
- Commit message:
- First commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r bf53f0550be8 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 14 12:47:50 2021 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" +//UART PINS (TX, RX, BAUDRATE) +Serial pc(PB_13, PB_12, 9600); +Serial pc2(PF_7, PF_6, 9600); + +//CAN PINS (RX, TX) +CAN can(PA_11, PA_12); +CANMessage message; + +void callback(){ + //UART RECEIVE + char byte; + pc.printf("callback"); + if(pc.readable()){ + byte = pc.getc(); + pc.printf("I received %c\n", byte); + } +} + +void callbackCAN(){ + //CAN RECEIVE + can.read(message); + //CAN SEND + can.write(message); +} + +int main(){ + //UART INIT + //pc.attach(&callback); + pc2.attach(&callback); + + //CAN INIT + can.frequency(100000); + can.attach(callbackCAN); + + while(1){ + //UART SEND + pc2.printf("Hi Marta and Mina. I am ECU!\n"); + + //CAN SEND + message.id = 0x01; + message.data[1] = 0x48; // repeat for each byte. + can.write(message); + + wait(2); + } + +} \ No newline at end of file
diff -r 000000000000 -r bf53f0550be8 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 14 12:47:50 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file