Beispiel #1
0
void UserMain(void * pd)
{
    InitializeStack();/* Setup the TCP/IP stack buffers etc.. */

    GetDHCPAddressIfNecessary();/*Get a DHCP address if needed*/
    /*You may want to add a check for the return value from this function*/
    /*See the function definition in  \nburn\include\dhcpclient.h*/

    OSChangePrio(MAIN_PRIO);/* Change our priority from highest to something in the middle */

    EnableAutoUpdate();/* Enable the ability to update code over the network */

    iprintf("Application started\n");

    // Setup DSPI3
    Pins[36].function(PIN_36_DSPI3_PCS0);
    Pins[38].function(PIN_38_DSPI3_SCK);
    Pins[32].function(PIN_32_DSPI3_SIN);
    Pins[34].function(PIN_34_DSPI3_SOUT);
    Pins[49].function(PIN_49_GPIO);

    PoolPtr pp;
    volatile dspistruct &spi = sim1.dspi3;
    int spiCh = DMA_CH_DSPI_3_RX;
    int RemoteFD;
    Pins[49] = 0;

    getchar();
    while ((RemoteFD = connect( TARGET_ADDR, 0, 20035, TICKS_PER_SECOND*5)) < 0) {
    iprintf("Error: %d\n", RemoteFD);
    }
    iprintf("Connected: %d\n", RemoteFD);
    ConfigRX(spi, spiCh);
    iprintf("Running\n");
//    OSSimpleTaskCreate(MonTask, MAIN_PRIO+1);
    while (1) {
        pp = (PoolPtr)OSFifoPend( &dspiRXFifo, 0 );
//        iprintf("pp: %p\n", pp);
//        iprintf("sr: %08lX\n", spi.sr);
//        ShowData( pp->pData, pp->usedsize);
        writeall( RemoteFD, (char *)pp->pData, pp->usedsize );
        Pins[49] = 0;
        DestBuffers.InsertTail(pp);
//        putchar('.');
//        FreeFrameBuf( pp );

    }
}
Beispiel #2
0
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);
  }
}