コード例 #1
0
ファイル: user_main.c プロジェクト: andresvidal/esp-ginx
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{   
    
    system_update_cpu_freq(160); //overclock :)

    uart_init(BIT_RATE_115200,BIT_RATE_115200);

    NODE_DBG("User Init");

    uint32_t size = flash_get_size_byte();
    NODE_DBG("Flash size %d",size);
   
    config_wifi();
    
	relay_init();   
    
    init_dns();
    init_http_server();

    //uncomment to send data to mqtt broker
    //mqtt_app_init();    

    //uncomment if you have sensors intalled
    //sensors_init();

    #ifdef DEVELOP_VERSION

    //arm timer
    os_memset(&heapTimer,0,sizeof(os_timer_t));
    os_timer_disarm(&heapTimer);
    os_timer_setfn(&heapTimer, (os_timer_func_t *)heapTimerCb, NULL);
    os_timer_arm(&heapTimer, 5000, 1);

    #endif
}
コード例 #2
0
ファイル: user_main.c プロジェクト: kirikiwi/smart.js
/* Init function */
void user_init() {
#ifndef RTOS_TODO
  system_update_cpu_freq(SYS_CPU_160MHZ);
  system_init_done_cb(sdk_init_done_cb);
#endif

  uart_div_modify(0, UART_CLK_FREQ / 115200);

#ifndef RTOS_TODO
  system_set_os_print(0);
#endif

  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);

  esp_exception_handler_init();

#ifndef RTOS_TODO
  gpio_init();
#endif

#ifdef RTOS_TODO
  rtos_init_dispatcher();
  sdk_init_done_cb();
#endif
}
コード例 #3
0
ファイル: user_main.c プロジェクト: a-kazantsev/smart.js
/* Init function */
void user_init() {
  system_update_cpu_freq(SYS_CPU_160MHZ);
  system_init_done_cb(sdk_init_done_cb);

  uart_div_modify(ESP_DEBUG_UART, UART_CLK_FREQ / 115200);

  esp_exception_handler_init();

  gpio_init();
}
コード例 #4
0
void ICACHE_FLASH_ATTR user_init(void)
{
    system_update_cpu_freq(160);
    
    i2c_init();
    display_init(0x3c);

    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
    system_os_post(user_procTaskPrio, 0, 0);
}
コード例 #5
0
ファイル: user_main.c プロジェクト: appDen4ik/ESP8266
//Init function 
void ICACHE_FLASH_ATTR
user_init() {
	uint8 data[] = "Hello World";
	uint8 hello[0x1000] = "1111111111";
	uint32_t i;
  extern void ets_wdt_disable(void);


  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  uart_tx_one_char(system_update_cpu_freq(SYS_CPU_160MHZ));
  os_install_putc1(uart_tx_one_char);
  spi_flash_erase_sector(0x12);
/*  if ( spi_flash_write( 0x12000, (uint32 *)data, 10 ) != 0 ){

	  ets_uart_printf("Error");

  } else {
	  ets_uart_printf("Write done");
	  if ( spi_flash_read( 0x12000, (uint32 *)hello, 10 ) != 0 ){

	 	  ets_uart_printf("Error");

	   } else {
		   ets_uart_printf("Read done");
	  uart_tx_one_char(hello[0]);
	  uart_tx_one_char(hello[1]);
	  uart_tx_one_char(hello[2]);
	  uart_tx_one_char(hello[3]);
	  uart_tx_one_char(hello[4]);
	  uart_tx_one_char(hello[5]);
	  uart_tx_one_char(hello[6]);
	  uart_tx_one_char(hello[7]);
	  uart_tx_one_char(hello[8]);
	  uart_tx_one_char(hello[9]);
	  ets_uart_printf("done");
	   }

  }

  */

  spi_flash_write( 0x12000 + 501, (uint32 *)data, 5 );
  spi_flash_read( 0x12000 , (uint32 *)hello, 0x1000 );
  for (  i = 0; i < 0x1000; i++ ){
	  uart_tx_one_char(hello[i]);
  }
/*  spi_flash_read( 0x13000, (uint32 *)hello, 0x1000 );
  for (  i = 0; i < 0x1000; i++ ){
	  uart_tx_one_char(hello[i]);
  }*/
}
コード例 #6
0
ファイル: jswrap_esp8266.c プロジェクト: RobinLin/Espruino
/*JSON{
  "type"     : "staticmethod",
  "class"    : "ESP8266WiFi",
  "name"     : "updateCPUFreq",
  "generate" : "jswrap_ESP8266WiFi_updateCPUFreq",
  "params"   : [
    ["freq", "JsVar", "Desired frequency - either 80 or 160."]
  ]
}
 * Update the operating frequency of the ESP8266 processor.
 */
void jswrap_ESP8266WiFi_updateCPUFreq(
    JsVar *jsFreq //!< Operating frequency of the processor.  Either 80 or 160.
  ) {
  if (!jsvIsInt(jsFreq)) {
    jsExceptionHere(JSET_ERROR, "Invalid frequency.");
    return;
  }
  int newFreq = jsvGetInteger(jsFreq);
  if (newFreq != 80 && newFreq != 160) {
    jsExceptionHere(JSET_ERROR, "Invalid frequency value, must be 80 or 160.");
    return;
  }
  system_update_cpu_freq(newFreq);
}
コード例 #7
0
STATIC mp_obj_t machine_freq(mp_uint_t n_args, const mp_obj_t *args) {
    if (n_args == 0) {
        // get
        return mp_obj_new_int(system_get_cpu_freq() * 1000000);
    } else {
        // set
        mp_int_t freq = mp_obj_get_int(args[0]) / 1000000;
        if (freq != 80 && freq != 160) {
            nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
                    "frequency can only be either 80Mhz or 160MHz"));
        }
        system_update_cpu_freq(freq);
        return mp_const_none;
    }
}
コード例 #8
0
ファイル: startup.c プロジェクト: A-Paul/RIOT
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);
}
コード例 #9
0
void init()
{
	spiffs_mount(); // Mount file system, in order to work with files
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(false);
	Serial.commandProcessing(false);

	//SET higher CPU freq & disable wifi sleep
	system_update_cpu_freq(SYS_CPU_160MHZ);
	wifi_set_sleep_type(NONE_SLEEP_T);

	ActiveConfig = loadConfig();

	// Attach Wifi events handlers
	WifiEvents.onStationDisconnect(STADisconnect);
	WifiEvents.onStationGotIP(STAGotIP);

	startWebServer();

	counterTimer.initializeMs(1000, counter_loop).start();
}
コード例 #10
0
void ICACHE_FLASH_ATTR user_init()
{
    // init UART for debugging baud rate comes from user_config.h
    uart_div_modify(0, UART_CLK_FREQ / BAUD_RATE);
    os_printf("\r\nESP8266 OOK decoding\r\n");

    // speed boost (hopefully)
    //system_update_cpu_freq(160);
    system_update_cpu_freq(80);

    // setup loop callback in system task queue
    system_os_task(loop, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen);
    system_os_post(user_procTaskPrio, 0, 0);

    // init wifi using creds in wifi_config.h. Put your own creds in the file
    connect_wifi(WIFI_SSID, WIFI_PSK);

    // apparently an accurate system time is needed for SSL, so start up
    //   SNTP stuff.
    // SNTP is also used for timestamping emails and alarm triggeringings
    sntp_setservername(0, "time.nist.gov");
    sntp_setservername(1, "time-c.nist.gov");
    sntp_set_timezone(TIMEZONE);
    sntp_init();

    // init stuff for the ook decoder
    gpio_init();
    gpio_intr_handler_register(ook_intr_handler, (void*) &unprocessedPackets);
    init_ook_decoder();

    // webserver-related initialisation
    init_web_server();
    attach_btn_clear(clearTriggeredSensors);
    attach_btn_arm_alarm(arm_alarm);
    attach_btn_disarm_alarm(disarm_alarm);
    // update so we don't just have a blank page on startup
    updateWebpage(); 
}
コード例 #11
0
void init()
{
	//SET higher CPU freq & disable wifi sleep
	system_update_cpu_freq(SYS_CPU_160MHZ);
	wifi_set_sleep_type(NONE_SLEEP_T);

	inputchip.begin();
	outputchip.begin();

	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	WifiStation.enable(false);
	WifiAccessPoint.enable(false);

	Serial.systemDebugOutput(false); // Allow debug output to serial
	Serial.println("<-= Sming start =->");

	
	inputchip.pinMode(0xFFFF);     // Use word-write mode to set all of the pins on inputchip to be inputs
	inputchip.pullupMode(0xFFFF);  // Use word-write mode to Turn on the internal pull-up resistors.
	inputchip.inputInvert(0x0000); // Use word-write mode to invert the inputs so that logic 0 is read as HIGH
	outputchip.pinMode(0x0000);    // Use word-write mode to Set all of the pins on outputchip to be outputs
  
	procTimer.initializeMs(200, loop).start();
}
コード例 #12
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void) {
#ifdef DOUBLE_CLK_FREQ
    system_update_cpu_freq(160);
#endif


#ifdef DEV
    //system_uart_swap();
#endif

    uart_init_new(BAUD, uart_rx);

    DBG("WILOC-MASTER");

    printf("SDK version:%s\n", system_get_sdk_version());

    unsigned char mac[6];

    wifi_get_macaddr(STATION_IF, mac);
    printf("MAC-STA:");
    printmac(mac, 0);
    printf("\n");

    wifi_get_macaddr(SOFTAP_IF, mac);
    printf("MAC- AP:");
    printmac(mac, 0);
    printf("\n");

    DBG(" ---- set opmode");
    if (!wifi_set_opmode(STATIONAP_MODE)) {
        DBG(" ---- > failed to set opmode");
    }
    DBG(" ---- done");

    // wifi_softap_set_config(&softapConf);

    os_delay_us(300);

    char *ssid = SSID;
    char *password = PASSWORD;
    struct station_config stationConf;
    stationConf.bssid_set = 0;  //need not check MAC address of AP
    memcpy(&stationConf.ssid, ssid, strlen(ssid) + 1);
    memcpy(&stationConf.password, password, strlen(password) + 1);

    wifi_station_set_config(&stationConf);
    wifi_station_set_reconnect_policy(true);
    wifi_station_connect();

    DBG(" --- trying to connect to AP");

    tx_queue = xQueueCreate(1, sizeof(int));

    ringbuf_mutex = xSemaphoreCreateMutex();

    ringbuf_init(&ringbuf_m, tx_buffer_m, sizeof(tx_buffer_m));
    ringbuf_init(&ringbuf_t, tx_buffer_t, sizeof(tx_buffer_t));

    synchronize_dev_id();

    // wait until wifi is connected
    user_wifi_init(connect_to_server);

}