老 姚
/
CANBUSTest
CANBUS Test
main.cpp@0:6da715211ca6, 2018-04-19 (annotated)
- Committer:
- yao6116601
- Date:
- Thu Apr 19 13:23:19 2018 +0000
- Revision:
- 0:6da715211ca6
modular2 CANBUS testing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yao6116601 | 0:6da715211ca6 | 1 | #include "mbed.h" |
yao6116601 | 0:6da715211ca6 | 2 | |
yao6116601 | 0:6da715211ca6 | 3 | DigitalOut myled(D8); |
yao6116601 | 0:6da715211ca6 | 4 | CAN can1(PD_0, PD_1,500000); |
yao6116601 | 0:6da715211ca6 | 5 | int main() { |
yao6116601 | 0:6da715211ca6 | 6 | CANMessage msg; |
yao6116601 | 0:6da715211ca6 | 7 | while(1) { |
yao6116601 | 0:6da715211ca6 | 8 | if(can1.read(msg)) { |
yao6116601 | 0:6da715211ca6 | 9 | printf("Message received:id=%d,type=%d,%d\n", msg.id,msg.type,msg.data[0]); |
yao6116601 | 0:6da715211ca6 | 10 | myled = !myled; |
yao6116601 | 0:6da715211ca6 | 11 | |
yao6116601 | 0:6da715211ca6 | 12 | } |
yao6116601 | 0:6da715211ca6 | 13 | } |
yao6116601 | 0:6da715211ca6 | 14 | } |