hello_world_main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: CC0-1.0
  5. */
  6. #include <stdio.h>
  7. #include "sdkconfig.h"
  8. #include "freertos/FreeRTOS.h"
  9. #include "freertos/task.h"
  10. #include "esp_chip_info.h"
  11. #include "esp_flash.h"
  12. void app_main(void)
  13. {
  14. printf("Hello world!\n");
  15. /* Print chip information */
  16. esp_chip_info_t chip_info;
  17. uint32_t flash_size;
  18. esp_chip_info(&chip_info);
  19. printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",
  20. CONFIG_IDF_TARGET,
  21. chip_info.cores,
  22. (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  23. (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
  24. printf("silicon revision %d, ", chip_info.revision);
  25. if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
  26. printf("Get flash size failed");
  27. return;
  28. }
  29. printf("%uMB %s flash\n", flash_size / (1024 * 1024),
  30. (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  31. printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
  32. for (int i = 10; i >= 0; i--) {
  33. printf("Restarting in %d seconds...\n", i);
  34. vTaskDelay(1000 / portTICK_PERIOD_MS);
  35. }
  36. printf("Restarting now.\n");
  37. fflush(stdout);
  38. esp_restart();
  39. }