-
Notifications
You must be signed in to change notification settings - Fork 152
DMA for more STM32 controllers #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
00b50e0
[ext] update modm-devices
rleh 6562f17
[platform] STM32 SpiMaster_Dma: Fix for non-Fifo devices
rleh 0a507aa
[platform] DMA: Enable for many more stm32-channel(-request) devices
rleh ebcffdf
[examples] Nucleo-F303RE: SPI-DMA example
rleh 8ca2f35
[examples] Nucleo-F042K6: SPI-DMA example
rleh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,43 @@ | ||
/* | ||
* Copyright (c) 2020, Mike Wolfram | ||
* Copyright (c) 2021, Raphael Lehmann | ||
* | ||
* 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> | ||
|
||
using Mosi = GpioOutputB5; | ||
using Miso = GpioInputB4; | ||
using Sck = GpioOutputB3; | ||
using DmaRx = Dma1::Channel2; | ||
using DmaTx = Dma1::Channel3; | ||
using Spi = SpiMaster1_Dma<DmaRx, DmaTx>; | ||
|
||
int main() | ||
{ | ||
Board::initialize(); | ||
|
||
Dma1::enable(); | ||
Spi::connect<Mosi::Mosi, Miso::Miso, Sck::Sck>(); | ||
Spi::initialize<Board::SystemClock, 12_MHz>(); | ||
|
||
while (true) | ||
{ | ||
uint8_t sendBuffer[13] { "data to send" }; | ||
uint8_t receiveBuffer[13]; | ||
|
||
// send out 12 bytes, don't care about response | ||
Spi::transferBlocking(sendBuffer, nullptr, 12); | ||
|
||
// send out 12 bytes, read in 12 bytes | ||
Spi::transferBlocking(sendBuffer, receiveBuffer, 12); | ||
} | ||
|
||
return 0; | ||
} |
This file contains hidden or 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,12 @@ | ||
<library> | ||
<extends>modm:nucleo-f042k6</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_f042k6/spi_dma</option> | ||
</options> | ||
<modules> | ||
<module>modm:platform:gpio</module> | ||
<module>modm:platform:dma</module> | ||
<module>modm:platform:spi:1</module> | ||
<module>modm:build:scons</module> | ||
</modules> | ||
</library> |
This file contains hidden or 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,43 @@ | ||
/* | ||
* Copyright (c) 2020, Mike Wolfram | ||
* Copyright (c) 2021, Raphael Lehmann | ||
* | ||
* 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> | ||
|
||
using Mosi = GpioOutputB5; | ||
using Miso = GpioInputB4; | ||
using Sck = GpioOutputB3; | ||
using DmaRx = Dma1::Channel2; | ||
using DmaTx = Dma1::Channel3; | ||
using Spi = SpiMaster1_Dma<DmaRx, DmaTx>; | ||
|
||
int main() | ||
{ | ||
Board::initialize(); | ||
|
||
Dma1::enable(); | ||
Spi::connect<Mosi::Mosi, Miso::Miso, Sck::Sck>(); | ||
Spi::initialize<Board::SystemClock, 8_MHz>(); | ||
|
||
while (true) | ||
{ | ||
uint8_t sendBuffer[13] { "data to send" }; | ||
uint8_t receiveBuffer[13]; | ||
|
||
// send out 12 bytes, don't care about response | ||
Spi::transferBlocking(sendBuffer, nullptr, 12); | ||
|
||
// send out 12 bytes, read in 12 bytes | ||
Spi::transferBlocking(sendBuffer, receiveBuffer, 12); | ||
} | ||
|
||
return 0; | ||
} |
This file contains hidden or 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,12 @@ | ||
<library> | ||
<extends>modm:nucleo-f303re</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_f303re/spi_dma</option> | ||
</options> | ||
<modules> | ||
<module>modm:platform:gpio</module> | ||
<module>modm:platform:dma</module> | ||
<module>modm:platform:spi:1</module> | ||
<module>modm:build:scons</module> | ||
</modules> | ||
</library> |
Submodule modm-devices
updated
10 files
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.