Skip to content
Snippets Groups Projects
main.cpp 1.49 KiB
Newer Older
Dorababu A's avatar
Dorababu A committed
/*
 * Observe the esp32 perfomance
 *
 * author : dorababu@subcom.tech
 *
 */

#include "driver/gpio.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "shepherd_sniff.h"
#include <stdio.h>

// define LED pins
#define BLINK_GPIO_1 GPIO_NUM_32
#define BLINK_GPIO_2 GPIO_NUM_25
#define BLINK_GPIO_3 GPIO_NUM_27
#define BLINK_GPIO_4 GPIO_NUM_12

// normal task
void blinky(void *pvParameter) {

  gpio_num_t led_pins[4] = {GPIO_NUM_32, GPIO_NUM_25, GPIO_NUM_27, GPIO_NUM_12};
  // config LED gpio pins
  for (uint8_t i = 0; i < 4; i++) {
    esp_rom_gpio_pad_select_gpio(led_pins[i]);
  }
  /* Set the GPIO as a push/pull output */
  for (uint8_t i = 0; i < 4; i++) {
    gpio_set_direction(led_pins[i], GPIO_MODE_OUTPUT);
  }
  while (1) {
    for (uint8_t i = 0; i < 4; i++) {
      /* Blink off (output low) */
      gpio_set_level(led_pins[i], 0);
      vTaskDelay(100 / portTICK_PERIOD_MS);
      /* Blink on (output high) */
      gpio_set_level(led_pins[i], 1);
    }
  }
}

void run_time_stats(void *pvParameter) {

  while (1) {
    // Runtime Stats
    printf("--------Run time stats ---------------\n");
    char pbuf[100];
    vTaskGetRunTimeStats(pbuf);
    printf("%s\r\n", pbuf);
    printf("---------------------------------------\n");
    vTaskDelay(15000 / portTICK_PERIOD_MS);
  }
}

Dorababu A's avatar
Dorababu A committed
extern "C" {
void app_main() {
  shepherd_sniff();
  xTaskCreate(&blinky, "blinky", 4098, NULL, 1, NULL);
  xTaskCreate(&run_time_stats, "run_time_stats", 2096, NULL, 2, NULL);
Dorababu A's avatar
Dorababu A committed
}
}