Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_PLC01A1 ros_lib_melodic
can_controller.cpp@1:ef4b86795d79, 2020-08-15 (annotated)
- Committer:
- yamadola
- Date:
- Sat Aug 15 09:09:33 2020 +0000
- Revision:
- 1:ef4b86795d79
- Parent:
- 0:43eb9ccc1583
- Child:
- 3:ea5cfd721b53
whole program without debugs
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yamadola | 0:43eb9ccc1583 | 1 | #include "can_controller.h" |
| yamadola | 0:43eb9ccc1583 | 2 | |
| yamadola | 0:43eb9ccc1583 | 3 | /** |
| yamadola | 0:43eb9ccc1583 | 4 | * @brief Initialize CAN controller |
| yamadola | 0:43eb9ccc1583 | 5 | * @param None |
| yamadola | 0:43eb9ccc1583 | 6 | */ |
| yamadola | 1:ef4b86795d79 | 7 | CANController::CANController():can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD){} |
| yamadola | 0:43eb9ccc1583 | 8 | |
| yamadola | 0:43eb9ccc1583 | 9 | /** |
| yamadola | 0:43eb9ccc1583 | 10 | * @brief Send CAN message |
| yamadola | 0:43eb9ccc1583 | 11 | * @param ID: CAN ID of the target device |
| yamadola | 0:43eb9ccc1583 | 12 | * @param msgData: Address of the message data to be sent |
| yamadola | 0:43eb9ccc1583 | 13 | * @retval 0: Transmission is successful, -1:Transmission is failed |
| yamadola | 0:43eb9ccc1583 | 14 | */ |
| yamadola | 0:43eb9ccc1583 | 15 | int CANController::sendMessage( uint16_t ID, char *msgData ){ |
| yamadola | 0:43eb9ccc1583 | 16 | CANMessage msg(ID, msgData, 8, CANData, CANStandard); |
| yamadola | 0:43eb9ccc1583 | 17 | int successFlag = can1.write(msg); |
| yamadola | 0:43eb9ccc1583 | 18 | if(successFlag){ |
| yamadola | 0:43eb9ccc1583 | 19 | return 0; |
| yamadola | 0:43eb9ccc1583 | 20 | }else{ |
| yamadola | 0:43eb9ccc1583 | 21 | return -1; |
| yamadola | 0:43eb9ccc1583 | 22 | } |
| yamadola | 0:43eb9ccc1583 | 23 | } |