SHARE
TWEET

main.c

tmax Feb 9th, 2019 (edited) 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include "freertos/FreeRTOS.h"
  3. #include "freertos/task.h"
  4. #include "freertos/timers.h"
  5. #include "esp_system.h"
  6. #include "esp_spi_flash.h"
  7. #include "driver/gpio.h"
  8. #include "esp_err.h"
  9.  
  10. #include "power_monitor/power_monitor.h"
  11. #include "esp_log.h"
  12.  
  13. static const char* TAG = "main";
  14.  
  15. void app_main()
  16. {
  17.     ESP_LOGI(TAG, "System boot!");
  18.  
  19.     // Get chip information and output it
  20.     esp_chip_info_t chip_info;
  21.     esp_chip_info(&chip_info);
  22.     ESP_LOGI(TAG, "ESP32 with %d CPU cores. Revision %d.",
  23.             chip_info.cores,
  24.             chip_info.revision);
  25.  
  26.     // Flash information
  27.     ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
  28.             (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  29.     fflush(stdout);
  30.  
  31.     esp_err_t err = ESP_OK;
  32.     ESP_LOGI(TAG, "Initializing systems");
  33.  
  34.     // Install gpio isr service
  35.     gpio_install_isr_service(ESP_INTR_FLAG_IRAM);
  36.  
  37.     // Give some time to circuits to power-up
  38.     vTaskDelay(pdMS_TO_TICKS(500));
  39.  
  40.     err = power_monitor_init();
  41.  
  42.     ESP_LOGI(TAG, "RAM left %d bytes", esp_get_free_heap_size());
  43.  
  44.     if(err == ESP_OK)
  45.     {
  46.         ESP_LOGI(TAG, "Systems ready!");
  47.     }
  48.     else
  49.     {
  50.         ESP_LOGE(TAG, "System init failed!");
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top