For RevB MBED Hardware, with the new boot sequence. This example establishes a transparent link between the mbed USB CDC port and the modem (LISA) on the C027. You can use it to use the standard u-blox tools such as m-center or any terminal program. These tools can then connect to the serial port and talk directly to the modem. Baudrate should be set to 115200 baud and is fixed. m-center can be downloaded from u-blox website following this link: http://www.u-blox.com/en/evaluation-tools-a-software/u-center/m-center.html
Dependencies: C027-REVB UbloxUSBModem mbed
main.cpp@2:c4ad86683060, 2013-12-14 (annotated)
- Committer:
- dixter1
- Date:
- Sat Dec 14 00:24:59 2013 +0000
- Revision:
- 2:c4ad86683060
- Parent:
- 1:15b5edb4a91f
First revision working, messages going between two LISA C027 boards across the CAN interface.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dixter1 | 0:92ab4f4846f8 | 1 | #include "mbed.h" |
dixter1 | 0:92ab4f4846f8 | 2 | #include "C027.h" |
dixter1 | 0:92ab4f4846f8 | 3 | |
dixter1 | 2:c4ad86683060 | 4 | Ticker ticker; |
dixter1 | 2:c4ad86683060 | 5 | DigitalOut led1(LED); |
dixter1 | 2:c4ad86683060 | 6 | DigitalOut led2(LED1); |
dixter1 | 2:c4ad86683060 | 7 | CAN can1(CANRD, CANTD); |
dixter1 | 2:c4ad86683060 | 8 | Serial pc(USBTX, USBRX); |
dixter1 | 0:92ab4f4846f8 | 9 | |
dixter1 | 2:c4ad86683060 | 10 | char counter = 0; |
dixter1 | 0:92ab4f4846f8 | 11 | |
dixter1 | 2:c4ad86683060 | 12 | void send() { |
dixter1 | 2:c4ad86683060 | 13 | if(can1.write(CANMessage(1337, &counter, 1))) { |
dixter1 | 2:c4ad86683060 | 14 | pc.printf("Message sent: %d\r\n", counter); |
dixter1 | 2:c4ad86683060 | 15 | counter++; |
dixter1 | 0:92ab4f4846f8 | 16 | } |
dixter1 | 2:c4ad86683060 | 17 | led1 = !led1; |
dixter1 | 2:c4ad86683060 | 18 | } |
dixter1 | 2:c4ad86683060 | 19 | |
dixter1 | 2:c4ad86683060 | 20 | int main() { |
dixter1 | 2:c4ad86683060 | 21 | |
dixter1 | 2:c4ad86683060 | 22 | DigitalOut can_standby(CANS); |
dixter1 | 2:c4ad86683060 | 23 | |
dixter1 | 2:c4ad86683060 | 24 | // enable the CAN interface |
dixter1 | 2:c4ad86683060 | 25 | // take it out of standby |
dixter1 | 2:c4ad86683060 | 26 | can_standby = 0; |
dixter1 | 2:c4ad86683060 | 27 | |
dixter1 | 0:92ab4f4846f8 | 28 | pc.baud(MDMBAUD); |
dixter1 | 0:92ab4f4846f8 | 29 | |
dixter1 | 2:c4ad86683060 | 30 | pc.printf( "Starting CAN Testing\r\n"); |
dixter1 | 2:c4ad86683060 | 31 | |
dixter1 | 2:c4ad86683060 | 32 | CANMessage msg; |
dixter1 | 2:c4ad86683060 | 33 | while(1) { |
dixter1 | 2:c4ad86683060 | 34 | |
dixter1 | 2:c4ad86683060 | 35 | if(can1.read(msg)) { |
dixter1 | 2:c4ad86683060 | 36 | pc.printf("Message received: %d\r\n", msg.data[0]); |
dixter1 | 2:c4ad86683060 | 37 | led2 = !led2; |
dixter1 | 0:92ab4f4846f8 | 38 | } |
dixter1 | 0:92ab4f4846f8 | 39 | |
dixter1 | 2:c4ad86683060 | 40 | wait(0.2); |
dixter1 | 2:c4ad86683060 | 41 | |
dixter1 | 2:c4ad86683060 | 42 | send(); |
dixter1 | 0:92ab4f4846f8 | 43 | } |
dixter1 | 0:92ab4f4846f8 | 44 | } |
dixter1 | 2:c4ad86683060 | 45 | |
dixter1 | 2:c4ad86683060 | 46 |