mirror of https://github.com/ARMmbed/mbed-os.git
Test: Sleep: Increase the UART flush wait
parent
7f1ed02291
commit
fa7eb7d888
|
@ -29,21 +29,20 @@
|
|||
#include "hal/us_ticker_api.h"
|
||||
#include "hal/lp_ticker_api.h"
|
||||
|
||||
/* Flush serial buffer before deep sleep
|
||||
/* To prevent a loss of Greentea data, the serial buffers have to be flushed
|
||||
* before the UART peripheral shutdown. The UART shutdown happens when the
|
||||
* device is entering the deepsleep mode or performing a reset.
|
||||
*
|
||||
* Since deepsleep() may shut down the UART peripheral, we wait for some time
|
||||
* to allow for hardware serial buffers to completely flush.
|
||||
* With the current API, it is not possible to check if the hardware buffers
|
||||
* are empty. However, it is possible to determine the time required for the
|
||||
* buffers to flush.
|
||||
*
|
||||
* Take NUMAKER_PFM_NUC472 as an example:
|
||||
* Its UART peripheral has 16-byte Tx FIFO. With baud rate set to 9600, flush
|
||||
* Tx FIFO would take: 16 * 8 * 1000 / 9600 = 13.3 (ms). So set wait time to
|
||||
* 20ms here for safe.
|
||||
*
|
||||
* This should be replaced with a better function that checks if the
|
||||
* hardware buffers are empty. However, such an API does not exist now,
|
||||
* so we'll use the busy_wait_ms() function for now.
|
||||
* Assuming the biggest Tx FIFO of 128 bytes (as for CY8CPROTO_062_4343W)
|
||||
* and a default UART config (9600, 8N1), flushing the Tx FIFO wold take:
|
||||
* (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms.
|
||||
* To be on the safe side, set the wait time to 150 ms.
|
||||
*/
|
||||
#define SERIAL_FLUSH_TIME_MS 20
|
||||
#define SERIAL_FLUSH_TIME_MS 150
|
||||
|
||||
#define US_PER_S 1000000
|
||||
|
||||
|
|
Loading…
Reference in New Issue