Matthew Lai <m...@matthewlai.ca> wrote: > > > > I would ignore it. There's very few places where it will really matter, > > and the people who will need it, will be handling it themselves anyway, not > > using high level helper functions. > It would mean things like: > rcc_periph_clock_enable(RCC_TIM3); > timer_set_period(TIM3, 1024); > > Would violate this, at high prescalar settings (or low > prescalar settings with LTO). That is actually the example > given here: > https://github.com/libopencm3/libopencm3/blob/master/lib/stm32/common/timer_common_all.c#L70 > > It would be a potential source of very difficult to find bugs.
There's plenty of edge cases if you really want to go looking. I'm not really entirely sure how far to go trying to protect people. [1] > > Since I imagine rcc_periph_clock_enable() to not be > performance-critical in most applications, wouldn't adding the > wait states be better default behaviour, and people who really > need to enable clocks very quickly can go to registers > directly? It's more that I'm not sure you can do it neatly, and be robust enough to be worth trying. You'll need to interpret what bus a peripheral is on, as well as what speed it's currently running at. Doing this using the rcc_axx_speed globals is... ok, but they're not set if people didn't use clock helpers to set them up. Adding your peripheral speed as a parameter is a gross user API. For the vast majority of use cases, this is simply never going to be a problem. Doing any sort of meaningful cycle delay is going to just add code that most people will never need. In my opinion at least :) Cheers, Karl P [1] see https://github.com/libopencm3/libopencm3/commit/095ed8511a82e7f7da5c59c42ca116bb228a20d6 and there's a whole class of bugs likely related there. That's just off the top of my head.
signature.html
Description: OpenPGP Digital Signature
------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford
_______________________________________________ libopencm3-devel mailing list libopencm3-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libopencm3-devel