Skip to content

Commit

Permalink
Migrate startup code from cpu_start into the application
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Sep 26, 2016
1 parent 3fb8cd9 commit c19a8d0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
17 changes: 0 additions & 17 deletions main/app_main.c

This file was deleted.

45 changes: 45 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"

esp_err_t event_handler(void *ctx, system_event_t *event)
{
return ESP_OK;
}

int app_main(void)
{
nvs_flash_init(6, 3);
system_init();
tcpip_adapter_init();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(esp_event_loop_get_queue() );
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
wifi_config_t sta_config = {
.sta = {
.ssid = "access_point_name",
.password = "password",
.bssid_set = false
}
};
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
ESP_ERROR_CHECK( esp_wifi_connect() );

gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
int level = 0;
while (true) {
gpio_set_level(GPIO_NUM_4, level);
level = !level;
vTaskDelay(300 / portTICK_PERIOD_MS);
}

return 0;
}

0 comments on commit c19a8d0

Please sign in to comment.