-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32 LPTICKER : Fix tickless and LPTICKER_DELAY_TICKS #8242
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,9 +145,6 @@ void lp_ticker_init(void) | |
|
||
__HAL_LPTIM_ENABLE_IT(&LptimHandle, LPTIM_IT_CMPM); | ||
HAL_LPTIM_Counter_Start(&LptimHandle, 0xFFFF); | ||
|
||
/* Need to write a compare value in order to get LPTIM_FLAG_CMPOK in set_interrupt */ | ||
__HAL_LPTIM_COMPARE_SET(&LptimHandle, 0); | ||
} | ||
|
||
static void LPTIM1_IRQHandler(void) | ||
|
@@ -194,21 +191,22 @@ void lp_ticker_set_interrupt(timestamp_t timestamp) | |
LptimHandle.Instance = LPTIM1; | ||
irq_handler = (void (*)(void))lp_ticker_irq_handler; | ||
|
||
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); | ||
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp); | ||
/* CMPOK is set by hardware to inform application that the APB bus write operation to the LPTIM_CMP register has been successfully completed */ | ||
/* Any successive write before the CMPOK flag be set, will lead to unpredictable results */ | ||
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) { | ||
} | ||
|
||
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK); | ||
__HAL_LPTIM_CLEAR_FLAG(&LptimHandle, LPTIM_FLAG_CMPM); | ||
__HAL_LPTIM_COMPARE_SET(&LptimHandle, timestamp); | ||
lp_ticker_clear_interrupt(); | ||
|
||
NVIC_EnableIRQ(LPTIM1_IRQn); | ||
} | ||
|
||
void lp_ticker_fire_interrupt(void) | ||
{ | ||
lp_Fired = 1; | ||
irq_handler = (void (*)(void))lp_ticker_irq_handler; | ||
NVIC_SetPendingIRQ(LPTIM1_IRQn); | ||
NVIC_EnableIRQ(LPTIM1_IRQn); | ||
} | ||
|
@@ -217,9 +215,6 @@ void lp_ticker_disable_interrupt(void) | |
{ | ||
NVIC_DisableIRQ(LPTIM1_IRQn); | ||
LptimHandle.Instance = LPTIM1; | ||
/* Waiting last write operation completion */ | ||
while (__HAL_LPTIM_GET_FLAG(&LptimHandle, LPTIM_FLAG_CMPOK) == RESET) { | ||
} | ||
} | ||
|
||
void lp_ticker_clear_interrupt(void) | ||
|
@@ -263,7 +258,6 @@ uint32_t lp_ticker_read(void) | |
|
||
void lp_ticker_set_interrupt(timestamp_t timestamp) | ||
{ | ||
lp_ticker_disable_interrupt(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have any details on how this fixes the test in #8129? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I should add the details you have added in #8129 |
||
rtc_set_wake_up_timer(timestamp); | ||
} | ||
|
||
|
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this bring back the blocking behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is the same behavior as you have done in #8129
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in #8129 caused blocking behavior as mentioned by @LMESTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@c1728p9 my mistake - Jérôme explained to me and I actually misunderstood CMPOK (programing ok) with CMPM (comparator match) - looks ok to me now