AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/samples/demo_bsd_udp.c
void    tx_application_define(void *first_unused_memory)
{

CHAR    *pointer;
UINT    status;

    
    /* Setup the working pointer.  */
    pointer =  (CHAR *) first_unused_memory;

    /* Create a thread for the Server  */
    tx_thread_create(&thread_server, "Server", thread_server_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    pointer =  pointer + DEMO_STACK_SIZE;

    /* Create a thread for client.  */
    tx_thread_create(&thread_client, "Client", thread_client_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
    
    pointer =  pointer + DEMO_STACK_SIZE;

    /* Initialize the NetX system.  */
    nx_system_initialize();

    /* Create a BSD packet pool.  */
    status =  nx_packet_pool_create(&bsd_pool, "NetX BSD Packet Pool", 128, pointer, 16384);
    
    pointer = pointer + 16384;   
    if (status)
    {
        error_counter++;
        printf("Error in creating BSD packet pool\n!");
    }
      
    /* Create an IP instance for BSD.  */
    status += nx_ip_create(&bsd_ip, "NetX IP Instance 2", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL,  
                           &bsd_pool, _nx_ram_network_driver,
                           pointer, DEMO_STACK_SIZE, 1);
    
    pointer =  pointer + DEMO_STACK_SIZE;

    /* Check for any errors */
    if (status)
        error_counter++;
    
    if (status)
        printf("Error creating BSD IP instance\n!");
    
    /* Enable ARP and supply ARP cache memory for BSD IP Instance */
    status +=  nx_arp_enable(&bsd_ip, (void *) pointer, 1024);
    
    pointer = pointer + 1024; 

    /* Check ARP enable status.  */     
    if (status)
        error_counter++;

    if (status)
        printf("Error in Enable ARP and supply ARP cache memory to BSD IP instance\n");

    /* Enable UDP traffic.  */
    status =  nx_udp_enable(&bsd_ip);

    /* Check for UDP enable errors.  */
    if (status)
        error_counter++;

    /* Now initialize BSD Socket Wrapper */
    status = (UINT)bsd_initialize (&bsd_ip, &bsd_pool, pointer, 2048, 2);

    if (status)
        error_counter++;

}
/* Define what the initial system looks like.  */
Define what the initial system looks like.
Define what the initial system looks like .
void    tx_application_define(void *first_unused_memory)
{
CHAR    *pointer;
UINT    status;
    pointer =  (CHAR *) first_unused_memory;
    tx_thread_create(&thread_server, "Server", thread_server_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;
    tx_thread_create(&thread_client, "Client", thread_client_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
    pointer =  pointer + DEMO_STACK_SIZE;
    nx_system_initialize();
    status =  nx_packet_pool_create(&bsd_pool, "NetX BSD Packet Pool", 128, pointer, 16384);
    pointer = pointer + 16384;   
    if (status)
    {
        error_counter++;
        printf("Error in creating BSD packet pool\n!");
    }
    status += nx_ip_create(&bsd_ip, "NetX IP Instance 2", IP_ADDRESS(1, 2, 3, 4), 0xFFFFFF00UL,  
                           &bsd_pool, _nx_ram_network_driver,
                           pointer, DEMO_STACK_SIZE, 1);
    pointer =  pointer + DEMO_STACK_SIZE;
    if (status)
        error_counter++;
    if (status)
        printf("Error creating BSD IP instance\n!");
    status +=  nx_arp_enable(&bsd_ip, (void *) pointer, 1024);
    pointer = pointer + 1024; 
    if (status)
        error_counter++;
    if (status)
        printf("Error in Enable ARP and supply ARP cache memory to BSD IP instance\n");
    status =  nx_udp_enable(&bsd_ip);
    if (status)
        error_counter++;
    status = (UINT)bsd_initialize (&bsd_ip, &bsd_pool, pointer, 2048, 2);
    if (status)
        error_counter++;
}
void tx_application_define ( void * first_unused_memory ) { CHAR * pointer ; UINT status ; pointer = ( CHAR * ) first_unused_memory ; tx_thread_create ( & thread_server , " " , thread_server_entry , 0 , pointer , DEMO_STACK_SIZE , 8 , 8 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; tx_thread_create ( & thread_client , " " , thread_client_entry , 0 , pointer , DEMO_STACK_SIZE , 16 , 16 , TX_NO_TIME_SLICE , TX_AUTO_START ) ; pointer = pointer + DEMO_STACK_SIZE ; nx_system_initialize ( ) ; status = nx_packet_pool_create ( & bsd_pool , " " , 128 , pointer , 16384 ) ; pointer = pointer + 16384 ; if ( status ) { error_counter ++ ; printf ( " \n " ) ; } status += nx_ip_create ( & bsd_ip , " " , IP_ADDRESS ( 1 , 2 , 3 , 4 ) , 0xFFFFFF00UL , & bsd_pool , _nx_ram_network_driver , pointer , DEMO_STACK_SIZE , 1 ) ; pointer = pointer + DEMO_STACK_SIZE ; if ( status ) error_counter ++ ; if ( status ) printf ( " \n " ) ; status += nx_arp_enable ( & bsd_ip , ( void * ) pointer , 1024 ) ; pointer = pointer + 1024 ; if ( status ) error_counter ++ ; if ( status ) printf ( " \n " ) ; status = nx_udp_enable ( & bsd_ip ) ; if ( status ) error_counter ++ ; status = ( UINT ) bsd_initialize ( & bsd_ip , & bsd_pool , pointer , 2048 , 2 ) ; if ( status ) error_counter ++ ; }
Define what the initial system looks like.
Define what the initial system looks like .
/* Setup the working pointer.  */ /* Create a thread for the Server  */ /* Create a thread for client.  */ /* Initialize the NetX system.  */ /* Create a BSD packet pool.  */ /* Create an IP instance for BSD.  */ /* Check for any errors */ /* Enable ARP and supply ARP cache memory for BSD IP Instance */ /* Check ARP enable status.  */ /* Enable UDP traffic.  */ /* Check for UDP enable errors.  */ /* Now initialize BSD Socket Wrapper */