Cleanup clock modules and add related user-defined literals - #180
Merged
Conversation
salkinium
force-pushed
the
feature/cleanup_clock
branch
10 times, most recently
from
March 5, 2019 23:56
d408303 to
825c402
Compare
salkinium
marked this pull request as ready for review
March 6, 2019 13:52
salkinium
force-pushed
the
feature/cleanup_clock
branch
from
March 6, 2019 13:58
825c402 to
54716d3
Compare
salkinium
force-pushed
the
feature/cleanup_clock
branch
from
March 6, 2019 14:05
54716d3 to
5648aa6
Compare
salkinium
force-pushed
the
feature/cleanup_clock
branch
2 times, most recently
from
March 6, 2019 16:38
4bdf87f to
f8ef8ba
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This refactors the
:platform:clockand related modules to remove legacy code and simplify module partitioning and generalize Baudrate and Frequency specification with user-defined literals.Structural changes (breaking):
:platform:clock.cortex->:platform:systick: Movedmodm_clock.cppto:platform:cortex-mmodulemodm::platform::ClockControlfor STM32 to:platform:rccmodule.modm:platform:clocknow is a module that contains common code.Refactorings (breaking):
modm::platform::ClockControl->modm::platform::Rccfor consistency.modm::cortex::SysTickTimer->modm::platform::SysTickTimerfor consistency.ClockControl::setFlashLatency(Hz, mV)->ClockControl::setFlashLatency<Hz, mV>(): Allows latency table lookup in constexpr at compile-time.Rcc::updateCoreFrequency<Hz>(): Sets the internal frequency values for delay functions.User-defined literals (breaking) added to the
modm::literalsnamespace:_Hz,_kHzand_MHzliterals. Removed and replaced usage ofmodm::clock::Frequencyenum._Bd,_kBdand_MBdliterals. Removed and replaced usage ofmodm::Uart::Baudrateenum._bps, _kbpsand_Mbps` literals. Not used yet.All literals are simply casting to a dimensionless
uint32_tof 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
floatcannot be passed, as well as custom types cannot be used (Like a type-safefrequency_ttype).Todo:
Check if clock tree can at least be partially generated, requires data from modm-devices.No, this is difficult, see Add clock trees and query interface modm-devices#17. To be added later.Check if using aNo, this would break a lot ofenum class frequency_t : uint32_t {};is an option for providing strongly-typed template arguments. Unfortunatelyenum classoperators are severely restricted (no implicit conversion obviously).::initialize<>()code without any benefits.Bdas Baudrate symbol, however, I personally find_Baud,_kBaudand_MBaudmore intuitive. Well, Bd is a SI unit, so that settles it.bit/sas bitrate symbol, however_bitslooks wrong, so_bpswas chosen. This is fine, other libraries use this convention too (Bytes/s is Bps then).@rleh @chris-durand