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
About the use of MillisecondTimer for timeout #19
Comments
I'll look into this. There are other classes that use |
Having broad dependence on MillisecondTimer is a problem for situations where you've got an RTOS or something which is wrapping SysTick. The ideal would be a Strategy Pattern, where you could optionally pass a reference at initialization time to an alternative backing implementation. |
Good point about the RTOS. I have an idea forming in the back of my ahead about how this could be done whilst still retaining compatibility. |
Hey, did anything come of this? I'm running into the conflict now trying to use the I2C peripheral. |
This change is on the mikepurvis-tick-event branch. I will merge it if I get positive feedback here I've taken Mike's PR and extended it to abstract This is a non-breaking change. Existing code will work just like it did before. If you want to wire up the stm32plus millisecond timer into another frameworks implementation then you can: Define You should provide your own implementation class that satisfies the 3-method contract defined in MillisecondTimerHolder. Here's an example that replaces the simple default with Mike's idea of permitting an event-based millisecond callback:
This implementation of
and the callback is a simple void method
|
+1 |
Two thoughts: First, it's a bummer to have to have a library-compile-time flag around this. It's one more variant of the library for the purposes of generating distributable static libs. I don't know much about how ISRs get linked up and so-on, but is it possible that the ISR could be defined in a header, so that the decision whether to use it or not can be made at project compile time rather than library compile time? Maybe there's no way to do this without having a separate timer ISR header which has to be included only once across all sources, or a Second, it seems to me that an event like MillisecondTick should be available regardless of what your backing MillisecondTimer implementation is— the implementation supplies ticks, whereas the rest of the library are consumers of ticks. Whether I want to attach code to the systick should be independent of what's providing it. Thoughts? |
It's not as portable, but declaring the supplied SysTick ISR as a weak symbol might address both issues— it would allow the linker to throw away multiple instances of the ISR coming in via headers, but it would also permit a user-supplied instance of the ISR to override the library-supplied one. |
The issue with using weak symbols for the ISRs is that weak definitions already exist in the |
My principal concern is what to do about a precompiled static lib. If we go with What about just making the default handler supplied by stm32plus a weak symbol, and eliminating the weak alias to A more dramatic case might be made that as a general purpose library, stm32plus should avoid all non-weak ISRs, and that any of them provided by the library should be opt-in by users, either using their project's |
This is a good simple solution and I'm in favour of it. I've tried it on a few of the examples and it does work well. The issue with upgraders is, I think, minor and can be addressed in release notes as you suggest. I'll prepare a commit shortly with all the
I'm actually in favour of this as well. Currently there are There will be a |
This is now on master as commit 08aef0f. Existing projects that try to build against this release that don't remove the weak aliasing of |
With the release of 3.5.0 I hope no-one minds if I close this now. |
Waking this thread up again. Sorry I was kind of lukewarm on the |
Hi, I have a suggestion for the implementation of timeout.
Your code seem to have implemented it by using
MillisecondTimer
, but this fact is not well-documented.I think that
MillisecondTimer
and the timeout functionality should be separated.It is not trivial that timeout is automatically enabled when using
MillisecondTimer
so they should be switched like this:(When using timeout)
(When using
MillisecondTimer
with no timeout)Thank you for your fascinating library and I hopefully make it more efficient and useful.
The text was updated successfully, but these errors were encountered: