Skip to content
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

Add RCC module to abstract clock enable and reset #177

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

salkinium
Copy link
Member

This adds a modm::platform::Rcc class with

  • Rcc::enable<Peripheral>()
  • Rcc::disable<Peripheral>()
  • Rcc::reset<Peripheral>()

methods, which are implemented by parsing the CMSIS header files to extract the peripheral name, register name and bit masks. This information be moved to modm-devices in the future, but for now this "hack" significantly improves modm by moving the A{H,P}B{1,2} decisions from all peripherals into a common module.

cc @rleh @chris-durand


# FIXME: Move to modm:platform:core!
env.outbasepath = "modm/src/modm/platform/core"
env.template("peripherals.hpp.in")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modm-devices need to become smarter, right now it's just dumping the raw XML out it's API, so a lot of things need to be computed in modm that should be provided by modm-devices. Here, to compute the true set of addressable peripherals requires quite a bit of computation, which I don't want to duplicate in :platform:core module.

@@ -37,6 +38,8 @@ public:
static inline void
enable()
{
Rcc::enable<Peripheral::Rng>();
Rcc::reset<Peripheral::Rng>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, remember how the RNG never worked? HAVE YOU TRIED TURNING IT OFF AND ON AGAIN???

# filter out MPU and/or FPU if required
peripherals = filter(lambda p: p[0] not in core_features or core_features[p[0]], peripherals)
peripherals = sorted(peripherals, key=lambda p: p[0])
# print("\n".join([s+" -> "+hex(a) for (s,k,a) in peripherals]))

# Find all RCC enable and reset definitions
match = re.findall(r"RCC_([A-Z0-9]+?)_([A-Z0-9]+?)_(EN|RST) ", content)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evil or genius? Why not both?

@salkinium salkinium merged commit 4a82a94 into modm-io:develop Feb 28, 2019
@salkinium salkinium deleted the feature/rcc branch February 28, 2019 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant