CAN for KL64F. No implementation for CAN class Find DEVICE_CAN macro in files to diagnose problems
main.cpp@0:5d2bea7f2b45, 2016-11-09 (annotated)
- Committer:
- marcus255
- Date:
- Wed Nov 09 20:10:33 2016 +0000
- Revision:
- 0:5d2bea7f2b45
KL64F CAN project. Initial version. Find DEVICE_CAN macro in mbed-dev sources
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcus255 | 0:5d2bea7f2b45 | 1 | #include "mbed.h" |
marcus255 | 0:5d2bea7f2b45 | 2 | |
marcus255 | 0:5d2bea7f2b45 | 3 | void sw_2_pushed(); |
marcus255 | 0:5d2bea7f2b45 | 4 | void send(); |
marcus255 | 0:5d2bea7f2b45 | 5 | |
marcus255 | 0:5d2bea7f2b45 | 6 | DigitalOut led_G(LED_GREEN); |
marcus255 | 0:5d2bea7f2b45 | 7 | DigitalOut led_B(LED_BLUE); |
marcus255 | 0:5d2bea7f2b45 | 8 | Serial pc(USBTX, USBRX); |
marcus255 | 0:5d2bea7f2b45 | 9 | InterruptIn sw2(SW2); |
marcus255 | 0:5d2bea7f2b45 | 10 | InterruptIn sw3(SW3); |
marcus255 | 0:5d2bea7f2b45 | 11 | CAN can(PTB19, PTB18); |
marcus255 | 0:5d2bea7f2b45 | 12 | int counter; |
marcus255 | 0:5d2bea7f2b45 | 13 | |
marcus255 | 0:5d2bea7f2b45 | 14 | void sw_2_pushed(){ |
marcus255 | 0:5d2bea7f2b45 | 15 | pc.printf("SW1 PUSHED\r\n"); |
marcus255 | 0:5d2bea7f2b45 | 16 | // send(); |
marcus255 | 0:5d2bea7f2b45 | 17 | } |
marcus255 | 0:5d2bea7f2b45 | 18 | |
marcus255 | 0:5d2bea7f2b45 | 19 | /*void send() { |
marcus255 | 0:5d2bea7f2b45 | 20 | pc.printf("send()\n"); |
marcus255 | 0:5d2bea7f2b45 | 21 | if(can.write(CANMessage(1337, &counter, 1))) { |
marcus255 | 0:5d2bea7f2b45 | 22 | pc.printf("wloop()\n"); |
marcus255 | 0:5d2bea7f2b45 | 23 | counter++; |
marcus255 | 0:5d2bea7f2b45 | 24 | pc.printf("Message sent: %d\n", counter); |
marcus255 | 0:5d2bea7f2b45 | 25 | } |
marcus255 | 0:5d2bea7f2b45 | 26 | led_G = !led_G; |
marcus255 | 0:5d2bea7f2b45 | 27 | }*/ |
marcus255 | 0:5d2bea7f2b45 | 28 | |
marcus255 | 0:5d2bea7f2b45 | 29 | int main() |
marcus255 | 0:5d2bea7f2b45 | 30 | { |
marcus255 | 0:5d2bea7f2b45 | 31 | sw2.rise(&sw_2_pushed); |
marcus255 | 0:5d2bea7f2b45 | 32 | pc.printf("Hello World!\n"); |
marcus255 | 0:5d2bea7f2b45 | 33 | |
marcus255 | 0:5d2bea7f2b45 | 34 | while (true) { |
marcus255 | 0:5d2bea7f2b45 | 35 | wait(0.5f); // wait a small period of time |
marcus255 | 0:5d2bea7f2b45 | 36 | led_B = !led_B; // toggle a led |
marcus255 | 0:5d2bea7f2b45 | 37 | } |
marcus255 | 0:5d2bea7f2b45 | 38 | } |