-
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.
[example] Add Feather M4 usbserial example
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2016-2017, Niklas Hauser | ||
* Copyright (c) 2022, Christopher Durand | ||
* Copyright (c) 2023, Thomas Rush | ||
* | ||
* 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/processing/timer.hpp> | ||
|
||
using namespace Board; | ||
|
||
modm::IODeviceWrapper<UsbUart0, modm::IOBuffer::BlockIfFull> usb_io_device; | ||
modm::IOStream usb_stream(usb_io_device); | ||
|
||
int | ||
main() | ||
{ | ||
initialize(); | ||
initializeUsbFs(); | ||
|
||
tusb_init(); | ||
|
||
uint32_t counter(0); | ||
|
||
modm::PeriodicTimer timer{500ms}; | ||
|
||
while (not timer.execute()) { | ||
tud_task(); | ||
} | ||
|
||
// it can be hard to catch this without the preceding delay | ||
usb_stream << "Hello from USB" << modm::endl; | ||
|
||
while (true) | ||
{ | ||
tud_task(); | ||
if (timer.execute()) { | ||
Led::toggle(); | ||
usb_stream << "loop: " << counter++ << 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,12 @@ | ||
<library> | ||
<extends>modm:feather-m4</extends> | ||
<options> | ||
<option name="modm:tinyusb:config">device.cdc</option> | ||
<option name="modm:build:build.path">../../../build/feather_m4/usbserial</option> | ||
</options> | ||
<modules> | ||
<module>modm:tinyusb</module> | ||
<module>modm:build:scons</module> | ||
<module>modm:processing:timer</module> | ||
</modules> | ||
</library> |