void UserMain(void * pd) { // Stock initialization code InitializeStack(); if (EthernetIP == 0) GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); Pins[16].function(PIN_16_GPIO); // Set module Pin 16 to GPIO while (1) { // Main Loop Pins[16] = 1; // Toggle Pin 16 HIGH OSTimeDly(TICKS_PER_SECOND); // Wait 1 second Pins[16] = 0; // Toggle Pin 16 LOW OSTimeDly(TICKS_PER_SECOND); // Wait 1 second } }
void UserMain(void * pd) { int x; DWORD flag = 0; int cnt; InitializeStack(); GetDHCPAddressIfNecessary(); if (EthernetIP == 0) GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); #ifdef _DEBUG /* InitializeNetworkGDB_and_Wait(); */ InitializeNetworkGDB(); #endif /* note, this may not work in all cases. 1) all systems might boot at the same time 2) when they get to this point, they may not have an ip yet */ /* init our acn stack */ acn_port_protect_startup(); #if CONFIG_NSK srand(GetPreciseTime() + netx_getmyip(0)); netx_init(); netx_startup(); #endif #if CONFIG_SLP slp_init(); slp_open(); slp_active_discovery_start(); #endif #if CONFIG_RLP rlp_init(); #if CONFIG_SDT sdt_init(); /* indirectly calls sdtm_init(), rlp_init(), rlpm_init() */ sdt_startup(true); #endif #if CONFIG_DMP /* dmp_startup(); */ #endif #endif /* RLP */ CreateTasks(); x = OSChangePrio( DEBUG_TERM_PRIORITY ); if (x) { PRINTF("%s","OUCH\n"); } PRINTF("%s","Hello ACN World\n"); ioctl( 0, IOCTL_CLR | IOCTL_RX_ECHO ); /* turn sdtin echo off */ process_keys(); /* shut things down - these require the threads to continue run... */ #if CONFIG_SDT sdt_shutdown(); #endif #if CONFIG_SLP slp_close(); #endif #if CONFIG_DMP /* dmp_shutdown() */ #endif /* shut down receive thread */ OSFlagClear(&recv_flag, 1); PRINTF("%s","Waiting for task to recv to shut down.."); cnt = 0; flag = 0; while (!flag) { cnt++; if (cnt == 80) { cnt = 0; PRINTF("%s","\n"); } PRINTF("%s","."); flag = OSFlagState(&recv_flag); } /* shut down tick thread */ OSFlagClear(&tick_flag, 1); PRINTF("%s","Waiting for task to tick to shut down.."); cnt = 0; flag = 0; while (!flag) { cnt++; if (cnt == 80) { cnt = 0; PRINTF("%s","\n"); } PRINTF("%s","."); flag = OSFlagState(&tick_flag); } #if CONFIG_NSK netx_shutdown(); #endif acn_port_protect_shutdown(); slp_stats(); sdt_stats(); PRINTF("%s","========================\n"); PRINTF("%s","\nDone....\n"); while (1) { OSTimeDly(20); } }