Example #1
0
void ICACHE_FLASH_ATTR ContinueHPATimer()
{
    TM1_EDGE_INT_ENABLE();
    ETS_FRC1_INTR_ENABLE();
	system_timer_reinit();
	hs_adc_start();
}
Example #2
0
/**
 * The main entry point in an ESP8266 application.
 * It is where the logic of ESP8266 starts.
 */
void user_init() {
  system_timer_reinit(); // use microsecond os_timer_*

  // Initialize the UART devices
  int defaultBaudRate = 9600;
#ifdef DEFAULT_CONSOLE_BAUDRATE
  defaultBaudRate = DEFAULT_CONSOLE_BAUDRATE;
#endif

  uart_init(defaultBaudRate, defaultBaudRate);

  //uart_init(BIT_RATE_9600, BIT_RATE_9600);
  os_delay_us(1000); // make sure there's a gap on uart output
  UART_SetPrintPort(1);
  system_set_os_print(1);
  os_printf("\n\n\n\n");
  os_delay_us(1000);

  // Dump the restart exception information.
  dumpRestart();
  os_printf("Heap: %d\n", system_get_free_heap_size());
  os_printf("Variables: %d @%dea = %dbytes\n", JSVAR_CACHE_SIZE, sizeof(JsVar),
      JSVAR_CACHE_SIZE * sizeof(JsVar));
  os_printf("Time sys=%u rtc=%u\n", system_get_time(), system_get_rtc_time());

  // Register the ESP8266 initialization callback.
  system_init_done_cb(initDone);

  os_timer_setfn(&mainLoopSuspendTimer, enableMainLoop, NULL);
}
Example #3
0
extern "C" void user_init(void)
{
	system_timer_reinit();
	uart_div_modify(UART_ID_0, UART_CLK_FREQ / 115200);
	cpp_core_initialize();
	spiffs_mount();
	System.initialize();

	init(); // User code init
}
Example #4
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	sys_read_cfg();
	if(!syscfg.cfg.b.debug_print_enable) system_set_os_print(0);
	uart_init();
#if USE_TMP2NET_PORT
	GPIO0_MUX = 0;
#else
	GPIO0_MUX = VAL_MUX_GPIO0_SDK_DEF;
#endif
	GPIO4_MUX = VAL_MUX_GPIO4_SDK_DEF;
	GPIO5_MUX = VAL_MUX_GPIO5_SDK_DEF;
	GPIO12_MUX = VAL_MUX_GPIO12_SDK_DEF;
	GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF;
	system_timer_reinit();
#if DEBUGSOO > 0
	os_printf("\nSimple WEB version: " WEB_SVERSION "\nOpenLoaderSDK v1.2\n");
#endif
	if(syscfg.cfg.b.pin_clear_cfg_enable) test_pin_clr_wifi_config();
	set_cpu_clk(); // select cpu frequency 80 or 160 MHz
#if DEBUGSOO > 0
	if(eraminfo.size > 0) os_printf("Found free IRAM: base: %p, size: %d bytes\n", eraminfo.base,  eraminfo.size);
	os_printf("System memory:\n");
    system_print_meminfo();
    os_printf("Start 'heap' size: %d bytes\n", system_get_free_heap_size());
#endif
#if DEBUGSOO > 0
	os_printf("Set CPU CLK: %u MHz\n", ets_get_cpu_frequency());
#endif
	Setup_WiFi();
#if USE_TMP2NET_PORT
	tpm2net_init();
#endif
#ifdef USE_NETBIOS
	if(syscfg.cfg.b.netbios_ena) netbios_init();
#endif
/* #ifdef USE_SNTP
	if(syscfg.cfg.b.sntp_ena) sntp_init();
#endif */
#ifdef UDP_TEST_PORT
	if(syscfg.udp_port) udp_test_port_init(syscfg.udp_port);
#endif
	// инициализация и запуск tcp серверa(ов)
#ifdef USE_SRV_WEB_PORT
    if(syscfg.web_port) webserver_init(syscfg.web_port);
#endif
///    if(syscfg.tcp2uart_port) tcp2uart_init(syscfg.tcp2uart_port);
#ifdef USE_MODBUS
    mdb_tcp_init(502);
#endif
#ifdef USE_WDRV
    init_wdrv();
#endif
	system_deep_sleep_set_option(0);
	system_init_done_cb(init_done_cb);
}
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	sys_read_cfg();
	if(!syscfg.cfg.b.debug_print_enable) system_set_os_print(0);
	GPIO0_MUX = VAL_MUX_GPIO0_SDK_DEF;
	GPIO4_MUX = VAL_MUX_GPIO4_SDK_DEF;
	GPIO5_MUX = VAL_MUX_GPIO5_SDK_DEF;
	GPIO12_MUX = VAL_MUX_GPIO12_SDK_DEF;
	GPIO13_MUX = VAL_MUX_GPIO13_SDK_DEF;
	GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF;
	GPIO15_MUX = VAL_MUX_GPIO15_SDK_DEF;
	// vad7
	//power_meter_init();
	//
	//uart_init(); // in tcp2uart.h
	system_timer_reinit();
#if (DEBUGSOO > 0 && defined(USE_WEB))
	os_printf("\nSimple WEB version: " WEB_SVERSION "\n");
#endif
	//if(syscfg.cfg.b.pin_clear_cfg_enable) test_pin_clr_wifi_config(); // сброс настроек, если замкнут пин RX
	set_cpu_clk(); // select cpu frequency 80 or 160 MHz
#ifdef USE_GDBSTUB
extern void gdbstub_init(void);
	gdbstub_init();
#endif
#if DEBUGSOO > 0
	if(eraminfo.size > 0) os_printf("Found free IRAM: base: %p, size: %d bytes\n", eraminfo.base,  eraminfo.size);
	os_printf("System memory:\n");
    system_print_meminfo();
    os_printf("bssi  : 0x%x ~ 0x%x, len: %d\n", &_lit4_start, &_lit4_end, (uint32)(&_lit4_end) - (uint32)(&_lit4_start));
    os_printf("free  : 0x%x ~ 0x%x, len: %d\n", (uint32)(&_lit4_end), (uint32)(eraminfo.base) + eraminfo.size, (uint32)(eraminfo.base) + eraminfo.size - (uint32)(&_lit4_end));

    os_printf("Start 'heap' size: %d bytes\n", system_get_free_heap_size());
#endif
#if DEBUGSOO > 0
	os_printf("Set CPU CLK: %u MHz\n", ets_get_cpu_frequency());
#endif
	Setup_WiFi();
    WEBFSInit(); // файловая система

	system_deep_sleep_set_option(0);
	system_init_done_cb(init_done_cb);
}
Example #6
0
void ICACHE_FLASH_ATTR StartHPATimer()
{

    RTC_REG_WRITE(FRC1_CTRL_ADDRESS,  FRC1_AUTO_RELOAD|
                  DIVDED_BY_16 | //5MHz main clock.
                  FRC1_ENABLE_TIMER |
                  TM_EDGE_INT );

    RTC_REG_WRITE(FRC1_LOAD_ADDRESS,  5000000/DFREQ);
    RTC_REG_WRITE(FRC1_COUNT_ADDRESS, 5000000/DFREQ);

    //pwm_set_freq_duty(freq, duty);
    //pwm_start();
//    RTC_REG_WRITE(FRC1_LOAD_ADDRESS, local_single[0].h_time);
    ETS_FRC_TIMER1_INTR_ATTACH(timerhandle, NULL);
    TM1_EDGE_INT_ENABLE();
    ETS_FRC1_INTR_ENABLE();
	system_timer_reinit();
	hs_adc_start();
}
Example #7
0
void IRAM user_init (void)
{
    syscalls_init ();
    thread_isr_stack_init ();

    /* set system frequency */
    system_update_cpu_freq(ESP8266_CPU_FREQUENCY);

    /* reinit system timer as microsecond timer */
    system_timer_reinit ();

    /* setup the serial communication */
    uart_div_modify(0, UART_CLK_FREQ / STDIO_UART_BAUDRATE);

    /* once the ETS initialization is done we can start with our code as callback */
    system_init_done_cb(system_init);

    /* keep wifi interface in null mode per default */
    wifi_set_opmode_current (0);
}
Example #8
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
	sys_read_cfg();
	if(!syscfg.cfg.b.debug_print_enable) system_set_os_print(0);
	uart_init();
	GPIO0_MUX = VAL_MUX_GPIO0_SDK_DEF;
	GPIO4_MUX = VAL_MUX_GPIO4_SDK_DEF;
	GPIO5_MUX = VAL_MUX_GPIO5_SDK_DEF;
	GPIO12_MUX = VAL_MUX_GPIO12_SDK_DEF;
	GPIO14_MUX = VAL_MUX_GPIO14_SDK_DEF;
	system_timer_reinit();
#if (DEBUGSOO > 0 && defined(USE_WEB))
	os_printf("\nSimple WEB version: " WEB_SVERSION "\nOpenLoaderSDK v1.2\n");
#endif
	if(syscfg.cfg.b.pin_clear_cfg_enable) test_pin_clr_wifi_config();
	set_cpu_clk(); // select cpu frequency 80 or 160 MHz
#ifdef USE_GDBSTUB
extern void gdbstub_init(void);
	gdbstub_init();
#endif
#if DEBUGSOO > 0
	if(eraminfo.size > 0) os_printf("Found free IRAM: base: %p, size: %d bytes\n", eraminfo.base,  eraminfo.size);
	os_printf("System memory:\n");
    system_print_meminfo();
    os_printf("Start 'heap' size: %d bytes\n", system_get_free_heap_size());
#endif
#if DEBUGSOO > 0
	os_printf("Set CPU CLK: %u MHz\n", ets_get_cpu_frequency());
#endif
	Setup_WiFi();
#ifdef USE_WDRV
    init_wdrv();
#endif
	Set_WiFi(&wificonfig, Cmp_WiFi_chg(&wificonfig) & (WIFI_MASK_SLEEP|WIFI_MASK_STDHCP|WIFI_MASK_APIPDHCP));
	WEBFSInit(); // файловая система
	system_deep_sleep_set_option(0);
	system_init_done_cb(init_done_cb);
}
Example #9
0
void ICACHE_FLASH_ATTR PauseHPATimer()
{
    TM1_EDGE_INT_DISABLE();
    ETS_FRC1_INTR_DISABLE();
	system_timer_reinit();
}
Example #10
0
void user_init(void) {
    system_timer_reinit();
    system_init_done_cb(init_done);
}
Example #11
0
void ICACHE_FLASH_ATTR user_init(void)
{
  // According to docs required as first step, to enable us timer
  system_timer_reinit();

  otb_util_init_logging();

  DEBUG("OTB: user_init entry");
  
  // Log some useful info
  otb_util_log_useful_info(FALSE);

  // Do some sanity checking
  otb_util_check_defs();
  
  // Initialise flash access (this makes it work if OTB_SUPER_BIG_FLASH_8266 if defined).
  otb_flash_init();
  
  // Initialize GPIO.  Must happen before we clear reset (as this uses GPIO)  
  otb_gpio_init();
  
  // Reset GPIO - pull pin 16 high
  otb_util_clear_reset();

  // Initialize wifi - mostly this just disables wifi until we're ready to turn it on!
  otb_wifi_init();

#if 0
  OTB_WIFI_STATION_CONFIG wifi_conf;
  // Some code to burn an SSID/password into the flash
  wifi_set_opmode_current(STATION_MODE);
  strcpy(wifi_conf.ssid, "some_ssid");
  strcpy(wifi_conf.password, "some_password");
  wifi_conf.bssid_set = FALSE;
  strcpy(wifi_conf.bssid, "");
  otb_wifi_set_stored_conf(&wifi_conf);
  INFO("Pausing for 20s ...");
  otb_util_delay_ms(20000);
#endif  

  // Initialize and load config
  otb_conf_init();
  otb_conf_load();
  
  otb_gpio_apply_boot_state();
  otb_led_wifi_update(OTB_LED_NEO_COLOUR_BLUE, TRUE);

#if 0  
  if (otb_gpio_get(OTB_GPIO_RESET_PIN, TRUE))
  {
#endif
    system_init_done_cb((init_done_cb_t)otb_wifi_kick_off);
#if 0
  }
  else
  {
    system_init_done_cb((init_done_cb_t)otb_gpio_reset_kick_off);
  }
#endif
  
  DEBUG("OTB: user_init exit");

  return;
}