Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* 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", pbuf);
printf("\n---------------------------------------\n");
vTaskDelay(15000 / portTICK_PERIOD_MS);
}
}
xTaskCreate(&blinky, "blinky", 4098, NULL, 1, NULL);
xTaskCreate(&run_time_stats, "run_time_stats", 2096, NULL, 2, NULL);