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

UINT     status;
UCHAR    *free_memory_pointer;


    free_memory_pointer = (UCHAR *)first_unused_memory;

    /* Create client packet pool. */
    status =  nx_packet_pool_create(&client_packet_pool, "SNTP Client Packet Pool",
                                    NX_SNTP_CLIENT_PACKET_SIZE, free_memory_pointer, 
                                    NX_SNTP_CLIENT_PACKET_POOL_SIZE);

    /* Check for errors. */
    if (status != NX_SUCCESS)
    {

        return;
    }

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

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer =  free_memory_pointer + NX_SNTP_CLIENT_PACKET_POOL_SIZE;

    /* Create Client IP instances */
    status = nx_ip_create(&client_ip, "SNTP IP Instance", CLIENT_IP_ADDRESS, 
                          0xFFFFFF00UL, &client_packet_pool, _nx_ram_network_driver, 
                          free_memory_pointer, 2048, 1);
    
    /* Check for error. */
    if (status != NX_SUCCESS)
    {

        return;
    }

    free_memory_pointer =  free_memory_pointer + 2048;

#ifndef NX_DISABLE_IPV4
    /* Enable ARP and supply ARP cache memory. */
    status =  nx_arp_enable(&client_ip, (void **) free_memory_pointer, 2048);

    /* Check for error. */
    if (status != NX_SUCCESS)
    {

        return;
    }
#endif /* NX_DISABLE_IPV4  */

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer = free_memory_pointer + 2048;
    
    /* Enable UDP for client. */
    status =  nx_udp_enable(&client_ip);
    
    /* Check for error. */
    if (status != NX_SUCCESS)
    {

        return;
    }

#ifndef NX_DISABLE_IPV4
    status = nx_icmp_enable(&client_ip);

    /* Check for error. */
    if (status != NX_SUCCESS)
    {

        return;
    }
#endif /* NX_DISABLE_IPV4  */

    /* Create the client thread */
    status = tx_thread_create(&demo_client_thread, "SNTP Client Thread", demo_client_thread_entry, 
                              (ULONG)(&demo_sntp_client), free_memory_pointer, 2048, 
                              4, 4, TX_NO_TIME_SLICE, TX_DONT_START);

    /* Check for errors */
    if (status != TX_SUCCESS)
    {

        return;
    }

    /* Create the event flags. */
    status = tx_event_flags_create(&sntp_flags, "SNTP event flags");

    /* Check for errors */
    if (status != TX_SUCCESS)
    {

        return;
    }

    /* Update pointer to unallocated (free) memory. */
    free_memory_pointer = free_memory_pointer + 2048;

    /* set the SNTP network interface to the primary interface. */
    iface_index = 0;

    /* Create the SNTP Client to run in broadcast mode.. */
    status =  nx_sntp_client_create(&demo_sntp_client, &client_ip, iface_index, &client_packet_pool,  
                                    leap_second_handler, 
                                    kiss_of_death_handler, 
                                    NULL /* no random_number_generator callback */);

    /* Check for error. */
    if (status != NX_SUCCESS)
    {

        /* Bail out!*/
        return;
    }

    tx_thread_resume(&demo_client_thread);

    return;
}
/* 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)
{
UINT     status;
UCHAR    *free_memory_pointer;
    free_memory_pointer = (UCHAR *)first_unused_memory;
    status =  nx_packet_pool_create(&client_packet_pool, "SNTP Client Packet Pool",
                                    NX_SNTP_CLIENT_PACKET_SIZE, free_memory_pointer, 
                                    NX_SNTP_CLIENT_PACKET_POOL_SIZE);
    if (status != NX_SUCCESS)
    {
        return;
    }
    nx_system_initialize();
    free_memory_pointer =  free_memory_pointer + NX_SNTP_CLIENT_PACKET_POOL_SIZE;
    status = nx_ip_create(&client_ip, "SNTP IP Instance", CLIENT_IP_ADDRESS, 
                          0xFFFFFF00UL, &client_packet_pool, _nx_ram_network_driver, 
                          free_memory_pointer, 2048, 1);
    if (status != NX_SUCCESS)
    {
        return;
    }
    free_memory_pointer =  free_memory_pointer + 2048;
#ifndef NX_DISABLE_IPV4
    status =  nx_arp_enable(&client_ip, (void **) free_memory_pointer, 2048);
    if (status != NX_SUCCESS)
    {
        return;
    }
#endif 
    free_memory_pointer = free_memory_pointer + 2048;
    status =  nx_udp_enable(&client_ip);
    if (status != NX_SUCCESS)
    {
        return;
    }
#ifndef NX_DISABLE_IPV4
    status = nx_icmp_enable(&client_ip);
    if (status != NX_SUCCESS)
    {
        return;
    }
#endif 
    status = tx_thread_create(&demo_client_thread, "SNTP Client Thread", demo_client_thread_entry, 
                              (ULONG)(&demo_sntp_client), free_memory_pointer, 2048, 
                              4, 4, TX_NO_TIME_SLICE, TX_DONT_START);
    if (status != TX_SUCCESS)
    {
        return;
    }
    status = tx_event_flags_create(&sntp_flags, "SNTP event flags");
    if (status != TX_SUCCESS)
    {
        return;
    }
    free_memory_pointer = free_memory_pointer + 2048;
    iface_index = 0;
    status =  nx_sntp_client_create(&demo_sntp_client, &client_ip, iface_index, &client_packet_pool,  
                                    leap_second_handler, 
                                    kiss_of_death_handler, 
                                    NULL );
    if (status != NX_SUCCESS)
    {
        return;
    }
    tx_thread_resume(&demo_client_thread);
    return;
}
void tx_application_define ( void * first_unused_memory ) { UINT status ; UCHAR * free_memory_pointer ; free_memory_pointer = ( UCHAR * ) first_unused_memory ; status = nx_packet_pool_create ( & client_packet_pool , " " , NX_SNTP_CLIENT_PACKET_SIZE , free_memory_pointer , NX_SNTP_CLIENT_PACKET_POOL_SIZE ) ; if ( status != NX_SUCCESS ) { return ; } nx_system_initialize ( ) ; free_memory_pointer = free_memory_pointer + NX_SNTP_CLIENT_PACKET_POOL_SIZE ; status = nx_ip_create ( & client_ip , " " , CLIENT_IP_ADDRESS , 0xFFFFFF00UL , & client_packet_pool , _nx_ram_network_driver , free_memory_pointer , 2048 , 1 ) ; if ( status != NX_SUCCESS ) { return ; } free_memory_pointer = free_memory_pointer + 2048 ; #ifndef NX_DISABLE_IPV4 status = nx_arp_enable ( & client_ip , ( void * * ) free_memory_pointer , 2048 ) ; if ( status != NX_SUCCESS ) { return ; } #endif free_memory_pointer = free_memory_pointer + 2048 ; status = nx_udp_enable ( & client_ip ) ; if ( status != NX_SUCCESS ) { return ; } #ifndef NX_DISABLE_IPV4 status = nx_icmp_enable ( & client_ip ) ; if ( status != NX_SUCCESS ) { return ; } #endif status = tx_thread_create ( & demo_client_thread , " " , demo_client_thread_entry , ( ULONG ) ( & demo_sntp_client ) , free_memory_pointer , 2048 , 4 , 4 , TX_NO_TIME_SLICE , TX_DONT_START ) ; if ( status != TX_SUCCESS ) { return ; } status = tx_event_flags_create ( & sntp_flags , " " ) ; if ( status != TX_SUCCESS ) { return ; } free_memory_pointer = free_memory_pointer + 2048 ; iface_index = 0 ; status = nx_sntp_client_create ( & demo_sntp_client , & client_ip , iface_index , & client_packet_pool , leap_second_handler , kiss_of_death_handler , NULL ) ; if ( status != NX_SUCCESS ) { return ; } tx_thread_resume ( & demo_client_thread ) ; return ; }
Define what the initial system looks like.
Define what the initial system looks like .
/* Create client packet pool. */ /* Check for errors. */ /* Initialize the NetX system. */ /* Update pointer to unallocated (free) memory. */ /* Create Client IP instances */ /* Check for error. */ /* Enable ARP and supply ARP cache memory. */ /* Check for error. */ /* NX_DISABLE_IPV4  */ /* Update pointer to unallocated (free) memory. */ /* Enable UDP for client. */ /* Check for error. */ /* Check for error. */ /* NX_DISABLE_IPV4  */ /* Create the client thread */ /* Check for errors */ /* Create the event flags. */ /* Check for errors */ /* Update pointer to unallocated (free) memory. */ /* set the SNTP network interface to the primary interface. */ /* Create the SNTP Client to run in broadcast mode.. */ /* no random_number_generator callback */ /* Check for error. */ /* Bail out!*/