Example #1
0
File: ex4.c Project: dev-zzo/Embsys
void tx_application_define(void *first) 
{
	tx_thread_create(&mainInitThread, "Main Init Thread", mainInitThreadMainFunc, 0, mainInitThreadStack,
        TX_MINIMUM_STACK, 1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
    tx_thread_create(&idleThread, "Idle thread", idleThreadMainFunc, 0, idleThreadStack,
        TX_MINIMUM_STACK, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, 1,TX_AUTO_START);
    embsys_timer_init(TX_TICK_MS);
    _enable();
}
Example #2
0
void tx_application_define(void *first_unused_memory) {
	/* Create the event flags. */
	intHARDWARE();
	status=timer0_register(1,true,none);
//	addMessages();
	//GUI_thread
	status=tx_thread_create(&GUI_thread, "GUI_thread", startUI, inputText,&guistack, STACK_SIZE,	16, 16, 4, TX_AUTO_START);
	//reciveThread
	status=tx_thread_create(&receiveThread, "NetworkReceiveThread", sendReceiveLoop, inputText,&receiveThreadStack, STACK_SIZE,	16, 16, 4, TX_AUTO_START);

	status=tx_queue_create(&receiveQueue, "receiveQueue", TX_1_ULONG, &receiveQueueStack, QUEUE_SIZE*sizeof(ULONG));
	status=tx_queue_create(&ToSendQueue, "ToSendQueue", TX_1_ULONG, &sendQueueStack, QUEUE_SIZE*sizeof(ULONG));

}
Example #3
0
/**
 *  Application Define function - creates and starts the application thread
 *  Called by ThreadX whilst it is initialising
 *
 *  @param first_unused_memory: unused parameter - required to match prototype
 */
void tx_application_define( void *first_unused_memory )
{
    TX_THREAD* app_thread_handle;
    char*      app_thread_stack;
    UINT       result;

    UNUSED_PARAMETER(first_unused_memory);

    /* Restore system clock taking into account time spent in deep-sleep */
    if ( WICED_DEEP_SLEEP_IS_WARMBOOT_HANDLE( ) )
    {
        tx_time_set( before_deep_sleep_time + wiced_deep_sleep_ticks_since_enter( ) );
    }

    /* Create the application thread.  */
    app_thread_handle = (TX_THREAD*)MALLOC_OBJECT("app thread", TX_THREAD);
    app_thread_stack  = (char*)malloc_named("app stack", APPLICATION_STACK_SIZE);

    result = tx_thread_create( app_thread_handle, (char*)"app thread", application_thread_main, 0, app_thread_stack, APPLICATION_STACK_SIZE, WICED_APPLICATION_PRIORITY, WICED_APPLICATION_PRIORITY, TX_NO_TIME_SLICE, TX_AUTO_START );

    if ( TX_SUCCESS != result )
    {
        free ( app_thread_handle );
        free ( app_thread_stack );
        app_thread_handle = NULL;
        app_thread_stack  = NULL;
    }
    else
    {
        ( void )tx_thread_entry_exit_notify( app_thread_handle, application_thread_cleanup );
    }
}
Example #4
0
void cmd_init(void)
{
	/* Turn on logging by default */
	log_init();
	tx_thread_create(&cmd_thread, "cmd_thread", cmd_parser, 0,
					 (void *)&cmd_stack[0], sizeof(cmd_stack), 21, 21, 2, 
					 TX_AUTO_START);
}
Example #5
0
void tx_application_define(void *first_unused_memory)
{

	CHAR *pool_pointer;


	/* Create a byte memory pool from which to allocate
	the thread stacks. */
	tx_byte_pool_create(&my_byte_pool, "my_byte_pool",
		first_unused_memory,
		DEMO_BYTE_POOL_SIZE);

	/* Put system definition stuff in here, e.g., thread
	creates and other assorted create information. */

	/* Allocate the stack for the Speedy_Thread. */
	tx_byte_allocate(&my_byte_pool, (VOID **) &pool_pointer,
		DEMO_STACK_SIZE, TX_NO_WAIT);

	/* Create the Speedy_Thread. */
	tx_thread_create(&Speedy_Thread, "Speedy_Thread",
		Speedy_Thread_entry, 0,
		pool_pointer, DEMO_STACK_SIZE, 5, 5,
		TX_NO_TIME_SLICE, TX_AUTO_START);

	/* Allocate the stack for the Slow_Thread. */
	tx_byte_allocate(&my_byte_pool, (VOID **) &pool_pointer,
		DEMO_STACK_SIZE, TX_NO_WAIT);

	/* Create the Slow_Thread. */
	tx_thread_create(&Slow_Thread, "Slow_Thread",
		Slow_Thread_entry, 1, pool_pointer,
		DEMO_STACK_SIZE, 15, 15,
		TX_NO_TIME_SLICE, TX_AUTO_START);

	/* Create the mutex used by both threads */
	tx_mutex_create(&my_mutex, "my_mutex", TX_NO_INHERIT);


}
Example #6
0
wwd_result_t host_rtos_create_thread_with_arg( /*@out@*/ host_thread_type_t* thread, void(*entry_function)( uint32_t ), const char* name, /*@null@*/ void* stack, uint32_t stack_size, uint32_t priority, uint32_t arg )
{
    UINT status;
    if ( stack == NULL )
    {
        wiced_assert("host_rtos_create_thread: stack is null\n", 0 != 0 );
        return WWD_THREAD_STACK_NULL;
    }

#ifdef DEBUG
    tx_thread_stack_error_notify( wiced_threadx_stack_error_handler );
#endif /* ifdef DEBUG */

    status = tx_thread_create( thread, (char*) name, (void(*)( ULONG )) entry_function, arg, stack, (ULONG) stack_size, (UINT) priority, 0, TX_NO_TIME_SLICE, (UINT) TX_AUTO_START );
    return ( status == TX_SUCCESS ) ? WWD_SUCCESS : WWD_THREAD_CREATE_FAILED;
}
Example #7
0
/* initialization */
unsigned int embsys_sms_slave_init()
{
    TX_STATUS status;
    status = tx_event_flags_create(&gUartSendEventFlags,"Uart send Event Flags");
    if(status != TX_SUCCESS)
        return status;
    status = tx_thread_create(&gUartSendThread, "Uart send Thread", UartSendThreadMainFunc,
                              0, gUartSendThreadStack, UART_SEND_THREAD_STACK_SIZE, UART_SEND_PRIORITY,
                              UART_SEND_PRIORITY, TX_NO_TIME_SLICE, TX_AUTO_START);
    if(status != TX_SUCCESS)
        return status;

    embsys_uart_init(&uart_interrupt);
    embsys_uart_queue_init(&requestBuffer);
    embsys_uart_queue_init(&replyBuffer);
    return 0;
}
Example #8
0
File: demo.c Project: igou/tx
void    tx_application_define(void *first_unused_memory)
{

CHAR    *pointer;


    /* Create a byte memory pool from which to allocate the thread stacks.  */
    tx_byte_pool_create(&byte_pool_0, "byte pool 0", first_unused_memory, DEMO_BYTE_POOL_SIZE);

    /* Put system definition stuff in here, e.g. thread creates and other assorted
       create information.  */

    /* Allocate the stack for thread 0.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create the main thread.  */
    tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);


    /* Allocate the stack for thread 1.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 1 and 2. These threads pass information through a ThreadX 
       message queue.  It is also interesting to note that these threads have a time
       slice.  */
    tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 2.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 3.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 3 and 4.  These threads compete for a ThreadX counting semaphore.  
       An interesting thing here is that both threads share the same instruction area.  */
    tx_thread_create(&thread_3, "thread 3", thread_3_and_4_entry, 3,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 4.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_4, "thread 4", thread_3_and_4_entry, 4,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 5.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create thread 5.  This thread simply pends on an event flag which will be set
       by thread_0.  */
    tx_thread_create(&thread_5, "thread 5", thread_5_entry, 5,  
            pointer, DEMO_STACK_SIZE, 
            4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 6.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 6 and 7.  These threads compete for a ThreadX mutex.  */
    tx_thread_create(&thread_6, "thread 6", thread_6_and_7_entry, 6,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 7.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_7, "thread 7", thread_6_and_7_entry, 7,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the message queue.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_QUEUE_SIZE*sizeof(ULONG), TX_NO_WAIT);

    /* Create the message queue shared by threads 1 and 2.  */
    tx_queue_create(&queue_0, "queue 0", TX_1_ULONG, pointer, DEMO_QUEUE_SIZE*sizeof(ULONG));

    /* Create the semaphore used by threads 3 and 4.  */
    tx_semaphore_create(&semaphore_0, "semaphore 0", 1);

    /* Create the event flags group used by threads 1 and 5.  */
    tx_event_flags_create(&event_flags_0, "event flags 0");

    /* Create the mutex used by thread 6 and 7 without priority inheritance.  */
    tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);

    /* Allocate the memory for a small block pool.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_BLOCK_POOL_SIZE, TX_NO_WAIT);

    /* Create a block memory pool to allocate a message buffer from.  */
    tx_block_pool_create(&block_pool_0, "block pool 0", sizeof(ULONG), pointer, DEMO_BLOCK_POOL_SIZE);

    /* Allocate a block and release the block memory.  */
    tx_block_allocate(&block_pool_0, (VOID **) &pointer, TX_NO_WAIT);

    /* Release the block back to the pool.  */
    tx_block_release(pointer);
}