Beispiel #1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : RTC_DRV_Deinit
 * Description   : Disable RTC module clock gate control
 * This function will disable clock gate to RTC module.
 *
 *END**************************************************************************/
void RTC_DRV_Deinit(uint32_t instance)
{
    /* Disable RTC interrupts.*/
    INT_SYS_DisableIRQ(g_rtcIrqId[instance]);
    INT_SYS_DisableIRQ(g_rtcSecondsIrqId[instance]);

    /* Disable the RTC counter */
    RTC_HAL_Disable(g_rtcBaseAddr[instance]);

    /* Disable clock gate to RTC module */
    CLOCK_SYS_DisableRtcClock( 0U);
    s_rtcRepeatAlarmState = NULL;
}
Beispiel #2
0
/*FUNCTION**********************************************************************
 *
 * Function Name : ENC_DRV_Deinit
 * Description   : De-initialize the Quadrature Encoder module. It will
 * shut down its clock to reduce the power consumption. 
 *
 *END**************************************************************************/
void ENC_DRV_Deinit(uint32_t instance)
{
    assert(instance < ENC_INSTANCE_COUNT);

    /* Disables Clock to Quadrature Encoder peripheral. */
    CLOCK_SYS_DisableEncClock(instance);
    
    /* Disable ENC interrupt on NVIC level. */
    INT_SYS_DisableIRQ(g_encCmpIrqId[instance]);
    INT_SYS_DisableIRQ(g_encWdtIrqId[instance]);
    INT_SYS_DisableIRQ(g_encHomeIrqId[instance]);
    INT_SYS_DisableIRQ(g_encIndexIrqId[instance]);
}
/*FUNCTION**********************************************************************
 *
 * Function Name : LPUART_DRV_Deinit
 * Description   : This function shuts down the UART by disabling interrupts and
 *                 transmitter/receiver.
 *
 *END**************************************************************************/
lpuart_status_t LPUART_DRV_Deinit(uint32_t instance)
{
    assert(instance < LPUART_INSTANCE_COUNT);

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

    LPUART_Type * base = g_lpuartBase[instance];
    lpuart_state_t * lpuartState = (lpuart_state_t *)g_lpuartStatePtr[instance];

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

    /* Disable LPUART interrupt. */
    INT_SYS_DisableIRQ(g_lpuartRxTxIrqId[instance]);

    /* disable tx and rx */
    LPUART_HAL_SetTransmitterCmd(base, false);
    LPUART_HAL_SetReceiverCmd(base, false);

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

    /* Clear our saved pointer to the state structure */
    g_lpuartStatePtr[instance] = NULL;

    /* gate lpuart module clock */
    CLOCK_SYS_DisableLpuartClock(instance);

    return kStatus_LPUART_Success;
}
Beispiel #4
0
/*FUNCTION*********************************************************************
 *
 * Function Name : PDB_DRV_Init
 * Description   : Initialize the PDB counter and trigger input for PDB module.
 * It resets PDB registers and enables the clock for PDB. So it should be 
 * called before any operation to PDB module. After initialized, the PDB can
 * ack as a triggered timer, which lays the foundation for other features in
 * PDB module.
 *
 *END*************************************************************************/
pdb_status_t PDB_DRV_Init(uint32_t instance, const pdb_timer_config_t *userConfigPtr)
{
    assert(instance < PDB_INSTANCE_COUNT);
    PDB_Type * base = g_pdbBase[instance];

    if (!userConfigPtr)
    {
        return kStatus_PDB_InvalidArgument;
    }
    /* Enable the clock gate from clock manager. */
    CLOCK_SYS_EnablePdbClock(instance);

    /* Reset the registers for PDB module to reset state. */
    PDB_HAL_Init(base);
    PDB_HAL_Enable(base);
    PDB_HAL_ConfigTimer(base, userConfigPtr);

    /* Configure NVIC. */
    if (userConfigPtr->intEnable)
    {
        INT_SYS_EnableIRQ(g_pdbIrqId[instance] );/* Enable PDB interrupt in NVIC level.*/
    }
    else
    {
        INT_SYS_DisableIRQ(g_pdbIrqId[instance] );/* Disable PDB interrupt in NVIC level.*/
    }

    return kStatus_PDB_Success;
}
/*FUNCTION**********************************************************************
 *
 * Function Name : SPI_DRV_DmaMasterDeinit
 * Description   : Shuts down a SPI instance with DMA support.
 *
 * This function resets the SPI peripheral, gates its clock, disables any used interrupts to
 * the core, and releases any used DMA channels.
 *
 *END**************************************************************************/
spi_status_t SPI_DRV_DmaMasterDeinit(uint32_t instance)
{
    /* instantiate local variable of type spi_dma_master_state_t and point to global state */
    spi_dma_master_state_t * spiDmaState = (spi_dma_master_state_t *)g_spiStatePtr[instance];
    SPI_Type *base = g_spiBase[instance];

    /* Restore the module to defaults which includes disabling the SPI then power it down.*/
    SPI_HAL_Init(base);

    /* destroy the interrupt sync object.*/
    OSA_SemaDestroy(&spiDmaState->irqSync);

    /* Disable SPI interrupt.*/
    INT_SYS_DisableIRQ(g_spiIrqId[instance]);

    /* Gate the clock for SPI.*/
    CLOCK_SYS_DisableSpiClock(instance);

    /* Free DMA channels */
    DMA_DRV_FreeChannel(&spiDmaState->dmaReceive);
    DMA_DRV_FreeChannel(&spiDmaState->dmaTransmit);

    /* Clear state pointer. */
    g_spiStatePtr[instance] = NULL;

    return kStatus_SPI_Success;
}
/*FUNCTION**********************************************************************
 *
 * Function Name : I2C_DRV_SlaveDeinit
 * Description   : Shuts down the I2C slave driver.
 * This function will clear the control register and turn off the clock to the
 * module.
 *
 *END**************************************************************************/
void I2C_DRV_SlaveDeinit(uint32_t instance)
{
    assert(instance < HW_I2C_INSTANCE_COUNT);

    uint32_t baseAddr = g_i2cBaseAddr[instance];
    i2c_slave_state_t * i2cSlaveState = (i2c_slave_state_t *)g_i2cStatePtr[instance];

#if FSL_FEATURE_I2C_HAS_START_STOP_DETECT
    /* Disable I2C START&STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStartStopIntCmd(baseAddr,false);
#endif
#if FSL_FEATURE_I2C_HAS_STOP_DETECT
    /* Disable STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStopIntCmd(baseAddr,false);
#endif

    /* Disable I2C interrupt. */
    I2C_HAL_SetIntCmd(baseAddr, false);

    /* Turn off I2C.*/
    I2C_HAL_Disable(baseAddr);

    /* Disable clock for I2C.*/
    CLOCK_SYS_DisableI2cClock(instance);

    /* Disable I2C NVIC interrupt */
    INT_SYS_DisableIRQ(g_i2cIrqId[instance]);

    /* Destroy sema. */
    OSA_EventDestroy(&i2cSlaveState->irqEvent);

    /* Clear runtime structure poniter.*/
    g_i2cStatePtr[instance] = NULL;
}
Beispiel #7
0
/*FUNCTION**********************************************************************
 *
 * Function Name : LPSCI_DRV_Deinit
 * Description   : This function shuts down the LPSCI by disabling interrupts
 * and the transmitter/receiver.
 *
 *END**************************************************************************/
void LPSCI_DRV_Deinit(uint32_t instance)
{
    assert(instance < HW_UART0_INSTANCE_COUNT);

    uint32_t baseAddr = g_lpsciBaseAddr[instance];
    lpsci_state_t * lpsciState = (lpsci_state_t *)g_lpsciStatePtr[instance];

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

    /* Disable the interrupt */
    INT_SYS_DisableIRQ(g_lpsciRxTxIrqId[instance]);

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

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

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

    /* Gate LPSCI module clock */
    CLOCK_SYS_DisableUartClock(instance);
}
Beispiel #8
0
/*FUNCTION**********************************************************************
 *
 * Function Name : PIT_DRV_Deinit
 * Description   : Disable PIT module and gate control
 * This function will disable all PIT interrupts and PIT clock. Then gate the
 * PIT clock control. pit_init must be called in order to use PIT again.
 *
 *END**************************************************************************/
pit_status_t PIT_DRV_Deinit(uint32_t instance)
{
    assert(instance < PIT_INSTANCE_COUNT);

    PIT_Type * base = g_pitBase[instance];
    uint32_t i;

    /* Exit if current instance is gated.*/
    if (!CLOCK_SYS_GetPitGateCmd(instance))
    {
        return kStatus_PIT_Fail;
    }

    /* Disable all PIT interrupts. Clear the chain bit if available */
    for (i=0; i < FSL_FEATURE_PIT_TIMER_COUNT; i++)
    {
        PIT_HAL_SetIntCmd(base, i, false);
        INT_SYS_DisableIRQ(g_pitIrqId[i]);
#if FSL_FEATURE_PIT_HAS_CHAIN_MODE
        PIT_HAL_SetTimerChainCmd(base, i, false);
#endif
    }

    /* Disable PIT module clock*/
    PIT_HAL_Disable(base);

    /* Gate PIT clock control*/
    CLOCK_SYS_DisablePitClock(instance);

    return kStatus_PIT_Success;
}
Beispiel #9
0
/*FUNCTION**********************************************************************
 *
 * Function Name : DSPI_DRV_MasterDeinit
 * Description   : Shutdown a DSPI instance.
 * This function resets the DSPI peripheral, gates its clock, and disables the interrupt to
 * the core.
 *
 *END**************************************************************************/
dspi_status_t DSPI_DRV_MasterDeinit(uint32_t instance)
{
    /* instantiate local variable of type dspi_master_state_t and point to global state */
    dspi_master_state_t * dspiState = (dspi_master_state_t *)g_dspiStatePtr[instance];
    SPI_Type *base = g_dspiBase[instance];

    /* First stop transfers */
    DSPI_HAL_StopTransfer(base);

    /* Restore the module to defaults then power it down. This also disables the DSPI module.*/
    DSPI_HAL_Init(base);

    /* destroy the interrupt sync object.*/
    OSA_SemaDestroy(&dspiState->irqSync);

    /* disable the interrupt*/
    INT_SYS_DisableIRQ(g_dspiIrqId[instance]);

    /* Gate the clock for DSPI.*/
    CLOCK_SYS_DisableSpiClock(instance);

    /* Clear state pointer. */
    g_dspiStatePtr[instance] = NULL;

    return kStatus_DSPI_Success;
}
/*FUNCTION********************************************************************* 
 *
 * Function Name : XBAR_DRV_Deinit
 * Description   : De-initialize the XBAR module. It shuts down XBAR module 
 * clock to reduce the power consumption and resets XBAR's registers to a known 
 * state. 
 *
 *END*************************************************************************/
void XBAR_DRV_Deinit(void)
{
    XBARA_Type * xbara_base = g_xbaraBase[0];
    
    /* Cleared state pointer. */ 
    g_xbarState = NULL; 
    
    /* Disable XBAR interrupt on NVIC level. */
    INT_SYS_DisableIRQ(g_xbarIrqId[0]);
          
    /*Initialize module to reset state - clears all configurations*/
     XBARA_HAL_Init(xbara_base);

     /* Disable XBARB module clock */
     CLOCK_SYS_DisableXbarClock(XBARA_MODULE);
     
#if !defined(FSL_FEATURE_XBAR_HAS_SINGLE_MODULE) 
  
     XBARB_Type * xbarb_base = g_xbarbBase[0];
          
     /*Initialize module to reset state - clears all configurations*/
     XBARB_HAL_Init(xbarb_base);
         
     /* Disable XBARB module clock */
     CLOCK_SYS_DisableXbarClock(XBARB_MODULE);   
#endif /* FSL_FEATURE_XBAR_HAS_SINGLE_MODULE */
}
/*FUNCTION**********************************************************************
 *
 * Function Name : DSPI_DRV_DmaMasterDeinit
 * Description   : Shuts down a DSPI instance with DMA support.
 *
 * This function resets the DSPI peripheral, gates its clock, disables any used interrupts to
 * the core, and releases any used DMA channels.
 *
 *END**************************************************************************/
dspi_status_t DSPI_DRV_DmaMasterDeinit(uint32_t instance)
{
    /* instantiate local variable of type dspi_dma_master_state_t and point to global state */
    dspi_dma_master_state_t * dspiDmaState = (dspi_dma_master_state_t *)g_dspiStatePtr[instance];
    SPI_Type *base = g_dspiBase[instance];

    /* First stop transfers */
    DSPI_HAL_StopTransfer(base);

    /* Restore the module to defaults then power it down. This also disables the DSPI module.*/
    DSPI_HAL_Init(base);

    /* destroy the interrupt sync object.*/
    OSA_SemaDestroy(&dspiDmaState->irqSync);

    /* disable the interrupt*/
    INT_SYS_DisableIRQ(g_dspiIrqId[instance]);

    /* Gate the clock for DSPI.*/
    CLOCK_SYS_DisableSpiClock(instance);

    /* Release all of the DMA channels used in the driver. DMA channel structures are stored in
     * the run-time state structure.
     */
    DMA_DRV_FreeChannel(&dspiDmaState->dmaTxDataChannel);
    DMA_DRV_FreeChannel(&dspiDmaState->dmaTxCmdChannel);
    DMA_DRV_FreeChannel(&dspiDmaState->dmaRxChannel);

    /* Clear state pointer. */
    g_dspiStatePtr[instance] = NULL;

    return kStatus_DSPI_Success;
}
/*FUNCTION**********************************************************************
*
* Function Name : TSI_DRV_DeInit
* Description   : De initialize whole the TSI peripheral and driver to be ready
* for any future use and don't load the system.
*
*END**************************************************************************/
tsi_status_t TSI_DRV_DeInit(uint32_t instance)
{
    assert(instance < TSI_INSTANCE_COUNT);

    TSI_Type * base = g_tsiBase[instance];
    tsi_state_t * tsiState = g_tsiStatePtr[instance];

    if (tsiState == NULL)
    {
        return kStatus_TSI_Error;
    }

    TSI_HAL_DisableInterrupt(base);
    tsiState->opModesData[tsiState->opMode].enabledElectrodes = 0;
    TSI_HAL_ClearOutOfRangeFlag(base);
    TSI_HAL_ClearEndOfScanFlag(base);
    TSI_HAL_DisableModule(base);

    /* Disable the interrupt */
    INT_SYS_DisableIRQ(g_tsiIrqId[instance]);

    /* Destroy the interrupt synch object*/
    OSA_SemaDestroy(&tsiState->irqSync);

    /* Clear runtime structure pointer.*/
    tsiState = NULL;

    /* Gate TSI module clock */
    CLOCK_SYS_DisableTsiClock(instance);

    return kStatus_TSI_Success;
}
Beispiel #13
0
void gpioDisableWakeUp(void)
{
    // disables interrupt
    PORT_HAL_SetPinIntMode(BOARD_SW_LLWU_BASE, BOARD_SW_LLWU_PIN, kPortIntDisabled);
    INT_SYS_DisableIRQ(BOARD_SW_LLWU_IRQ_NUM);

    LLWU_HAL_ClearExternalPinWakeupFlag(LLWU_BASE_PTR, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN);
    LLWU_HAL_SetExternalInputPinMode(LLWU_BASE_PTR,kLlwuExternalPinDisabled, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN);
}
/*FUNCTION**********************************************************************
 *
 * Function Name : FTM_DRV_Deinit
 * Description   : Shuts down the FTM driver.
 *
 *END**************************************************************************/
void FTM_DRV_Deinit(uint32_t instance)
{
    assert(instance < FTM_INSTANCE_COUNT);

    /* disable clock for FTM.*/
    CLOCK_SYS_DisableFtmClock(instance);

    INT_SYS_DisableIRQ(g_ftmIrqId[instance]);
}
/*FUNCTION**********************************************************************
 *
 * Function Name : SLCD_DRV_Deinit
 * Description   : Deinit the SLCD driver.
 * This function will deinit the SLCD driver with reset SLCD driver to reset state and
 * close SLCD clock.
 *
 *END**************************************************************************/
void SLCD_DRV_Deinit(uint32_t instance)
{
    assert(instance < LCD_INSTANCE_COUNT);
    LCD_Type * base = g_slcdBase[instance];
    
    INT_SYS_DisableIRQ(g_slcdIrqId[instance]);  /*!< Disables SLCD interrupt in NVIC   */
    SLCD_HAL_Init(base);                        /*!< Sets the SLCD to a workable state */
    CLOCK_SYS_DisableSlcdClock(instance);       /*!< Disables SLCD clock               */      
}
/*FUNCTION**********************************************************************
 *
 * Function Name : QUADTMR_DRV_Deinit
 * Description   : Shuts down the Quad Timer driver.
 * Gates the module clock and disables the interrupt in the system interrupt controller.
 *
 *END**************************************************************************/
void QUADTMR_DRV_Deinit(uint32_t instance)
{
    assert(instance < TMR_INSTANCE_COUNT);

    /* disable clock for Quad timer.*/
    CLOCK_SYS_DisableQuadTmrClock(instance);

    INT_SYS_DisableIRQ(g_quadtmrIrqId[instance]);
}
/*FUNCTION**********************************************************************
 *
 * Function Name : MMAU_DRV_Deinit
 * Description   : Deinitilize the MMAU module
 *
 *END**************************************************************************/
mmau_status_t MMAU_DRV_Deinit(void){
    
    MMAU_HAL_Init(MMAU);
    
    /* Enable MMAU interrupt on NVIC level. */
    INT_SYS_DisableIRQ(g_mmauIrqId[0]);
    
    return kStatus_MMAU_Success;
}
Beispiel #18
0
/*FUNCTION*********************************************************************
 *
 * Function Name : PDB_DRV_Deinit
 * Description   : De-initialize the PDB module.
 * When the PDB module is not used. Calling this function would shutdown the 
 * PDB module and reduce the power consumption.
 *
 *END*************************************************************************/
pdb_status_t PDB_DRV_Deinit(uint32_t instance)
{
    assert(instance < PDB_INSTANCE_COUNT);
    PDB_Type * base = g_pdbBase[instance];

    INT_SYS_DisableIRQ( g_pdbIrqId[instance] );
    PDB_HAL_Disable(base);
    CLOCK_SYS_DisablePdbClock(instance);

    return kStatus_PDB_Success;
}
/*FUNCTION*********************************************************************
 *
 * Function Name : ADC16_DRV_Deinit
 * Description   : De-initialize the comparator in ADC module. It will gate
 * the clock to ADC module. When ADC is no long used in application, calling
 * this API will shut down the device to reduce power consumption.
 *
 *END*************************************************************************/
adc16_status_t ADC16_DRV_Deinit(uint32_t instance)
{
    assert(instance < ADC_INSTANCE_COUNT);
    ADC_Type * base = g_adcBase[instance];

    /* Disable ADC interrupt in NVIC level. */
    INT_SYS_DisableIRQ( g_adcIrqId[instance] );

    ADC16_HAL_Init(base);

    /* Disable clock for ADC. */
    CLOCK_SYS_DisableAdcClock(instance);

    return kStatus_ADC16_Success;
}
Beispiel #20
0
OSStatus MicoUartFinalize( mico_uart_t uart )
{
    uint32_t  Instance = getInstanceBy(uart);
    // uart = MICO_UART_1; //test
#ifdef  UART_IRQ_APP 
    UART_DRV_Deinit(Instance);
#else     
    UART_DRV_EdmaDeinit(Instance);    
    EDMA_DRV_Deinit();   
    INT_SYS_DisableIRQ(g_uartRxTxIrqId[Instance]);
#endif
#ifndef NO_MICO_RTOS
  mico_rtos_deinit_semaphore(&uart_interfaces[uart].rx_complete);
  mico_rtos_deinit_semaphore(&uart_interfaces[uart].tx_complete);
#endif  
  
  return kNoErr;
}
void SpiDeInit(Spi_t *obj)
{
    /* First stop transfers */
    DSPI_HAL_StopTransfer(obj->Spi);

    /* Restore the module to defaults then power it down. This also disables the DSPI module.*/
    DSPI_HAL_Init(obj->Spi);

    /* disable the interrupt*/
    INT_SYS_DisableIRQ (g_dspiIrqId[obj->instance]);

    /* Gate the clock for DSPI.*/
    CLOCK_SYS_DisableSpiClock(obj->instance);

    GpioInit(&obj->Mosi, obj->Mosi.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0);
    GpioInit(&obj->Miso, obj->Miso.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0);
    GpioInit(&obj->Sclk, obj->Sclk.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0);
    GpioInit(&obj->Nss, obj->Nss.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1);
}
Beispiel #22
0
/*FUNCTION**********************************************************************
 *
 * Function Name : I2C_DRV_SlaveDeinit
 * Description   : Shuts down the I2C slave driver.
 * This function will clear the control register and turn off the clock to the
 * module.
 *
 *END*/
i2c_status_t I2C_DRV_SlaveDeinit(uint32_t instance)
{
    assert(instance < I2C_INSTANCE_COUNT);

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

    I2C_Type * base = g_i2cBase[instance];
    i2c_slave_state_t * i2cSlaveState = (i2c_slave_state_t *)g_i2cStatePtr[instance];

#if FSL_FEATURE_I2C_HAS_START_STOP_DETECT
     /** Disable I2C START&STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStartStopIntCmd(base,false);
#endif
#if FSL_FEATURE_I2C_HAS_STOP_DETECT
     /** Disable STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStopIntCmd(base,false);
#endif

     /** Disable I2C interrupt. */
    I2C_HAL_SetIntCmd(base, false);

     /** Turn off I2C.*/
    I2C_HAL_Disable(base);

     /** Disable clock for I2C.*/
    CLOCK_SYS_DisableI2cClock(instance);

     /** Disable I2C NVIC interrupt */
    INT_SYS_DisableIRQ(g_i2cIrqId[instance]);

     /** Destroy sema. */
    OSA_EventDestroy(&i2cSlaveState->irqEvent);

     /** Clear runtime structure poniter.*/
    g_i2cStatePtr[instance] = NULL;

    return kStatus_I2C_Success;
}
Beispiel #23
0
OSStatus MicoUartFinalize( mico_uart_t uart )
{
  
    uart = MICO_UART_1; //test
#ifdef  UART_IRQ_APP 
    UART_DRV_Deinit(BOARD_APP_UART_INSTANCE);
#else     
    UART_DRV_EdmaDeinit(BOARD_APP_UART_INSTANCE);    
    EDMA_DRV_Deinit();   
    INT_SYS_DisableIRQ(g_uartRxTxIrqId[BOARD_APP_UART_INSTANCE]);
#endif
#if ADD_OS_CODE
#ifndef NO_MICO_RTOS
  mico_rtos_deinit_semaphore(&uart_interfaces[uart].rx_complete);
  mico_rtos_deinit_semaphore(&uart_interfaces[uart].tx_complete);
#endif  
#endif  
  
  return kNoErr;
}
/*FUNCTION**********************************************************************
 *
 * Function Name : SPI_DRV_DmaSlaveDeinit
 * Description   : De-initializes the device.
 * Clears the control register and turns off the clock to the module.
 *
 *END**************************************************************************/
spi_status_t SPI_DRV_DmaSlaveDeinit(uint32_t instance)
{
    spi_dma_slave_state_t * spiState = (spi_dma_slave_state_t *)g_spiStatePtr[instance];
    SPI_Type *base = g_spiBase[instance];

    assert(instance < SPI_INSTANCE_COUNT);

    /* Disable SPI interrupt */
    INT_SYS_DisableIRQ(g_spiIrqId[instance]);

    /* Reset the SPI module to its default settings including disabling SPI and its interrupts */
    SPI_HAL_Init(base);

#if FSL_FEATURE_SPI_16BIT_TRANSFERS
    if (g_spiFifoSize[instance] != 0)
    {
        SPI_HAL_SetFifoIntCmd(base, kSpiRxFifoNearFullInt, false);
    }

    /* disable transmit interrupt */
    SPI_HAL_SetIntMode(base, kSpiTxEmptyInt, false);
#endif /* FSL_FEATURE_SPI_16BIT_TRANSFERS */

    /* Free DMA channels */
    DMA_DRV_FreeChannel(&spiState->dmaReceive);
    DMA_DRV_FreeChannel(&spiState->dmaTransmit);

    /* Disable clock for SPI */
    CLOCK_SYS_DisableSpiClock(instance);

    /* Destroy the event */
    OSA_EventDestroy(&spiState->event);

    /* Clear state pointer */
    g_spiStatePtr[instance] = NULL;

    return kStatus_SPI_Success;
}
Beispiel #25
0
void eth_arch_disable_interrupts(void) {
  INT_SYS_DisableIRQ(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetRxfInt]]);
  INT_SYS_DisableIRQ(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetTxfInt]]);
}
Beispiel #26
0
/*FUNCTION**********************************************************************
 *
 * Function Name : LPTMR_DRV_Init
 * Description   : initializes the LPTMR driver.
 * This function will initialize the LPTMR driver according to user configure
 * strcuture.
 *
 *END*/
lptmr_status_t LPTMR_DRV_Init(uint32_t instance, lptmr_state_t *userStatePtr, const lptmr_user_config_t* userConfigPtr)
{
    assert(instance < LPTMR_INSTANCE_COUNT);

    LPTMR_Type * base = g_lptmrBase[instance];
    lptmr_prescaler_user_config_t prescalerUserConfig;
    lptmr_working_mode_user_config_t workingModeUserConfig;

    if ((!userConfigPtr) || (!userStatePtr))
    {
        return kStatus_LPTMR_NullArgument;
    }

     /** prescaler value 0 is invalid while working as pulse counter */
    if ((kLptmrTimerModePulseCounter == userConfigPtr->timerMode) &&
         (true == userConfigPtr->prescalerEnable) &&
         (kLptmrPrescalerDivide2 == userConfigPtr->prescalerValue))
    {
        return kStatus_LPTMR_InvalidPrescalerValue;
    }

     /** Enable clock for lptmr */
    CLOCK_SYS_EnableLptmrClock(instance);

     /** Disable lptmr and reset lptmr logic */
    LPTMR_HAL_Disable(base);

     /** LPTMR prescaler configure */
    prescalerUserConfig.prescalerClockSelect = (lptmr_prescaler_clock_select_t)userConfigPtr->prescalerClockSource;
    prescalerUserConfig.prescalerBypass = (uint8_t)(userConfigPtr->prescalerEnable == false);
    prescalerUserConfig.prescalerValue = userConfigPtr->prescalerValue;
    LPTMR_HAL_SetPrescalerMode(base, prescalerUserConfig);

     /** Working Mode configure */
    workingModeUserConfig.timerModeSelect = userConfigPtr->timerMode;
    workingModeUserConfig.freeRunningEnable = userConfigPtr->freeRunningEnable;
    workingModeUserConfig.pinPolarity = userConfigPtr->pinPolarity;
    workingModeUserConfig.pinSelect = userConfigPtr->pinSelect;
    LPTMR_HAL_SetTimerWorkingMode(base,workingModeUserConfig);

     /** Internal context */
    lptmr_state_ptrs[instance] = userStatePtr;

    userStatePtr->userCallbackFunc = NULL;

     /** LPTMR interrupt */
    if (userConfigPtr->isInterruptEnabled)
    {
        LPTMR_HAL_SetIntCmd(base,true);
        INT_SYS_EnableIRQ(g_lptmrIrqId[instance]);
    }
    else
    {
        LPTMR_HAL_SetIntCmd(base,false);
        INT_SYS_DisableIRQ(g_lptmrIrqId[instance]);
    }

     /** Caculate prescaler clock frequency */
    if ( kLptmrTimerModeTimeCounter == userConfigPtr->timerMode)
    {
        userStatePtr->prescalerClockHz = CLOCK_SYS_GetLptmrFreq(instance,
                userConfigPtr->prescalerClockSource);

        if (userConfigPtr->prescalerEnable)
        {
            userStatePtr->prescalerClockHz = (userStatePtr->prescalerClockHz >> ((uint32_t)(userConfigPtr->prescalerValue+1)));
        }