Skip to content

Commit 1bc0d26

Browse files
committed
Add documentation for LP_TICKER defines
They're now potentially useful, so document them as per the US_TICKER defines.
1 parent 579a25a commit 1bc0d26

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ void lp_ticker_info_test()
110110
TEST_ASSERT(p_ticker_info->frequency >= 4000);
111111
TEST_ASSERT(p_ticker_info->frequency <= 64000);
112112
TEST_ASSERT(p_ticker_info->bits >= 12);
113+
114+
#ifdef LP_TICKER_PERIOD_NUM
115+
TEST_ASSERT_UINT32_WITHIN(1, 1000000 * LP_TICKER_PERIOD_DEN / LP_TICKER_PERIOD_NUM, p_ticker_info->frequency);
116+
TEST_ASSERT_EQUAL_UINT32(LP_TICKER_MASK, ((uint64_t)1 << p_ticker_info->bits) - 1);
117+
#endif
118+
113119
}
114120

115121
#if DEVICE_SLEEP

hal/lp_ticker_api.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ extern "C" {
4949
*
5050
* @see hal_lp_ticker_tests
5151
*
52+
* # Compile-time optimization macros
53+
*
54+
* To permit compile-time optimization, the following macros can be defined by a target's device.h:
55+
*
56+
* LP_TICKER_PERIOD_NUM, LP_TICKER_PERIOD_DEN: These denote the ratio (numerator, denominator)
57+
* of the ticker period to a microsecond. For example, a 64kHz ticker would have NUM = 125, DEN = 8;
58+
* a 4kHz ticker would have NUM = 250, DEN = 1; a 32.768kHz ticker would have NUM = 15625, DEN = 512.
59+
* Both numerator and denominator must be 32 bits or less. They do not need to be fully simplified,
60+
* so 32.768kHz could also be NUM = 1000000, DEN = 32768, but more simplification may be a minor
61+
* speed optimisation, as can matching numerator or denominator with US_TICKER.
62+
*
63+
* LP_TICKER_MASK: The value mask for the ticker - eg 0x07FFFFFF for a 27-bit ticker.
64+
*
65+
* If any are defined, all 3 must be defined, and the macros are checked for consistency with
66+
* lp_ticker_get_info by test ::lp_ticker_info_test.
67+
5268
* @{
5369
*/
5470

hal/us_ticker_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern "C" {
5050
* US_TICKER_PERIOD_NUM, US_TICKER_PERIOD_DEN: These denote the ratio (numerator, denominator)
5151
* of the ticker period to a microsecond. For example, an 8MHz ticker would have NUM = 1, DEN = 8;
5252
* a 1MHz ticker would have NUM = 1, DEN = 1; a 250kHz ticker would have NUM = 4, DEN = 1.
53-
* Both numerator and denominator must be 16 bits or less.
53+
* Both numerator and denominator must be 16 bits or less, but need not be fully simplified.
5454
*
5555
* US_TICKER_MASK: The value mask for the ticker - eg 0x07FFFFFF for a 27-bit ticker.
5656
*

0 commit comments

Comments
 (0)