Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
/**
 * Internal function to initialize SoC reset reason at system initialization
 */
static void __esp_reset_reason_init(int init)
{
    const uint32_t hw_reset = esp_rtc_get_reset_reason();
#if CONFIG_RESET_REASON_CHECK_WAKEUP
    const uint32_t hw_wakeup = esp_rtc_get_wakeup_reason();
#else
    const uint32_t hw_wakeup = 0;
#endif
    const uint32_t hint = esp_reset_reason_get_hint(hw_reset);

    s_reset_reason = get_reset_reason(hw_reset, hint);
    if (init && hint != ESP_RST_UNKNOWN) {
        esp_reset_reason_clear_hint();
    }

    if (init)
        ESP_LOGI(TAG, "RTC reset %u wakeup %u store %u, reason is %u", hw_reset, hw_wakeup, hint, s_reset_reason);
}
Ejemplo n.º 3
0
static void ther_device_init(struct ther_info *ti)
{
	/*
	 * 1. gpio init
	 */
	ther_port_init();

	/*
	 * 2. uart init
	 */
	ther_uart_init(UART_PORT_0, UART_BAUD_RATE_115200, ther_at_handle);
	print(LOG_INFO, "\n");
	print(LOG_INFO, "-------------------------------------\n");
	print(LOG_INFO, "  Firmware V%d.%d\n",
			FIRMWARE_MAJOR_VERSION, FIREWARM_MINOR_VERSION);
	print(LOG_INFO, "      %s, %s\n",
			__DATE__, __TIME__);
	print(LOG_INFO, "  by <%s>\n", get_reset_reason());

	uart_delay(UART_WAIT);
	print(LOG_INFO, "\n");
	print(LOG_INFO, "  Copyright (c) 2015 [email protected]\r\n");
	print(LOG_INFO, "  All rights reserved.\r\n");
	print(LOG_INFO, "-------------------------------------\r\n");

	/*
	 * 2. buzzer init
	 */
	ther_buzzer_init(ti->task_id);

	/*
	 * 3. button init
	 */
	ther_button_init(ti->task_id);

	/*
	 * 4. oled display init
	 */
	oled_display_init(ti->task_id, ther_display_event_report);

	/*
	 * 5. mtd
	 */
	ther_mtd_init();

	/*
	 * 6. storage
	 */
	ther_storage_init();

	/*
	 * 7. temp init
	 */
	ther_temp_init();

	/* read high temp warning thershold */
	if (!storage_read_high_temp_enabled(&ti->warning_enabled)) {
		print(LOG_INFO, MODULE "read high temp enalbe failed, set enabled\n");

		ti->warning_enabled = TRUE;
		storage_write_high_temp_enabled(ti->warning_enabled);
	}
	if (!storage_read_high_temp_threshold(&ti->high_temp_threshold)) {
		ti->high_temp_threshold = DEFAULT_HIGH_TEMP_THRESHOLD;

		print(LOG_INFO, MODULE "read high temp threshold failed, set as %d\n", ti->high_temp_threshold);
		storage_write_high_temp_threshold(ti->high_temp_threshold);
	}
	ti->next_warning_threshold = ti->high_temp_threshold;

	/*
	 * 8. ble init
	 */
	ther_ble_init(ti->task_id, ther_handle_ts_event, ther_handle_ps_event, ther_handle_wechat_event);

//	HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_ENABLE_CLK_DIVIDE_ON_HALT );

	// Enable stack to toggle bypass control on TPS62730 (DC/DC converter)
//	HCI_EXT_MapPmIoPortCmd( HCI_EXT_PM_IO_PORT_NONE, HCI_EXT_PM_IO_PORT_PIN0 );

  //the TI interface to set TXPOWER is not satisfying, so I have to
  //set register TXPOWER myself.
//  HCI_EXT_SetTxPowerCmd(LL_EXT_TX_POWER_0_DBM);
}