-
Notifications
You must be signed in to change notification settings - Fork 155
Support for NRF arm processors #410
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
Draft
el-han
wants to merge
10
commits into
modm-io:develop
Choose a base branch
from
el-han:nrf
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
48b863a
[ext] Enable NRF devices and update submodules
el-han 3f406b3
[core] Add NRF port
el-han ceb74af
[clock] Port NRF HFCLK peripheral
el-han e4fb68b
[gpio] Implement GPIO driver for NRF
el-han e145e23
[examples] Add inital example for NRF52840
el-han 827193a
[ci] add nrf example to CI
el-han c4df07f
use generic cortex linkerscript
el-han 51780b4
clean up gpio code
el-han 11ae56a
correct build path from example
el-han aa47cbf
correct header file names
el-han 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
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
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,31 @@ | ||
| /* | ||
| * Copyright (c) 2010-2011, Fabian Greif | ||
| * Copyright (c) 2013-2014, 2016-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/platform.hpp> | ||
|
|
||
| using namespace modm::platform; | ||
|
|
||
| typedef GpioOutputP0_22 Led; | ||
|
|
||
| int | ||
| main() | ||
| { | ||
| Led::setOutput(); | ||
|
|
||
| while (true) | ||
| { | ||
| Led::toggle(); | ||
|
|
||
| modm::delay_ms(1000); | ||
| } | ||
| } | ||
|
|
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,14 @@ | ||
| <library> | ||
| <options> | ||
| <option name="modm:target">nrf52840-xxaa</option> | ||
| <option name="modm:build:build.path">../../../build/nrf/blink</option> | ||
| </options> | ||
| <modules> | ||
| <module>modm:architecture:delay</module> | ||
| <module>modm:platform:core</module> | ||
| <module>modm:platform:clock</module> | ||
| <module>modm:platform:hfclk</module> | ||
| <module>modm:platform:gpio</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,29 @@ | ||
| /* | ||
| * Copyright (c) 2019 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/. | ||
| */ | ||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| #ifndef MODM_DEVICE_HPP | ||
| #define MODM_DEVICE_HPP | ||
|
|
||
| #define DONT_USE_CMSIS_INIT 1 | ||
| %% for define in defines | ||
| #define {{ define }} 1 | ||
| %% endfor | ||
|
|
||
| #include <stdint.h> | ||
| // Defines for example the modm_always_inline macro | ||
| #include <modm/architecture/utils.hpp> | ||
|
|
||
| // Include external device headers: | ||
| %% for header in headers | ||
| #include <{{ header }}> | ||
| %% endfor | ||
|
|
||
| #endif // MODM_DEVICE_HPP |
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,81 @@ | ||
| #!/usr/bin/env python3 | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright (c) 2019, Niklas Hauser | ||
| # Copyright (c) 2020, Hannes Ellinger | ||
| # | ||
| # 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/. | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| import re | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| def init(module): | ||
| module.name = ":cmsis:device" | ||
|
|
||
|
|
||
| def prepare(module, options): | ||
| device = options[":target"] | ||
| if device.identifier["platform"] != "nrf": | ||
| return False | ||
|
|
||
| module.depends(":cmsis:core") | ||
| return True | ||
|
|
||
|
|
||
| pp = {} | ||
|
|
||
|
|
||
| def validate(env): | ||
| device = env[":target"] | ||
| device_name = device.identifier.string.split("-")[0] | ||
|
|
||
| define = "{}".format(device_name.upper()) | ||
| family_file = None | ||
| famfile = Path(localpath("nrf/nrf.h")) | ||
| content = famfile.read_text(encoding="utf-8", errors="replace") | ||
| match = re.findall(r"defined \((?P<define>_?.*)\)", content) | ||
| for m in match: | ||
| if define in m: | ||
| family_file = famfile.relative_to(localpath(".")) | ||
|
|
||
| if family_file is None: | ||
| raise ValidateException("No device define found for '{}'!".format(device.partname)) | ||
|
|
||
| family_folder = family_file.parent | ||
| if device_name == "nrf51822": | ||
| device_header = "nrf51.h" | ||
| elif device_name == "nrf52832": | ||
| device_header = "nrf52.h" | ||
| else: | ||
| device_header = "{}.h".format(device_name) | ||
|
|
||
| global pp | ||
| pp = { | ||
| "define": define, | ||
| "folder": family_folder, | ||
| "device_header": device_header, | ||
| } | ||
|
|
||
|
|
||
| def build(env): | ||
| global pp | ||
| env.collect(":build:path.include", "modm/ext/cmsis/device") | ||
|
|
||
| env.outbasepath = "modm/ext/cmsis/device" | ||
| files = [pp["device_header"], "system_"+pp["device_header"]] | ||
| for file in files: | ||
| env.copy(localpath(pp["folder"], file), file) | ||
|
|
||
| env.substitutions = { | ||
| "headers": [pp["device_header"]], | ||
| "defines": [pp["define"]], | ||
| } | ||
| env.outbasepath = "modm/src/modm/platform" | ||
| env.template("device.hpp.in") |
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,20 @@ | ||
| /* | ||
| * Copyright (c) 2013-2014, Kevin Läufer | ||
| * Copyright (c) 2014-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 "../device.hpp" | ||
| #include "hfclk.hpp" | ||
|
|
||
| namespace modm::platform | ||
| { | ||
| uint16_t modm_fastdata delay_fcpu_MHz(64); | ||
| uint16_t modm_fastdata delay_ns_per_loop({{ loops * 1000 / 64 }}); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The core runs at 64MHz right after boot? This should be set to the default clock frequency which is probably much less than 64MHz. |
||
| } | ||
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,35 @@ | ||
| /* | ||
| * Copyright (c) 2019, Ethan Slattery | ||
| * | ||
| * 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 <stdint.h> | ||
| #include "../device.hpp" | ||
|
|
||
| namespace modm::platform | ||
| { | ||
|
|
||
| /** | ||
| * Clock management | ||
| * | ||
| * \ingroup modm_platform_hfclk | ||
| */ | ||
| class HighFrequencyClockController | ||
| { | ||
| public: | ||
| template< uint32_t Core_Hz > | ||
| void | ||
| updateCoreFrequency(); | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| #include "hfclk_impl.hpp" |
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,30 @@ | ||
| /* | ||
| * Copyright (c) 2019, Ethan Slattery | ||
| * | ||
| * 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 <cmath> | ||
|
|
||
| namespace modm::platform | ||
| { | ||
| /// @cond | ||
| extern uint16_t delay_fcpu_MHz; | ||
| extern uint16_t delay_ns_per_loop; | ||
| /// @endcond | ||
|
|
||
| template< uint32_t Core_Hz > | ||
| void | ||
| HighFrequencyClockController::updateCoreFrequency() | ||
| { | ||
| delay_fcpu_MHz = Core_Hz / 64'000'000; | ||
| delay_ns_per_loop = ::round({{loops}}000.f / (Core_Hz / 64'000'000)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. divide by 1MHz. |
||
| } | ||
|
|
||
| } | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked at this repo, it looks manually copied? Where from? I'm seeing a lot of linker script and so many header files it would be nice to have the some folders that structure this just a little bit (at least by family?). Preferrably automated via
update.pysimiliar to the other cmsis-header repos to simplify maintenance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, never mind, I just looked at the top-level
nrf.hfile and it looks like it is not meant to be split apart by family. Let's keep this in mind as a future goal, currently this copies all family files, which is unfortunate.