Beispiel #1
0
void NET_PRES_Deinitialize(SYS_MODULE_OBJ obj)
{
    if (!sNetPresData.initialized)
    {
        return;
    }
    
    uint8_t x;
    // Make sure all the sockets are closed down
    for (x = 0; x < NET_PRES_NUM_SOCKETS; x++)
    {
        if (sNetPresSockets[x].inUse)
        {
            if ((sNetPresSockets[x].socketType & NET_PRES_SKT_ENCRYPTED) == NET_PRES_SKT_ENCRYPTED)
            {
                NET_PRES_EncProviderConnectionClose fpClose = sNetPresSockets[x].provObject->fpClose;
                NET_PRES_TransClose fpTransClose = sNetPresSockets[x].transObject->fpClose;
                if (fpClose != NULL)
                {
                    (*fpClose)(sNetPresSockets[x].providerData);
                }
                if (fpTransClose)
                {
                    (*fpTransClose)(sNetPresSockets[x].transHandle);
                }
                sNetPresSockets[x].inUse = false;
            }
        }
    }
    
    // Make sure all the encryption providers are down
    for (x = 0; x < NET_PRES_NUM_INSTANCE; x++)
    {
        if (sNetPresData.encProvObjectSS[x].fpDeinit != NULL)
        {
            (*sNetPresData.encProvObjectSS[x].fpDeinit)();
        }
        if (sNetPresData.encProvObjectSC[x].fpDeinit != NULL)
        {
            (*sNetPresData.encProvObjectSC[x].fpDeinit)();
        }
        if (sNetPresData.encProvObjectDS[x].fpDeinit != NULL)
        {
            (*sNetPresData.encProvObjectDS[x].fpDeinit)();
        }
        if (sNetPresData.encProvObjectDC[x].fpDeinit != NULL)
        {
            (*sNetPresData.encProvObjectDC[x].fpDeinit)();
        }
    }
    
    if (OSAL_MUTEX_Delete(&sNetPresData.presMutex) != OSAL_RESULT_TRUE)
    {
        
    }
    memset(&sNetPresData, 0, sizeof(NET_PRES_InternalData));
    memset(&sNetPresSockets, 0, sizeof(NET_PRES_SocketData) * NET_PRES_NUM_SOCKETS);
}
uint32_t WDRV_MutexDestroy(OSAL_MUTEX_HANDLE_TYPE **mutex_ptr)
{
    OSAL_MUTEX_Delete(*mutex_ptr);   
    free(*mutex_ptr);
    return 0;
}
uint32_t wdrv_mutex_destroy(OSAL_MUTEX_HANDLE_TYPE **mutex_ptr)
{
    OSAL_MUTEX_Delete(*mutex_ptr);   
    free(*mutex_ptr);
    return 0;
}
Beispiel #4
0
void  DRV_USART_Deinitialize(SYS_MODULE_OBJ object)
{
    DRV_USART_OBJ * dObj;
    DRV_USART_BUFFER_OBJ * iterator;
    bool status;

    /* Check that the object is valid */
    
    if(object == SYS_MODULE_OBJ_INVALID)
    {
        SYS_DEBUG(0, "Invalid system object handle" );
        return;
    }
    
    if(object >= DRV_USART_INSTANCES_NUMBER)
    {
        SYS_DEBUG(0, "Invalid system object handle" );
        return;
    }

    dObj = (DRV_USART_OBJ*) &gDrvUSARTObj[object];

    if(!dObj->inUse)
    {
        SYS_DEBUG(0, "Invalid system object handle");
        return;
    }

    /* The driver will not have clients when it is
       being de-initialized. So the order in which
       we do the following steps is not that important */

    /* Indicate that this object is not is use */
    dObj->inUse = false;

    /* Deinitialize the USART status */
    dObj->status =  SYS_STATUS_UNINITIALIZED ;

    /* Disable the interrupt */
    status = _DRV_USART_InterruptSourceDisable(dObj->txInterruptSource) ;
    status = _DRV_USART_InterruptSourceDisable(dObj->rxInterruptSource) ;
    status = _DRV_USART_InterruptSourceDisable(dObj->errorInterruptSource);

    /* Disable USART module */
    PLIB_USART_Disable (dObj->moduleId);

    /* Deallocate all mutexes */
    OSAL_ASSERT( (OSAL_MUTEX_Delete(&(dObj->mutexDriverInstance)) == OSAL_RESULT_TRUE),
            "Unable to delete client handle mutex" );

    
    /* TODO: Disable all DMA interrupts */

    /* Remove all objects from the read and write queue */

    iterator = dObj->queueWrite;
    while(iterator != NULL)
    {
        /* Return the buffer object to the pool */
        iterator->inUse = false;
        iterator = iterator->next;
    }

    iterator = dObj->queueRead;
    while(iterator != NULL)
    {
        /* Return the buffer object to the pool */
        iterator->inUse = false;
        iterator = iterator->next;
    }
}