Andrei Carp
/
mbed_can_test
test
main.cpp@0:e443527d2afd, 2018-04-02 (annotated)
- Committer:
- andreixc
- Date:
- Mon Apr 02 13:18:13 2018 +0000
- Revision:
- 0:e443527d2afd
1st
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andreixc | 0:e443527d2afd | 1 | #include "mbed.h" |
andreixc | 0:e443527d2afd | 2 | |
andreixc | 0:e443527d2afd | 3 | DigitalOut ledTest(LED1); |
andreixc | 0:e443527d2afd | 4 | CAN HSCAN(p30, p29); |
andreixc | 0:e443527d2afd | 5 | CAN MSCAN(p9,p10); |
andreixc | 0:e443527d2afd | 6 | |
andreixc | 0:e443527d2afd | 7 | int main() |
andreixc | 0:e443527d2afd | 8 | { |
andreixc | 0:e443527d2afd | 9 | printf("START...."); |
andreixc | 0:e443527d2afd | 10 | unsigned long counter = 0; |
andreixc | 0:e443527d2afd | 11 | ledTest = 1; |
andreixc | 0:e443527d2afd | 12 | |
andreixc | 0:e443527d2afd | 13 | HSCAN.frequency(500000); |
andreixc | 0:e443527d2afd | 14 | MSCAN.frequency(125000); |
andreixc | 0:e443527d2afd | 15 | |
andreixc | 0:e443527d2afd | 16 | |
andreixc | 0:e443527d2afd | 17 | while(1) |
andreixc | 0:e443527d2afd | 18 | { |
andreixc | 0:e443527d2afd | 19 | if(HSCAN.write(CANMessage(0x726, (char *)&counter, sizeof(counter)))) |
andreixc | 0:e443527d2afd | 20 | { |
andreixc | 0:e443527d2afd | 21 | printf("wloop()\r\n"); |
andreixc | 0:e443527d2afd | 22 | counter++; |
andreixc | 0:e443527d2afd | 23 | printf("Message sent: %d\r\n", counter); |
andreixc | 0:e443527d2afd | 24 | printf("TDERROR : %d\r\n", HSCAN.tderror()); |
andreixc | 0:e443527d2afd | 25 | } |
andreixc | 0:e443527d2afd | 26 | /*if(MSCAN.write(CANMessage(0x731, (char *)&counter, sizeof(counter)))) |
andreixc | 0:e443527d2afd | 27 | { |
andreixc | 0:e443527d2afd | 28 | printf("wloop()\n"); |
andreixc | 0:e443527d2afd | 29 | counter++; |
andreixc | 0:e443527d2afd | 30 | printf("Message sent: %d\r\n", counter); |
andreixc | 0:e443527d2afd | 31 | }*/ |
andreixc | 0:e443527d2afd | 32 | ledTest = !ledTest; |
andreixc | 0:e443527d2afd | 33 | wait(0.5); |
andreixc | 0:e443527d2afd | 34 | } |
andreixc | 0:e443527d2afd | 35 | |
andreixc | 0:e443527d2afd | 36 | return 0; |
andreixc | 0:e443527d2afd | 37 | } |