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

[WIP] cpu/stm32_common: add LPTIM driver #7351

Closed
wants to merge 2 commits into from

Conversation

vincent-d
Copy link
Member

This is rough and WIP, but it adds an implementation of timer API for the stm32f4 LPTIM.

tests/xtimer_msg works, but tests/xtimer_longterm does not, and I don't know why!

Not related to that PR, but pm / pm_layered do not work on stm32...

@vincent-d vincent-d added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Jul 11, 2017
/**
* @brief Timer configuration
*/
typedef struct {
TIM_TypeDef *dev; /**< timer device */
TIM_TypeDef *dev; /**< timer device, not set for LPTIM */
Copy link
Member

Choose a reason for hiding this comment

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

why not? Set it to LPTIM1 and you can use dev(tim)-> below in line 223, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Main reason is that LPTIM1 is not a TIM_TypeDef * so we could either use an union or a void *.

We would then need a dev_lptim(tim) to return the pointer with the right type.

Copy link
Member

Choose a reason for hiding this comment

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

ah, different low-level types, haven't seen that.

@aabadie aabadie added this to the Release 2017.10 milestone Jul 12, 2017
@haukepetersen
Copy link
Contributor

This looks rather hacky to me, and does once more point out the problems of xtimer. Logically, I would rather tend to use the lptim hardware to implement the periph/rtt interface, as the semantics of that interface fit better on the characteristics of the lptim (-> see cpu/stm32l4/periph/rtt_lptim.c). But this does of course not help in practice currently, as xtimer can not make use of that implementation.

For the long term we will have a redone/overworked high level timer system, that can simply utilize the rtt_lptim implementation, so in that context that would be my preferred way.

But for the short term, I see only two options: 'hack' the periph/timer implementation to make use of both tim and lptim hardware uints (as sketched in this PR), or to implement the periph/timer interface using the lptim separately and configure during compile time, which of the two implementations to use. The latter has the advantage of being more clean and straight forward, but it does of course allow only one of the two hardware timer options to be used...

@madokapeng
Copy link
Contributor

Hi, what status of this issue now? @vincent-d

@vincent-d
Copy link
Member Author

I did not work on this recently, as it didn't really reached a consensus.

But the LPTIM can be accessed through periph_rtt API.

If one think it still useful to add the support through periph_timer I could spend some time on it. The main goal IMO would be to use the LPTIM as xtimer backend. I also know that there is some work on a replacement for xtimer, but I have no idea what the status is, maybe @haukepetersen or @kaspar030 know.

@kaspar030
Copy link
Contributor

I also know that there is some work on a replacement for xtimer, but I have no idea what the status is, maybe @haukepetersen or @kaspar030 know.

I have a working prototype here. Soon as the staging tree is in place (or an alternative), I'll PR so we can discuss more visibly. @gebart and @ZetaR60 also have coded towards better timers.

There's already a periph_rtt backend in ztimer, so LPTIM should already be usable with that.

@aabadie
Copy link
Contributor

aabadie commented Jan 3, 2019

I have a working prototype here. Soon as the staging tree is in place (or an alternative), I'll PR so we can discuss more visibly. @gebart and @ZetaR60 also have coded towards better timers.

@kaspar030, I don't understand why you think having the staging tree is a requirement for this feature. It appears that at least @vincent-d, @gebart, @ZetaR60 (all maintainers) are interested by such a feature and already started to also work on that on their side. They should be enough motivated (and I will) to give help and speed-up the review/merge process. Since it's a core feature, many existing features in RIOT will certainly benefit from it.
Having this feature will also help solving existing problems, especially with LoRa (see #10352, #10442 and others related).

Please open the PR asap!
I think that's long enough that we are waiting for it (I remember having heard about it during the Summit 2017... or maybe in Paris in May 2017).

@vincent-d
Copy link
Member Author

@kaspar030, I don't understand why you think having the staging tree is a requirement for this feature.

I agree with this. I think it would be beneficial to merge your work directly in the mainline.

Closing this one anyway.

@vincent-d vincent-d closed this Jan 3, 2019
@kaspar030
Copy link
Contributor

I don't understand why you think having the staging tree is a requirement for this feature.

It is not at all a requirement. I just didn't expect staging/ to be blocked that long, and I think something like ztimer would be quite useful even volatile and / or unpolished, thus ideal for staging/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: ARM Platform: This PR/issue effects ARM-based platforms State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants