/* See fsl_debug_console.h for documentation of this function.*/
debug_console_status_t DbgConsole_DeInit(void)
{
    if (s_debugConsole.type == kDebugConsoleNone)
    {
        return kStatus_DEBUGCONSOLE_Success;
    }

    switch(s_debugConsole.type)
    {
#if defined(HW_UART_INSTANCE_COUNT)
        case kDebugConsoleUART:
            CLOCK_SYS_DisableUartClock(s_debugConsole.instance);
            break;
#endif
#if defined(HW_UART0_INSTANCE_COUNT)
        case kDebugConsoleLPSCI:
            CLOCK_SYS_DisableLpsciClock(s_debugConsole.instance);
            break;
#endif
#if defined(HW_LPUART_INSTANCE_COUNT)
        case kDebugConsoleLPUART:
             CLOCK_SYS_DisableLpuartClock(s_debugConsole.instance);
            break;
#endif
        default:
            return kStatus_DEBUGCONSOLE_InvalidDevice;
    }

    s_debugConsole.type = kDebugConsoleNone;

    return kStatus_DEBUGCONSOLE_Success;
}
Exemplo n.º 2
0
/*FUNCTION**********************************************************************
 *
 * Function Name : LPSCI_DRV_DmaDeinit
 * Description   : This function shuts down the LPSCI by disabling LPSCI DMA and
 *                 the transmitter/receiver.
 *
 *END**************************************************************************/
lpsci_status_t LPSCI_DRV_DmaDeinit(uint32_t instance)
{
    assert(instance < UART0_INSTANCE_COUNT);

    /* Exit if current instance is already de-initialized or is gated.*/
    if ((!g_lpsciStatePtr[instance]) || (!CLOCK_SYS_GetLpsciGateCmd(instance)))
    {
        return kStatus_LPSCI_Fail;
    }

    UART0_Type * base = g_lpsciBase[instance];
    lpsci_dma_state_t * lpsciDmaState = (lpsci_dma_state_t *)g_lpsciStatePtr[instance];

    /* Wait until the data is completely shifted out of shift register */
    while(!(UART0_BRD_S1_TC(base))) { }

    LPSCI_HAL_SetTxDmaCmd(base, false);
    LPSCI_HAL_SetRxDmaCmd(base, false);

    /* Release DMA channel. */
    DMA_DRV_FreeChannel(&lpsciDmaState->dmaLpsciRx);
    DMA_DRV_FreeChannel(&lpsciDmaState->dmaLpsciTx);

    /* Disable TX and RX */
    LPSCI_HAL_DisableTransmitter(base);
    LPSCI_HAL_DisableReceiver(base);

    /* Destroy TX and RX sema. */
    OSA_SemaDestroy(&lpsciDmaState->txIrqSync);
    OSA_SemaDestroy(&lpsciDmaState->rxIrqSync);

    /* Cleared state pointer. */
    g_lpsciStatePtr[instance] = NULL;

    /* Gate LPSCI module clock */
    CLOCK_SYS_DisableLpsciClock(instance);

    return kStatus_LPSCI_Success;
}
Exemplo n.º 3
0
/* See fsl_debug_console.h for documentation of this function.*/
debug_console_status_t DbgConsole_DeInit(void)
{
    if (s_debugConsole.type == kDebugConsoleNone)
    {
        return kStatus_DEBUGCONSOLE_Success;
    }

    switch(s_debugConsole.type)
    {
#if defined(UART_INSTANCE_COUNT)
        case kDebugConsoleUART:
            CLOCK_SYS_DisableUartClock(s_debugConsole.instance);
            break;
#endif
#if defined(UART0_INSTANCE_COUNT)
        case kDebugConsoleLPSCI:
            CLOCK_SYS_DisableLpsciClock(s_debugConsole.instance);
            break;
#endif
#if defined(LPUART_INSTANCE_COUNT)
        case kDebugConsoleLPUART:
             CLOCK_SYS_DisableLpuartClock(s_debugConsole.instance);
            break;
#endif
#if (defined(USB_INSTANCE_COUNT) && defined(BOARD_USE_VIRTUALCOM))
        case kDebugConsoleUSBCDC:
             VirtualCom_Deinit();
             CLOCK_SYS_DisableUsbfsClock(0);
            break;
#endif
        default:
            return kStatus_DEBUGCONSOLE_InvalidDevice;
    }

    s_debugConsole.type = kDebugConsoleNone;
    return kStatus_DEBUGCONSOLE_Success;
}