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

Cleanup clock modules and add related user-defined literals #180

Merged
merged 12 commits into from
Mar 6, 2019

Conversation

salkinium
Copy link
Member

@salkinium salkinium commented Mar 2, 2019

This refactors the :platform:clock and related modules to remove legacy code and simplify module partitioning and generalize Baudrate and Frequency specification with user-defined literals.

Structural changes (breaking):

  • Renamed :platform:clock.cortex -> :platform:systick: Moved modm_clock.cpp to :platform:cortex-m module
  • Moved modm::platform::ClockControl for STM32 to :platform:rcc module.
  • modm:platform:clock now is a module that contains common code.
  • moved flash latency data into modm-devices.

Refactorings (breaking):

  • Renamed modm::platform::ClockControl -> modm::platform::Rcc for consistency.
  • Renamed modm::cortex::SysTickTimer -> modm::platform::SysTickTimer for consistency.
  • Refactored ClockControl::setFlashLatency(Hz, mV) -> ClockControl::setFlashLatency<Hz, mV>(): Allows latency table lookup in constexpr at compile-time.
  • Added Rcc::updateCoreFrequency<Hz>(): Sets the internal frequency values for delay functions.

User-defined literals (breaking) added to the modm::literals namespace:

  • Added _Hz, _kHz and _MHz literals. Removed and replaced usage of modm::clock::Frequency enum.
  • Added _Bd, _kBd and _MBd literals. Removed and replaced usage of modm::Uart::Baudrate enum.
  • Added _bps, _kbpsand_Mbps` literals. Not used yet.

All literals are simply casting to a dimensionless uint32_t of integer units (no fractional units possible) to be lightweight and backwards compatible with modm.
The limitation here is that since baudrates and frequencies are passed around as template arguments, the C++ limitations regarding template argument types applies, specifically float cannot be passed, as well as custom types cannot be used (Like a type-safe frequency_t type).

Todo:

@rleh @chris-durand

@salkinium salkinium force-pushed the feature/cleanup_clock branch 10 times, most recently from d408303 to 825c402 Compare March 5, 2019 23:56
@salkinium salkinium marked this pull request as ready for review March 6, 2019 13:52
@salkinium salkinium force-pushed the feature/cleanup_clock branch from 825c402 to 54716d3 Compare March 6, 2019 13:58
@salkinium salkinium force-pushed the feature/cleanup_clock branch from 54716d3 to 5648aa6 Compare March 6, 2019 14:05
@salkinium salkinium force-pushed the feature/cleanup_clock branch 2 times, most recently from 4bdf87f to f8ef8ba Compare March 6, 2019 16:38
@salkinium salkinium merged commit f8ef8ba into modm-io:develop Mar 6, 2019
@salkinium salkinium deleted the feature/cleanup_clock branch March 6, 2019 16:57
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