|
| 1 | +/* Blink Example with covergae info |
| 2 | +
|
| 3 | + This example code is in the Public Domain (or CC0 licensed, at your option.) |
| 4 | +
|
| 5 | + Unless required by applicable law or agreed to in writing, this |
| 6 | + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 7 | + CONDITIONS OF ANY KIND, either express or implied. |
| 8 | +*/ |
| 9 | +#include <stdio.h> |
| 10 | +#include "freertos/FreeRTOS.h" |
| 11 | +#include "freertos/task.h" |
| 12 | +#include "driver/gpio.h" |
| 13 | +#include "esp_app_trace.h" |
| 14 | +#include "sdkconfig.h" |
| 15 | + |
| 16 | +/* Can use project configuration menu (idf.py menuconfig) to choose the GPIO |
| 17 | + to blink, or you can edit the following line and set a number here. |
| 18 | +*/ |
| 19 | +#define BLINK_GPIO CONFIG_BLINK_GPIO |
| 20 | + |
| 21 | +void blink_dummy_func(void); |
| 22 | +void some_dummy_func(void); |
| 23 | + |
| 24 | +static void blink_task(void *pvParameter) |
| 25 | +{ |
| 26 | + // The first two iterations GCOV data are dumped using call to esp_gcov_dump() and OOCD's "esp32 gcov dump" command. |
| 27 | + // After that they can be dumped using OOCD's "esp32 gcov" command only. |
| 28 | + int dump_gcov_after = -2; |
| 29 | + /* Configure the IOMUX register for pad BLINK_GPIO (some pads are |
| 30 | + muxed to GPIO on reset already, but some default to other |
| 31 | + functions and need to be switched to GPIO. Consult the |
| 32 | + Technical Reference for a list of pads and their default |
| 33 | + functions.) |
| 34 | + */ |
| 35 | + gpio_reset_pin(BLINK_GPIO); |
| 36 | + /* Set the GPIO as a push/pull output */ |
| 37 | + gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT); |
| 38 | + |
| 39 | + while(1) { |
| 40 | + /* Blink off (output low) */ |
| 41 | + gpio_set_level(BLINK_GPIO, 0); |
| 42 | + vTaskDelay(500 / portTICK_PERIOD_MS); |
| 43 | + /* Blink on (output high) */ |
| 44 | + gpio_set_level(BLINK_GPIO, 1); |
| 45 | + vTaskDelay(500 / portTICK_PERIOD_MS); |
| 46 | + blink_dummy_func(); |
| 47 | + some_dummy_func(); |
| 48 | + if (dump_gcov_after++ < 0) { |
| 49 | + // Dump gcov data |
| 50 | + printf("Ready to dump GCOV data...\n"); |
| 51 | + esp_gcov_dump(); |
| 52 | + printf("GCOV data have been dumped.\n"); |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +void app_main(void) |
| 58 | +{ |
| 59 | + xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL); |
| 60 | +} |
0 commit comments