hello_world_main.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <inttypes.h>
  8. #include "sdkconfig.h"
  9. #include "freertos/FreeRTOS.h"
  10. #include "freertos/task.h"
  11. #include "esp_chip_info.h"
  12. #include "esp_flash.h"
  13. #include "esp_system.h"
  14. void app_main(void)
  15. {
  16. printf("Hello world!\n");
  17. /* Print chip information */
  18. esp_chip_info_t chip_info;
  19. uint32_t flash_size;
  20. esp_chip_info(&chip_info);
  21. printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
  22. CONFIG_IDF_TARGET,
  23. chip_info.cores,
  24. (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
  25. (chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
  26. (chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
  27. (chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
  28. unsigned major_rev = chip_info.revision / 100;
  29. unsigned minor_rev = chip_info.revision % 100;
  30. printf("silicon revision v%d.%d, ", major_rev, minor_rev);
  31. if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
  32. printf("Get flash size failed");
  33. return;
  34. }
  35. printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
  36. (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  37. printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
  38. for (int i = 10; i >= 0; i--) {
  39. printf("Restarting in %d seconds...\n", i);
  40. vTaskDelay(1000 / portTICK_PERIOD_MS);
  41. }
  42. printf("Restarting now.\n");
  43. fflush(stdout);
  44. esp_restart();
  45. }