Beispiel #1
0
int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  
  //multiply the base quartz frequency (32768) by 100
  SCFQCTL = 100-1;
  CCTL0 = CCIE;
  TACTL = TACLR;
  TACTL = TASSEL_2 + MC_1;
  TACCR0 = 32768-1;
  
  
  int i = 0;
  // wait for xtal to stabilize
  FLL_CTL0 |= XCAP14PF;
  do
  {
    IFG1 &= ~OFIFG;
    for (i = 0x47FF; i > 0; i--);
  }
  while ((IFG1 & OFIFG));
  
  //input output configuration
  P2DIR = 0xF;
  P2OUT = 0;
  P1IES = 0;
  P1IE = 0xF;
  P1IFG = 0;
 
  //init mmodules
  em_init();
  dm_init();
  sw_reset();
  
  __enable_interrupt();	    //globaly enable interrupts
  
  _BIS_SR(LPM0_bits + GIE); //on éteint presque tout pour économiser
  
  for(;;);
}
Beispiel #2
0
PROCESS_THREAD(gatewaytest_process, ev, data)
{
	static struct etimer et;
	PROCESS_BEGIN();
	char tempstr[32];
	uint16_t tmp;
	broadcast_open(&broadcast, 129, &broadcast_call);
	printf("Initiating em4325\r\n");
	em_init();
	stcn75_init();

	while(1) {
		etimer_set(&et, CLOCK_SECOND);
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
//leds_toggle(LEDS_ALL);
		//read em mem
		//printf("read em status: %x\r\n",em_get_status());
		//printf("mem: %x ", em_read_word(0x2c));

		//write em mem
		//printf("write status: %x\r\n",em_write_word(0x2C,0xacab));

		

		//read gateway temp
		//stcn75_read(&tmp);
		//printf("onboard temp: %dC \r\n",tmp);

		//Send hello
	/*	packetbuf_copyfrom("Hello", 6);
    		broadcast_send(&broadcast);
    		printf("broadcast message sent\n\r");
	*/	
	}
	
  PROCESS_END();
}
Beispiel #3
0
// ---------------------------------------------------------------------------
/// Mandor2 core.
// ---------------------------------------------------------------------------
int
main (int argc, char **argv)
{
   time_get (&stopFlag_startTime);
   cl_import ("./source/import.pl", argc, argv, 0);

   parameter_enterMPI (argc, argv, 1);
   parameter_load ();

   // Initializes profiler.
   profiler_init (_("output/prof_core_%03d.txt", cpu_here));

   units_load ();

   // Configures all modules.
   main_startUp ();
   em_init      (&E, &H);
   plasma_init  ();

   for (int tmp = 0; tmp < 100; tmp++) tmp_gamma[tmp] = 0.0; // TEMP

   say ("System is initialized successfully.");

   // Total time of the work stage - starts here.
   int    stopFlag   = 0;
   double computTime = MPI_Wtime (),
          oldTime    = -1;
   for (int t = 1 ; t <= totalSteps && !stopFlag ; t++) {
      double W_E, W_M, WTx = 0, WTy = 0, WTz = 0;
      profiler_startLoop ();

      // XXX Add it to the timing counter.
      comm_plasma_start ();

      // Reads data from external file (works as mailbox)..
      profiler_begin (mc_prof_throwStopFlag);
      if (chPoint_stopRequest > 0 && t%chPoint_stopRequest == 0)
         main_throwStopFlag ();

      // H^(n-1/2) -> H^n.
      profiler_endBegin (mc_prof_emh1);
      em_HHalfStep (mcast_meshVec_RO (&E), &H);

      // Energy density of the field at t = n*tau.
      profiler_endBegin (mc_prof_EMenergy);
      em_energy (mcast_meshVec_RO(&E), mcast_meshVec_RO(&H), &W_E, &W_M);
      profiler_endBegin (mc_prof_probes);
      probe_postData (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H));

      // Gauss law test beginning (profiler call is inside).
      gauss_before ();

      profiler_endBegin (mc_prof_plasma_move);
      plasma_move (mcast_meshVec_RO(&E), mcast_meshVec_RO(&H), &J);

      // Energy density: gets plasma termal energy.
      profiler_endBegin (mc_prof_plasma_Txyz);
      plasma_temperature (&WTx, &WTy, &WTz);

      // Tecplot's diagnostic check-pointing.
      if (chPoint_tecplot > 0 && t%chPoint_tecplot == 0) {
         say_doing ("writing tecplot mesh...");
         profiler_endBegin (mc_prof_tecRho);
         plasma_rho (&rho);
         profiler_endBegin (mc_prof_tecEH);
         tecIO_saveFields (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H));
      }

      // Spectral energy density diagnostic.
      if (chPoint_spectr > 0 && t%chPoint_spectr == 0) {
         say_doing ("writing spectral energy density dump...");
         profiler_endBegin (mc_prof_spectr);
         reg_t reg = {{cpu_min[0], cpu_min[1], cpu_min[2]},
                      {cpu_max[0] - mc_have_x, cpu_max[1] - mc_have_y, cpu_max[2] - mc_have_z}};
         reg_t map = {{E.imin, E.jmin, E.kmin},
                      {E.imax, E.jmax, E.kmax}};
         spectr_dump (Time, cpu_here, cpu_total, &reg, &map, E.storage, H.storage);
      }

      // Saves local energies to the buffer.
      profiler_endBegin (mc_prof_wDensity);
      wDensity_addPoint (W_E, W_M, WTx, WTy, WTz);

      // H^n -> H^(n+1/2).
      profiler_endBegin (mc_prof_emh2);
      em_HStep (mcast_meshVec_RO(&E), &H);

      // E^n -> E^(n+1).
      profiler_endBegin (mc_prof_eme);
      em_EStep_start (&E, mcast_meshVec_RO(&H));

      // Gets full picture of the currents.
      profiler_endBegin (mc_prof_jbcFinish);
      jbc_finish (&J);

      profiler_endBegin (mc_prof_plasma_pbcRecv);
      comm_plasma_complete (1000);

      profiler_endBegin (mc_prof_EFinish);
      em_EStep_finish (&E, &H, mcast_meshVec_RO(&J));

      // Gauss law test ending.
      gauss_after (mcast_meshVec_RO(&J), mcast_meshVec_RO(&E));

      // Tecplot's diagnostic check-pointing.
      if (chPoint_tecplot > 0 && t%chPoint_tecplot == 0) {
         say_doing ("writing tecplot mesh...");
         profiler_endBegin (mc_prof_tecRhoJ);
         tecIO_saveCurrents (mcast_meshVec_RO(&J), mcast_meshDouble_RO(&rho));
      }

      // Updates time after successful time step.
      parameter_setTime (Time + tau);

      tmp_update_gamma(countCore, countAll); // TEMP
      tmp_update_gamma(0, countShell); // TEMP

      // System check-point.
      if (t && t%chPoint_full == 0) {
        tmp_save_gamma(sysNum, cpu_here); // TEMP

         timeTick_t startWrite;
         time_get (&startWrite);
         say_doing ("writing check-point...");

         profiler_endBegin (mc_prof_sysSave);
         plasma_save (sysNum, cpu_here);
         sysIO_save  (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H));

         profiler_endBegin (mc_prof_wDensityFlush);
         // WARNING: barrier-type calls inside.
         wDensity_flushData ();
         oldTime = Time;

         // Updates estimate of saving time.
         timeTick_t endWrite;
         time_get (&endWrite);
         stopFlag_saveTime = time_elapsed (&startWrite, &endWrite);
      }

      profiler_endBegin (mc_prof_catchStop);

      // Gets data sent earlier.
      if (chPoint_stopRequest > 0 &&  t % chPoint_stopRequest == 0) {
         stopFlag = main_catchStopFlag ();
      }
      profiler_end ();

      say_doing ("time=%.4f (%.2f %%)   ", Time, 100.0*t/(double) totalSteps);
//       say ("step %d: time=%.4f (%.2f %%)", t, Time
//                                               , 100.0*t/(double) totalSteps);
      profiler_finishLoop ();
   }
   computTime = MPI_Wtime () - computTime;
   say ("main: main loop have taken %f sec.", computTime);

   // System check-point.
   if (oldTime != Time)	{
      say ("Addional check-point to save the final state.");
      plasma_save (sysNum, cpu_here);
      sysIO_save  (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H));
   }

   say ("Final barrier.");
   MPI_Barrier (MPI_COMM_WORLD);

   // Removes tmp file to signal the end of run.
   if (!cpu_here)
      remove ("tmp/stop.flag");

   return EXIT_SUCCESS;
}