-
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.
[rp2040] Add Adafruit Feather RP2040 board
- Loading branch information
cocasema
committed
Aug 16, 2022
1 parent
2ee1d3a
commit cea4f47
Showing
7 changed files
with
228 additions
and
11 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,39 @@ | ||
/* | ||
* Copyright (c) 2016, Sascha Schade | ||
* Copyright (c) 2017, Niklas Hauser | ||
* | ||
* 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 namespace Board; | ||
|
||
/* | ||
* Blinks the green user LED with 1 Hz. | ||
* It is on for 90% of the time and off for 10% of the time. | ||
*/ | ||
|
||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
|
||
Led::setOutput(); | ||
|
||
while (true) | ||
{ | ||
Led::set(); | ||
modm::delay(900ms); | ||
|
||
Led::reset(); | ||
modm::delay(100ms); | ||
} | ||
|
||
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,9 @@ | ||
<library> | ||
<extends>modm:feather-rp2040</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/feather_rp2040/blink</option> | ||
</options> | ||
<modules> | ||
<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022, Andrey Kunitsyn | ||
* Copyright (c) 2022, Nikolay Semenov | ||
* | ||
* 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/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#pragma once | ||
|
||
#include <modm/architecture/interface/clock.hpp> | ||
#include <modm/platform.hpp> | ||
|
||
using namespace modm::platform; | ||
|
||
namespace Board | ||
{ | ||
using namespace modm::literals; | ||
|
||
/// RP2040 running at 125MHz generated from the external 12MHz crystal | ||
/// @ingroup modm_board_feather_rp2040 | ||
struct SystemClock | ||
{ | ||
static constexpr uint32_t Frequency = 125_MHz; | ||
static constexpr uint32_t XOSCFrequency = 12_MHz; | ||
static constexpr uint32_t PllSysFrequency = Frequency; | ||
static constexpr uint32_t PllUsbFrequency = 48_MHz; | ||
static constexpr uint32_t SysPLLMul = 125; | ||
static constexpr uint32_t UsbPLLMul = 40; | ||
static constexpr uint32_t RefFrequency = XOSCFrequency; | ||
static constexpr uint32_t UsbFrequency = PllUsbFrequency; | ||
static constexpr uint32_t SysFrequency = Frequency; | ||
static constexpr uint32_t PeriFrequency = SysFrequency; | ||
|
||
static bool inline enable() | ||
{ | ||
ClockControl::disableResus(); | ||
ClockControl::enableExternalCrystal(XOSCFrequency); | ||
ClockControl::disableAux<ClockControl::Clock::Sys>(); | ||
ClockControl::disableAux<ClockControl::Clock::Ref>(); | ||
// PLL SYS: 12MHz / 1 = 12MHz * 125 = 1500MHZ / 6 / 2 = 125MHz | ||
ClockControl::initPll<ClockControl::Pll::Sys, 1, SysPLLMul, 6, 2>(); | ||
// PLL USB: 12MHz / 1 = 12MHz * 40 = 480 MHz / 5 / 2 = 48MHz | ||
ClockControl::initPll<ClockControl::Pll::Usb, 1, UsbPLLMul, 5, 2>(); | ||
|
||
// CLK_REF = XOSC (12MHz) / 1 = 12MHz | ||
ClockControl::configureClock<ClockControl::Clock::Ref, ClockControl::ClockSrc::Xosc, | ||
XOSCFrequency, RefFrequency>(); | ||
// CLK SYS = PLL SYS (125MHz) / 1 = 125MHz | ||
ClockControl::configureClock<ClockControl::Clock::Sys, ClockControl::ClockSrc::PllSys, | ||
PllSysFrequency, SysFrequency>(); | ||
// CLK USB = PLL USB (48MHz) / 1 = 48MHz | ||
ClockControl::configureClock<ClockControl::Clock::Usb, ClockControl::ClockSrc::PllUsb, | ||
PllUsbFrequency, UsbFrequency>(); | ||
// CLK PERI = clk_sys. Used as reference clock for Peripherals. No dividers so just select | ||
// and enable Normally choose clk_sys or clk_usb | ||
ClockControl::configureClock<ClockControl::Clock::Peri, ClockControl::ClockSrc::Sys, | ||
SysFrequency, PeriFrequency>(); | ||
|
||
ClockControl::updateCoreFrequency<Frequency>(); | ||
return true; | ||
} | ||
}; | ||
|
||
namespace usb | ||
{ | ||
/// @ingroup modm_board_feather_rp2040 | ||
using Device = Usb; | ||
} | ||
|
||
/// @ingroup modm_board_feather_rp2040 | ||
/// @{ | ||
// User LED | ||
using LedRed = GpioOutput13; | ||
using Led = LedRed; | ||
using Leds = SoftwareGpioPort<Led>; | ||
|
||
using Button = GpioUnused; | ||
|
||
inline void | ||
initialize() | ||
{ | ||
SystemClock::enable(); | ||
SysTickTimer::initialize<SystemClock>(); | ||
|
||
Led::setOutput(); | ||
} | ||
|
||
inline void | ||
initializeUsbFs(uint8_t priority=3) | ||
{ | ||
usb::Device::initialize<SystemClock>(priority); | ||
usb::Device::connect<>(); | ||
} | ||
/// @} | ||
|
||
} // namespace Board |
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,17 @@ | ||
<library> | ||
<repositories> | ||
<repository> | ||
<path>../../../../repo.lb</path> | ||
</repository> | ||
</repositories> | ||
|
||
<options> | ||
<option name="modm:target">rp2040</option> | ||
<option name="modm:platform:core:boot2">generic_03h</option> | ||
<option name="modm:platform:cortex-m:linkerscript.flash_size">8388608</option> | ||
<option name="modm:cmsis:device:xosc_startup_delay_multiplier">16</option> | ||
</options> | ||
<modules> | ||
<module>modm:board:feather-rp2040</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2022, Andrey Kunitsyn | ||
# Copyright (c) 2022, Nikolay Semenov | ||
# | ||
# 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/. | ||
# ----------------------------------------------------------------------------- | ||
|
||
def init(module): | ||
module.name = ":board:feather-rp2040" | ||
module.description = """\ | ||
# Adafruit Feather RP2040 | ||
A board with RP2040 chip and 8MB of flash memory. | ||
https://www.adafruit.com/product/4884 | ||
See https://modm.io/reference/config/modm-rp-pico for programming instructions. | ||
""" | ||
|
||
def prepare(module, options): | ||
if not options[":target"].partname.startswith("rp2040"): | ||
return False | ||
|
||
module.depends( | ||
":platform:clock", | ||
":platform:core", | ||
":platform:gpio", | ||
":platform:usb", | ||
":platform:clockgen") | ||
return True | ||
|
||
def build(env): | ||
env.outbasepath = "modm/src/modm/board" | ||
env.substitutions = { | ||
"with_logger": False, | ||
"with_assert": env.has_module(":architecture:assert") | ||
} | ||
env.template("../board.cpp.in", "board.cpp") | ||
env.copy('.') | ||
|
||
env.outbasepath = "modm/openocd/modm/board/" | ||
env.copy(repopath("tools/openocd/modm/rp2040_picoprobe.cfg"), "rp2040_picoprobe.cfg") | ||
env.collect(":build:openocd.source", "modm/board/rp2040_picoprobe.cfg") |