Skip to content

Commit b57f60e

Browse files
authored
Merge pull request #5856 from scartmell-arm/feature-hal-ticker-free
Add missing free function to lp and us ticker HAL APIs
2 parents 2ae20ca + 5853e7e commit b57f60e

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

hal/lp_ticker_api.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern "C" {
4141
*
4242
* # Undefined behavior
4343
* * See the @ref hal_ticker_shared "ticker specification"
44+
* * Calling any function other than lp_ticker_init after calling lp_ticker_free
4445
*
4546
* @see hal_lp_ticker_tests
4647
*
@@ -112,6 +113,18 @@ void lp_ticker_irq_handler(void);
112113
*/
113114
void lp_ticker_init(void);
114115

116+
/** Deinitialize the lower power ticker
117+
*
118+
* Powerdown the lp ticker in preparation for sleep, powerdown, or reset.
119+
*
120+
* After calling this function no other ticker functions should be called except
121+
* lp_ticker_init(). Calling any function other than init after freeing is
122+
* undefined.
123+
*
124+
* @note This function stops the ticker from counting.
125+
*/
126+
void lp_ticker_free(void);
127+
115128
/** Read the current tick
116129
*
117130
* If no rollover has occurred, the seconds passed since lp_ticker_init()

hal/us_ticker_api.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern "C" {
7878
* * Calling any function other than ticker_init before the initialization of the ticker
7979
* * Whether ticker_irq_handler is called a second time if the time wraps and matches the value set by ticker_set_interrupt again
8080
* * Calling ticker_set_interrupt with a value that has more than the supported number of bits
81+
* * Calling any function other than us_ticker_init after calling us_ticker_free
8182
*
8283
* # Potential bugs
8384
* * Drift due to reschedule - Verified by ::ticker_repeat_reschedule_test
@@ -161,7 +162,18 @@ void us_ticker_irq_handler(void);
161162
*/
162163
void us_ticker_init(void);
163164

164-
/** Read the current tick
165+
/** Deinitialize the us ticker
166+
*
167+
* Powerdown the us ticker in preparation for sleep, powerdown, or reset.
168+
*
169+
* After this function is called, no other ticker functions should be called
170+
* except us_ticker_init(), calling any function other than init is undefined.
171+
*
172+
* @note This function stops the ticker from counting.
173+
*/
174+
void us_ticker_free(void);
175+
176+
/** Read the current counter
165177
*
166178
* Read the current counter value without performing frequency conversions.
167179
* If no rollover has occurred, the seconds passed since us_ticker_init()
@@ -230,7 +242,7 @@ void us_ticker_disable_interrupt(void);
230242
void us_ticker_clear_interrupt(void);
231243

232244
/** Set pending interrupt that should be fired right away.
233-
*
245+
*
234246
* The ticker should be initialized prior calling this function.
235247
*
236248
* Pseudo Code:

targets/TARGET_NORDIC/TARGET_NRF5/lp_ticker.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ void lp_ticker_init(void)
2424
common_rtc_init();
2525
}
2626

27+
void lp_ticker_free(void)
28+
{
29+
// A common counter is used for RTC, lp_ticker and us_ticker, so it can't be
30+
// disabled here, but this does not cause any extra cost.
31+
}
32+
2733
uint32_t lp_ticker_read()
2834
{
2935
return (uint32_t)common_rtc_64bit_us_get();

targets/TARGET_NORDIC/TARGET_NRF5/us_ticker.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ void us_ticker_init(void)
259259
common_rtc_init();
260260
}
261261

262+
void us_ticker_free(void)
263+
{
264+
// A common counter is used for RTC, lp_ticker and us_ticker, so it can't be
265+
// disabled here, but this does not cause any extra cost.
266+
}
267+
262268
uint32_t us_ticker_read()
263269
{
264270
us_ticker_init();

0 commit comments

Comments
 (0)