Skip to content

Commit 39e784d

Browse files
committed
Move C files into components/sample
1 parent 648bd32 commit 39e784d

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

testFiles/gcov/components/sample/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
idf_component_register(SRCS "some_funcs.c"
1+
idf_component_register(SRCS "gcov_example_main.c" "gcov_example_func.c" "some_funcs.c"
22
INCLUDE_DIRS ".")
33

44
set_source_files_properties(some_funcs.c
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
3+
4+
void blink_dummy_func(void)
5+
{
6+
static int i;
7+
printf("blink_dummy_func: Counter = %d\n", i++);
8+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)