gcov_example_main.c 2.0 KB

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