void Uart::waitToEmpty()
{
#if FSL_FEATURE_SOC_UART_COUNT
    if(!SIM_HAL_GetGateCmd(SIM, gate_name)) return;
    uint32_t start = millis();
    while(!(UART_RD_S1(instance) & (UART_S1_TDRE_MASK)))
    {
        if(millis() - start > 10)
            return;
    }
    while(!(UART_RD_S1(instance) & (UART_S1_TC_MASK)))
    {
        if(millis() - start > 10)
            break;
    }
#endif
}
size_t Uart::write(const uint8_t data)
{
#if FSL_FEATURE_SOC_UART_COUNT
    if(!SIM_HAL_GetGateCmd(SIM, gate_name)) return 0;
    uint32_t start = millis();

    while (!UART_BRD_S1_TDRE(instance))
    {
        if(millis() - start > 10)
            return 0;
    }

    UART_HAL_Putchar(instance, data);
    return 1;
#endif

    return 0;
}
Ejemplo n.º 3
0
/*FUNCTION**********************************************************************
 *
 * Function Name : CLOCK_SYS_GetUartGateCmd
 * Description   : Get the the clock gate state for UART module
 * This function will get the clock gate state for UART module.
 *
 *END**************************************************************************/
bool CLOCK_SYS_GetUartGateCmd(uint32_t instance)
{
    assert(instance < sizeof(uartGateTable)/sizeof(uartGateTable[0]));

    return SIM_HAL_GetGateCmd(SIM, uartGateTable[instance]);
}