File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,13 @@ void lp_ticker_info_test(void);
44
44
*/
45
45
void lp_ticker_deepsleep_test (void );
46
46
47
-
47
+ /** Test that the ticker does not glitch backwards due to an incorrectly implemented ripple counter driver.
48
+ *
49
+ * Given ticker is available.
50
+ * When ticker is enabled and counts.
51
+ * Then ticker does not glitch backwards due to an incorrectly implemented ripple counter driver.
52
+ */
53
+ void lp_ticker_glitch_test (void );
48
54
/**@}*/
49
55
50
56
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -86,6 +86,24 @@ void lp_ticker_deepsleep_test()
86
86
TEST_ASSERT_EQUAL (1 , intFlag);
87
87
}
88
88
89
+ /* Test that the ticker does not glitch backwards due to an incorrectly implemented ripple counter driver. */
90
+ void lp_ticker_glitch_test ()
91
+ {
92
+ lp_ticker_init ();
93
+
94
+ const ticker_info_t * p_ticker_info = lp_ticker_get_info ();
95
+
96
+ uint32_t last = lp_ticker_read ();
97
+ const uint32_t start = last;
98
+
99
+ /* Set test time to 2 sec. */
100
+ while (last < (start + p_ticker_info->frequency * 2 )) {
101
+ const uint32_t cur = lp_ticker_read ();
102
+ TEST_ASSERT (cur >= last);
103
+ last = cur;
104
+ }
105
+ }
106
+
89
107
utest::v1::status_t test_setup (const size_t number_of_cases)
90
108
{
91
109
GREENTEA_SETUP (20 , " default_auto" );
@@ -95,6 +113,7 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
95
113
Case cases[] = {
96
114
Case (" lp ticker info test" , lp_ticker_info_test),
97
115
Case (" lp ticker sleep test" , lp_ticker_deepsleep_test),
116
+ Case (" lp ticker glitch test" , lp_ticker_glitch_test)
98
117
};
99
118
100
119
Specification specification (test_setup, cases);
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ extern "C" {
43
43
* * See the @ref hal_ticker_shared "ticker specification"
44
44
* * Calling any function other than lp_ticker_init after calling lp_ticker_free
45
45
*
46
+ * # Potential bugs
47
+ * * Glitches due to ripple counter - Verified by ::lp_ticker_glitch_test
48
+ *
46
49
* @see hal_lp_ticker_tests
47
50
*
48
51
* @{
You can’t perform that action at this time.
0 commit comments