Beispiel #1
0
void ICACHE_FLASH_ATTR as3935_init(){
	//we can only use uart for debugging no jtag in this iot devil
	//uart_div_modify(0, 115200);
	system_soft_wdt_stop();
	uart0_sendStr("as3935_init function\n");
	
	//we use i2c for communication with as3935
	//justinitialize it in read and write functions
	
	//first inicialize chip
	spi_write(0x3c,0x96);//dc	PRESET_DEFAULT
	//as3935_set_tuning_capacitor(3); //factory calibrated 3 and 12
	//as3935_set_tuning_capacitor(12);
	spi_write(0x3d,0x96);//dc CALIB_RCO
	
	as3935_TRCO_calibration();
	/*as3935_set_min_lightning_events(0);//REG0x02[5] REG0x02[4] 1(0),5(1),9(2),16(3)
	as3935_set_mask_disturbers(0);//after we are satified with operation just turn off by sending 1
	as3935_set_AFE_gainboost(INDOOR);
	as3935_set_watchdog_thresold(1);
	as3935_set_spike_rejection(2);
	as3935_set_noise_floor_level(2);*/
	as3935_set_mask_disturbers(1);
	system_soft_wdt_restart();
	
}
Beispiel #2
0
enum mgos_init_result esp_mgos_init2(void) {
#ifdef CS_MMAP
  mgos_vfs_mmap_init();
#endif
  enum mgos_init_result ir = mgos_debug_uart_init();
  if (ir != MGOS_INIT_OK) return ir;
  uart_initialized = true;
  cs_log_set_level(MGOS_EARLY_DEBUG_LEVEL);
  setvbuf(stdout, NULL, _IOLBF, 256);
  setvbuf(stderr, NULL, _IOLBF, 256);
  /* Note: putc can be invoked from int handlers. */
  os_install_putc1(sdk_putc);
  fputc('\n', stderr);

  if (strcmp(MGOS_APP, "mongoose-os") != 0) {
    LOG(LL_INFO, ("%s %s (%s)", MGOS_APP, build_version, build_id));
  }
  LOG(LL_INFO, ("Mongoose OS %s (%s)", mg_build_version, mg_build_id));
  LOG(LL_INFO, ("CPU: %s, %d MHz, RAM: %u total, %u free",
                esp_chip_type_str(esp_get_chip_type()),
                (int) (mgos_get_cpu_freq() / 1000000), mgos_get_heap_size(),
                mgos_get_free_heap_size()));
  LOG(LL_INFO, ("SDK %s; flash: %uM", system_get_sdk_version(),
                esp_vfs_dev_sysflash_get_size(NULL) / 1048576));
  esp_print_reset_info();

  system_soft_wdt_stop();
  ir = mgos_init();
  if (ir != MGOS_INIT_OK) {
    LOG(LL_ERROR, ("%s init error: %d", "MG", ir));
    return ir;
  }

  return MGOS_INIT_OK;
}
Beispiel #3
0
//returns:
// 1 for INT_NH noise level to high
// 4 for INT_D disturber detected 
// 8 for INT_L lightning detected
uint8_t ICACHE_FLASH_ATTR as3935_interrupt_source(){//get interrupt source but first wait for 2ms for chip to calculate what trigerred it
	system_soft_wdt_stop();
	HSPI_INIT_STUF;
	//this won't work
	os_delay_us(3000);
	as3935.x3.a3.INT=0;
	as3935.x3.d3=spi_read(3);
	system_soft_wdt_restart();
	return as3935.x3.a3.INT;
}
Beispiel #4
0
/*
 * Called when SDK initialization is finished
 */
void sdk_init_done_cb() {
  srand(system_get_rtc_time());

#if !defined(ESP_ENABLE_HW_WATCHDOG)
  ets_wdt_disable();
#endif
  system_soft_wdt_stop(); /* give 60 sec for initialization */

  /* Schedule SJS initialization (`sjs_init()`) */
  os_timer_disarm(&startcmd_timer);
  os_timer_setfn(&startcmd_timer, sjs_init, NULL);
  os_timer_arm(&startcmd_timer, 0, 0);
}
Beispiel #5
0
void init()
{
	//debugf("Memory info: flashID %d size: %d\n",spi_flash_get_id(),fs_size());
	
	System.setCpuFrequency(eCF_160MHz);

	Serial.systemDebugOutput(false); // Disable debug output
	Serial.print("rst_info.reason: ");
	Serial.println(system_get_rst_info()->reason);
	Serial.print("rst_info.depc ");
	Serial.println(system_get_rst_info()->depc, HEX);
	Serial.print("rst_info.epc1 ");
	Serial.println(system_get_rst_info()->epc1, HEX);
	Serial.print("rst_info.epc2 ");
	Serial.println(system_get_rst_info()->epc2, HEX);
	Serial.print("rst_info.epc3 ");
	Serial.println(system_get_rst_info()->epc3, HEX);
	Serial.print("rst_info.exccause ");
	Serial.println(system_get_rst_info()->exccause, HEX);
	Serial.print("rst_info.excvaddr ");
	Serial.println(system_get_rst_info()->excvaddr, HEX);

	//WDT.enable(false); // First (but not the best) option: fully disable watch dog timer
	system_soft_wdt_stop();

	// You can change pins:
	//Wire.pins(12, 14); // SCL, SDA
	Wire.pins(4, 5);
	Wire.begin();

	WifiStation.enable(true);
	WifiStation.config(WIFI_SSID, WIFI_PWD);
	WifiAccessPoint.enable(false);

	// Run our method when station was connected to AP
	WifiStation.waitConnection(connectOk);
}