-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[platform] Add CANFD large frame support
- Loading branch information
1 parent
c347f00
commit e4b1a4a
Showing
17 changed files
with
258 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2022, Rasmus Kleist Hørlyck Sørensen | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include <modm/board.hpp> | ||
#include <modm/debug/logger.hpp> | ||
#include <modm/board.hpp> | ||
|
||
using namespace modm::literals; | ||
|
||
// Set the log level | ||
#undef MODM_LOG_LEVEL | ||
#define MODM_LOG_LEVEL modm::log::INFO | ||
|
||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
|
||
MODM_LOG_INFO << "CAN Test Program" << modm::endl; | ||
|
||
MODM_LOG_INFO << "Initializing Fdcan1..." << modm::endl; | ||
// Initialize Fdcan1 | ||
Fdcan1::connect<GpioB8::Rx, GpioB9::Tx>(Gpio::InputType::PullUp); | ||
Fdcan1::initialize<Board::SystemClock, 125_kbps, 1_pct, 500_kbps>(9); | ||
|
||
MODM_LOG_INFO << "Setting up Filter for Fdcan1..." << modm::endl; | ||
// Receive every extended id message | ||
Fdcan1::setExtendedFilter(0, Fdcan1::FilterConfig::Fifo0, | ||
modm::can::ExtendedIdentifier(0), | ||
modm::can::ExtendedMask(0)); | ||
|
||
MODM_LOG_INFO << "Initializing Fdcan2..." << modm::endl; | ||
// Initialize Fdcan2 | ||
Fdcan2::connect<GpioB5::Rx, GpioB6::Tx>(Gpio::InputType::PullUp); | ||
Fdcan2::initialize<Board::SystemClock, 125_kbps, 1_pct, 500_kbps>(12); | ||
|
||
MODM_LOG_INFO << "Setting up Filter for Fdcan2..." << modm::endl; | ||
// Receive every message | ||
Fdcan2::setExtendedFilter(0, Fdcan2::FilterConfig::Fifo0, | ||
modm::can::ExtendedIdentifier(0), | ||
modm::can::ExtendedMask(0)); | ||
|
||
// Send a message | ||
MODM_LOG_INFO << "Sending message on Fdcan1..." << modm::endl; | ||
modm::can::Message msg(1, 1); | ||
msg.setExtended(true); | ||
msg.data[0] = 0x11; | ||
Fdcan1::sendMessage(msg); | ||
|
||
// Send a message | ||
MODM_LOG_INFO << "Sending message on Fdcan2..." << modm::endl; | ||
msg.data[0] = 0x22; | ||
Fdcan2::sendMessage(msg); | ||
|
||
// Send a message | ||
MODM_LOG_INFO << "Sending message on Fdcan1..." << modm::endl; | ||
modm::can::Message longMsg(2, 32); | ||
longMsg.setExtended(true); | ||
for (uint8_t i = 0; i < 32; i++) longMsg.data[i] = i; | ||
Fdcan1::sendMessage(longMsg); | ||
|
||
// Send a message | ||
MODM_LOG_INFO << "Sending message on Fdcan2..." << modm::endl; | ||
longMsg.data[0] = 0x22; | ||
Fdcan2::sendMessage(longMsg); | ||
|
||
while (true) | ||
{ | ||
if (Fdcan1::isMessageAvailable()) | ||
{ | ||
MODM_LOG_INFO << "Fdcan1: Message is available..." << modm::endl; | ||
modm::can::Message message; | ||
Fdcan1::getMessage(message); | ||
MODM_LOG_INFO << message << modm::endl; | ||
} | ||
if (Fdcan2::isMessageAvailable()) | ||
{ | ||
MODM_LOG_INFO << "Fdcan2: Message is available..." << modm::endl; | ||
modm::can::Message message; | ||
Fdcan2::getMessage(message); | ||
MODM_LOG_INFO << message << modm::endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<library> | ||
<extends>modm:nucleo-g474re</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_g474re/fdcan</option> | ||
<option name="modm:architecture:can:message.buffer">64</option> | ||
</options> | ||
<modules> | ||
<module>modm:debug</module> | ||
<module>modm:platform:can:1</module> | ||
<module>modm:platform:can:2</module> | ||
<module>modm:platform:gpio</module> | ||
<module>modm:platform:uart:2</module> | ||
<module>modm:build:scons</module> | ||
</modules> | ||
</library> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.