File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 28
28
29
29
#define US_PER_S 1000000
30
30
31
+ /* Flush serial buffer before deep sleep
32
+ *
33
+ * Since deepsleep() may shut down the UART peripheral, we wait for some time
34
+ * to allow for hardware serial buffers to completely flush.
35
+ *
36
+ * Take NUMAKER_PFM_NUC472 as an example:
37
+ * Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
38
+ * Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
39
+ * 20ms here for safe.
40
+ *
41
+ * This should be replaced with a better function that checks if the
42
+ * hardware buffers are empty. However, such an API does not exist now,
43
+ * so we'll use the wait_ms() function for now.
44
+ */
45
+ #define SERIAL_FLUSH_TIME_MS 20
46
+
31
47
using namespace utest ::v1;
32
48
33
49
/* The following ticker frequencies are possible:
@@ -167,7 +183,7 @@ void deepsleep_lpticker_test()
167
183
/* Give some time Green Tea to finish UART transmission before entering
168
184
* deep-sleep mode.
169
185
*/
170
- wait_ms (10 );
186
+ wait_ms (SERIAL_FLUSH_TIME_MS );
171
187
172
188
TEST_ASSERT_TRUE_MESSAGE (sleep_manager_can_deep_sleep (), " deep sleep should not be locked" );
173
189
@@ -202,7 +218,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
202
218
/* Give some time Green Tea to finish UART transmission before entering
203
219
* deep-sleep mode.
204
220
*/
205
- wait_ms (10 );
221
+ wait_ms (SERIAL_FLUSH_TIME_MS );
206
222
207
223
TEST_ASSERT_TRUE_MESSAGE (sleep_manager_can_deep_sleep (), " deep sleep should not be locked" );
208
224
You can’t perform that action at this time.
0 commit comments