示例#1
0
文件: main.c 项目: bisle/34_GW_G100
void  main_init( void )
{
  int   sts;
  
  sts = get_reset_reason();
  main_status = MAIN_STS_NO_SNS_ERR;
  main_is_enter_stby_mode = 0;
  
  bio_init();
  clk_init();
  uart_init();
  dbg_wait();
  
#ifdef FEATURE_WDOG_TRIG
  IWDG_Enable();
  bio_led_ctrl( BIO_LED_IX_POWER, 0, 0, 0 );
#else // FEATURE_WDOG_TRIG
  dbg_out( "\r\n**********==> Watchdog Disabled!!!!!\r\n" );
  bio_led_ctrl( BIO_LED_IX_POWER, 500, 500, BIO_LED_ALWAYS_WINK );
#endif  // FEATURE_WDOG_TRIG
  
  dbg_out_pool_const( UART_DBG_MSG_ENTER3 );
  dbg_out( "================== 0x%02X =================\r\n", sts );
  dbg_out( "==== Welcome to %s  Ver %d.%02X ====\r\n",
           MAIN_TIT_STR, MAIN_VER_MAJ, MAIN_VER_MIN );
  dbg_out( "=====   i=%d, si=%d, li=%d, f=%d, d=%d   =====\r\n",
           sizeof( int ), sizeof( short int ),
           sizeof( long  int ),sizeof( float ),sizeof( double ) );
  dbg_out( "=====  %dMHz %s  %s  =====\r\n",
           SystemCoreClock / 1000000, __DATE__, __TIME__ );
  dbg_out_pool_const( UART_DBG_MSG_EQ_LINE );
  dbg_wait();
  
  view_reset_reason( sts );
  eep_param_init();
  IWDG_ReloadCounter();
  
  u3_ctrl.sw_baud = 115200;
  uart3_init();
  sns_init();
  adc_init();
  zb_init();
  encb_init();
  fnd_init();
  indc_init();
  
  bio_set_fan_pwm_base_freq( eep_hw_info.fan_base_f );
  cmd_rx_ptr = u1_ctrl.rx_bptr;
  
  // set monitor timer
  clk_set_timer( &monit_timer, MAIN_MONITOR_MS, MAIN_MONITOR_MS,
                 CLK_SIGS_MONITOR );
  
} // end of main_init()
示例#2
0
/// Called by the application to shutdown the scheduler and network. May be
/// called from any lightweight HPX thread, or the network thread.
void hpx_abort(void) {
  inst_fini();

  if (here && here->config && here->config->dbg_waitonabort) {
    dbg_wait();
  }
  if (here && here->boot) {
    assert(here->boot);
    boot_abort(here->boot);
  }
  abort();
}
示例#3
0
文件: main.c 项目: bisle/34_GW_G100
void  view_reset_reason( int reason )
{
#if ( FEATURE_USE_DEBUG != FEATURE_USE_DEBUG_NONE )
  int   ix = 1;
  
  dbg_wait();
  dbg_out( "Reset reason ::\r\n" );
  
  if( (reason & MAIN_RST_FOR_PIN) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_PIN\r\n", ix++ );
  }
  if( (reason & MAIN_RST_FOR_POR) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_POR\r\n", ix++ );
  }
  if( (reason & MAIN_RST_FOR_SFT) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_SFT\r\n", ix++ );
  }
  if( (reason & MAIN_RST_FOR_IWD) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_IWD\r\n", ix++ );
  }
  if( (reason & MAIN_RST_FOR_WWD) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_WWD\r\n", ix++ );
  }
  if( (reason & MAIN_RST_FOR_LPR) != 0 )
  {
    dbg_out( "  %d. MAIN_RST_FOR_LPR\r\n", ix++ );
  }
  
  dbg_out( "\r\n" );
  dbg_wait();
#endif  // ( FEATURE_USE_DEBUG != FEATURE_USE_DEBUG_NONE )
  
} // end of view_reset_reason()
示例#4
0
文件: main.c 项目: bisle/34_GW_G100
void  proc_user_cmd( void )
{
  uint32    val;
  int       ix;
  char     *ptr;
  
  if( (ix = DBG_RECV( cmd_rx_ptr, U1_RX_BUFF_SIZE )) > 1 )
  {
    cmd_rx_ptr[ix] = '\0';
    dbg_out( "\r\n" );
    
    ptr = strtok( (char *)cmd_rx_ptr, separator );
    util_cvt_low_format_cmd( ptr );
    
    if( util_cmp_str2nd( ptr, "get" ) == 0 )
    {
      proc_user_cmd_get();
    }
    else if( util_cmp_str2nd( ptr, "set" ) == 0 )
    {
      proc_user_cmd_set();
    }
    else
    {
      dbg_wait();
      dbg_out( "  get ver[version]\r\n" );
      dbg_out( "  get wifi dhcp\r\n" );
      dbg_out( "  get wifi sip[srv_ip]\r\n" );
      dbg_out( "  get wifi auth\r\n" );
      dbg_out( "  get wifi port\r\n" );
      dbg_out( "  get wifi ssid\r\n" );
      dbg_out( "  get wifi sspw\r\n" );
      dbg_wait();
      dbg_out( "  get time\r\n" );
      dbg_out( "  get date\r\n" );
      dbg_out( "  get fan[temp]\r\n" );
      dbg_out( "  get batt\r\n" );
      dbg_out( "  get gw[gateway]\r\n" );
      dbg_out( "  get sns[sensor]\r\n" );
      dbg_out( "  get log\r\n" );
      
      dbg_wait();
      dbg_out( "\r\n" );
      dbg_out( "  set wifi bypass\r\n" );
      val = eep_wifi_info.ip_srv;
      dbg_out( "  set wifi sip[srv_ip] %d.%d.%d.%d\r\n",
                (byte)(val >> 24), (byte)(val >> 16),
                (byte)(val >>  8), (byte)(val >>  0) );
      dbg_out( "  set wifi auth %d\r\n", eep_wifi_info.auth );
      dbg_out( "  set wifi ssid %s\r\n", eep_wifi_info.ssid );
      dbg_out( "  set wifi sspw %s\r\n", eep_wifi_info.sspw );
      dbg_out( "  set eep init\r\n" );
      dbg_out( "  set eep write[save]\r\n" );
      dbg_out( "  set zb isp\r\n" );
      dbg_out( "  set zb reset[rst]\r\n" );
      dbg_wait();
      dbg_out( "  set gw[gateway] fac 20\r\n" );
      dbg_out( "  set gw[gateway] num YYMMFT\r\n" );
      dbg_out( "      YY:Year, MM:Month, F:Factory, T:Type\r\n" );
      dbg_out( "    F=10:KIST, 20:NineOne, 30:Cesco, 40:Viliv\r\n" );
      dbg_out( "    T=00:CDMA,    01:WiFi,  02:ZigBee\r\n" );
      dbg_out( "  set gw sns_time %d\r\n", eep_hw_info.sns_rd_ms );
      dbg_out( "  set date %d %d %d\r\n",
                clk_rtc.year, clk_rtc.mon, clk_rtc.day );
      dbg_out( "  set time %d %d %d\r\n",
                clk_rtc.h, clk_rtc.m, clk_rtc.s );
      dbg_out( "  set fan %d %d[0~1000]\r\n",
               eep_hw_info.fan1_min, eep_hw_info.fan2_min );
      dbg_out( "  set fan freq %d[1~72000]\r\n", eep_hw_info.fan_base_f );
      dbg_wait();
      dbg_out( "  set log only\r\n" );
      dbg_out( "  set log clr[rst]\r\n" );
      dbg_out( "  set log kist\r\n" );
      
      dbg_wait();
      dbg_out( "\r\n" );
      dbg_out( "  set wifi ssid %s\r\n", eep_wifi_info.ssid );
      dbg_out( "  set wifi sspw %s\r\n", eep_wifi_info.sspw );
      dbg_out( "  set wifi auth %d\r\n", eep_wifi_info.auth );
      dbg_out( "           auth [WEB=1][WPA=2]\r\n" );
      dbg_out( "  set wifi port %d\r\n", eep_wifi_info.port_srv );
      dbg_out( "  set eep write\r\n" );
      dbg_out( "  Power OFF --> ON\r\n" );
      dbg_wait();
    }
  }
示例#5
0
int hpx_init(int *argc, char ***argv) {
  int status = HPX_SUCCESS;

  // Start the internal clock
  libhpx_time_start();

  here = malloc(sizeof(*here));
  if (!here) {
    status = log_error("failed to allocate a locality.\n");
    goto unwind0;
  }

  here->rank = -1;
  here->ranks = 0;
  here->epoch = 0;

  sigset_t set;
  sigemptyset(&set);
  dbg_check(pthread_sigmask(SIG_BLOCK, &set, &here->mask));

  here->config = config_new(argc, argv);
  if (!here->config) {
    status = log_error("failed to create a configuration.\n");
    goto unwind1;
  }

  // check to see if everyone is waiting
  if (config_dbg_waitat_isset(here->config, HPX_LOCALITY_ALL)) {
    dbg_wait();
  }

  // bootstrap
  here->boot = boot_new(here->config->boot);
  if (!here->boot) {
    status = log_error("failed to bootstrap.\n");
    goto unwind1;
  }
  here->rank = boot_rank(here->boot);
  here->ranks = boot_n_ranks(here->boot);

  // initialize the debugging system
  // @todo We would like to do this earlier but MPI_init() for the bootstrap
  //       network overwrites our segv handler.
  if (LIBHPX_OK != dbg_init(here->config)) {
    goto unwind1;
  }

  // Now that we know our rank, we can be more specific about waiting.
  if (config_dbg_waitat_isset(here->config, here->rank)) {
    // Don't wait twice.
    if (!config_dbg_waitat_isset(here->config, HPX_LOCALITY_ALL)) {
      dbg_wait();
    }
  }

  // see if we're supposed to output the configuration, only do this at rank 0
  if (config_log_level_isset(here->config, HPX_LOG_CONFIG)) {
    if (here->rank == 0) {
      config_print(here->config, stdout);
    }
  }

  // topology discovery and initialization
  here->topology = topology_new(here->config);
  if (!here->topology) {
    status = log_error("failed to discover topology.\n");
    goto unwind1;
  }

  // Initialize our instrumentation.
  if (inst_init(here->config)) {
    log_dflt("error detected while initializing instrumentation\n");
  }

  // Allocate the global heap.
  here->gas = gas_new(here->config, here->boot);
  if (!here->gas) {
    status = log_error("failed to create the global address space.\n");
    goto unwind1;
  }
  HPX_HERE = HPX_THERE(here->rank);

  here->percolation = percolation_new();
  if (!here->percolation) {
    status = log_error("failed to activate percolation.\n");
    goto unwind1;
  }

  int cores = system_get_available_cores();
  dbg_assert(cores > 0);

  if (!here->config->threads) {
    here->config->threads = cores;
  }
  log_dflt("HPX running %d worker threads on %d cores\n", here->config->threads,
           cores);

  here->net = network_new(here->config, here->boot, here->gas);
  if (!here->net) {
    status = log_error("failed to create network.\n");
    goto unwind1;
  }

  // thread scheduler
  here->sched = scheduler_new(here->config);
  if (!here->sched) {
    status = log_error("failed to create scheduler.\n");
    goto unwind1;
  }

#ifdef HAVE_APEX
  // initialize APEX, give this main thread a name
  apex_init("HPX WORKER THREAD");
  apex_set_node_id(here->rank);
#endif

  action_registration_finalize();
  inst_start();

  // start the scheduler, this will return after scheduler_shutdown()
  if (scheduler_startup(here->sched, here->config) != LIBHPX_OK) {
    log_error("scheduler shut down with error.\n");
    goto unwind1;
  }

  if ((here->ranks > 1 && here->config->gas != HPX_GAS_AGAS) ||
      !here->config->opt_smp) {
    status = hpx_run(&_hpx_143_fix);
  }

  return status;
 unwind1:
  _stop(here);
  _cleanup(here);
 unwind0:
  return status;
}