/* Try to wait the expected status of specified flags.  */
static int32_t USART_WaitStatus(const CM_USART_TypeDef *USARTx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
/* Try to wait the expected status of specified flags.  */
static int32_t USART_WaitStatus(const CM_USART_TypeDef *USARTx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
{
    int32_t i32Ret = LL_OK;
    __IO uint32_t u32To = 0UL;
    DDL_ASSERT(IS_USART_UNIT(USARTx));
    DDL_ASSERT(IS_USART_FLAG(u32Flag));
    while (USART_GetStatus(USARTx, u32Flag) != enStatus) {
        if ((u32To > u32Timeout) && (u32Timeout < USART_MAX_TIMEOUT)) {
            i32Ret = LL_ERR_TIMEOUT;
            break;
        }
        u32To++;
    }
    return i32Ret;
}