-
Notifications
You must be signed in to change notification settings - Fork 3k
Nuvoton: Adhere to reworked ticker spec to release with Mbed OS 5.9 #7029
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 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ebd93ba
[Nuvoton] Meet new us_ticker HAL spec (Mbed OS 5.9)
ccli8 3f86142
[Nuvoton] Meet new lp_ticker HAL spec (Mbed OS 5.9)
ccli8 12792fd
[NANO130] Fix CLK_Idle incorrectly enters into deep sleep mode
ccli8 7caec46
[NANO130] Adjust static/dynamic memory allocation for IAR toolchain t…
ccli8 b18f690
Fix Greentea test code
ccli8 86e194d
[Nuvoton] Reduce blocking code in lp_ticker
ccli8 fe627cb
[Nuvoton] Synchronize lp_ticker code to us_ticker
ccli8 8e11ddf
[Nuvoton] Fix trap in lp_ticker ISR with non-blocking "clear interrup…
ccli8 310a1fe
[Nuvoton] Synchronize lp_ticker code to us_ticker
ccli8 1fa3374
[Nuvoton] Remove special handling for dummy interrupt in lp_ticker
ccli8 4f04ae4
[Nuvoton] Synchronize lp_ticker code to us_ticker
ccli8 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
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 |
---|---|---|
|
@@ -53,6 +53,10 @@ static int ticker_inited = 0; | |
void lp_ticker_init(void) | ||
{ | ||
if (ticker_inited) { | ||
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the | ||
* ticker interrupt. */ | ||
lp_ticker_disable_interrupt(); | ||
lp_ticker_clear_interrupt(); | ||
return; | ||
} | ||
ticker_inited = 1; | ||
|
@@ -88,7 +92,7 @@ void lp_ticker_init(void) | |
|
||
NVIC_EnableIRQ(TIMER_MODINIT.irq_n); | ||
|
||
TIMER_EnableInt(timer_base); | ||
TIMER_DisableInt(timer_base); | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
|
||
TIMER_EnableWakeup(timer_base); | ||
|
@@ -101,6 +105,33 @@ void lp_ticker_init(void) | |
while(! (timer_base->CTL & TIMER_CTL_ACTSTS_Msk)); | ||
} | ||
|
||
void lp_ticker_free(void) | ||
{ | ||
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname); | ||
|
||
/* Stop counting */ | ||
TIMER_Stop(timer_base); | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
|
||
/* Wait for timer to stop counting and unset active flag */ | ||
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk)); | ||
|
||
/* Disable wakeup */ | ||
TIMER_DisableWakeup(timer_base); | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
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. Is this 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. @c1728p9 All these |
||
|
||
/* Disable interrupt */ | ||
TIMER_DisableInt(timer_base); | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
|
||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n); | ||
|
||
/* Disable IP clock */ | ||
CLK_DisableModuleClock(TIMER_MODINIT.clkidx); | ||
|
||
ticker_inited = 0; | ||
} | ||
|
||
timestamp_t lp_ticker_read() | ||
{ | ||
if (! ticker_inited) { | ||
|
@@ -131,6 +162,9 @@ void lp_ticker_set_interrupt(timestamp_t timestamp) | |
|
||
timer_base->CMP = cmp_timer; | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
|
||
TIMER_EnableInt(timer_base); | ||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3); | ||
} | ||
|
||
void lp_ticker_disable_interrupt(void) | ||
|
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
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
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
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
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
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.
Why was this inserted?
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.
Never mind. Commit b18f690 explained it perfectly.