예제 #1
0
wiced_result_t wiced_rtos_delete_thread( wiced_thread_t* thread )
{
    wiced_result_t result =  (wiced_result_t) host_rtos_finish_thread( WICED_GET_THREAD_HANDLE( thread ) );

    if ( result != WICED_WWD_SUCCESS )
    {
        return result;
    }

    if ( thread->stack != NULL )
    {
        malloc_transfer_to_curr_thread( thread->stack );
    }

    malloc_leak_check( &thread->handle, LEAK_CHECK_THREAD );

    result =  (wiced_result_t) host_rtos_delete_terminated_thread( WICED_GET_THREAD_HANDLE( thread ) );

    if ( result == WICED_WWD_SUCCESS )
    {
        if ( thread->stack != NULL )
        {
            free( thread->stack );
            thread->stack = NULL;
        }
    }

    return result;
}
예제 #2
0
wiced_result_t wiced_rtos_delete_thread(wiced_thread_t* thread)
{
    wiced_result_t result;

    malloc_leak_check( &thread, LEAK_CHECK_THREAD );

    result = host_rtos_finish_thread( WICED_GET_THREAD_HANDLE( thread ) );

    if ( result != WICED_WWD_SUCCESS )
    {
        return result;
    }

    return host_rtos_delete_terminated_thread( WICED_GET_THREAD_HANDLE( thread ) );
}
예제 #3
0
/** The WWD Thread function
 *
 *  This is the main loop of the WWD Thread.
 *  It simply calls @ref wwd_thread_poll_all to send/receive all waiting packets, then goes
 *  to sleep.  The sleep has a 100ms timeout, causing the send/receive queues to be
 *  checked 10 times per second in case an interrupt is missed.
 *  Once the quit flag has been set, flags/mutexes are cleaned up, and the function exits.
 *
 * @param thread_input  : unused parameter needed to match thread prototype.
 *
 */
static void wwd_thread_func( wwd_thread_arg_t /*@unused@*/thread_input ) /*@globals killed wwd_transceive_semaphore@*/ /*@modifies wwd_wlan_status, wwd_bus_interrupt, wwd_thread_quit_flag, wwd_inited, wwd_thread@*/
{
    int8_t rx_status;
    int8_t tx_status;
    wwd_result_t wwd_result;

    UNUSED_PARAMETER(thread_input);

    WWD_LOG(("Started Wiced Thread\n"));

    /* Interrupts may be enabled inside thread. To make sure none lost set flag now. */
    wwd_inited = WICED_TRUE;

    while ( wwd_thread_quit_flag != WICED_TRUE )
    {
        /* If was in deep sleep and needs wakeup, then wake first */
        if ( WICED_TRUE == wwd_wifi_ds1_needs_wake( ) )
        {
            wwd_result = wwd_wifi_ds1_finish_wake( );
            if ( WWD_SUCCESS != wwd_result )
            {
                WPRINT_WWD_ERROR(("Err %d:Unable to do ds1 wake", wwd_result));
            }
        }

        /* Check if we were woken by interrupt */
        if ( ( wwd_bus_interrupt == WICED_TRUE ) ||
           ( WWD_BUS_USE_STATUS_REPORT_SCHEME ) )
        {
           wwd_bus_interrupt = WICED_FALSE;

           /* Check if the interrupt indicated there is a packet to read */
           if ( wwd_bus_packet_available_to_read( ) != 0)
           {
               /* Receive all available packets */
               do
               {
                   rx_status = wwd_thread_receive_one_packet( );
               } while ( rx_status != 0 );
           }
        }

        /* Send all queued packets */
        do
        {
             tx_status = wwd_thread_send_one_packet( );
        }
        while (tx_status != 0);

        /* Sleep till WLAN do something */
        wwd_wait_for_wlan_event( &wwd_transceive_semaphore );
        WWD_LOG(("Wiced Thread: Woke\n"));
    }

    /* Set flag before releasing objects */
    wwd_inited = WICED_FALSE;

    /* Reset the quit flag */
    wwd_thread_quit_flag = WICED_FALSE;

    /* Delete the semaphore */
    (void) host_rtos_deinit_semaphore( &wwd_transceive_semaphore );  /* Ignore return - not much can be done about failure */

    wwd_sdpcm_quit( );

    WWD_LOG(("Stopped Wiced Thread\n"));

    if ( WWD_SUCCESS != host_rtos_finish_thread( &wwd_thread ) )
    {
        WPRINT_WWD_DEBUG(("Could not close WWD thread\n"));
    }
}