You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/esp_driver_gpio/include/driver/gpio_etm.h
+29-11Lines changed: 29 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2
+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
@@ -13,38 +13,49 @@
13
13
extern"C" {
14
14
#endif
15
15
16
+
#defineGPIO_ETM_EVENT_EDGE_TYPES 3 /*!< GPIO ETM edge events are POS/NEG/ANY */
17
+
#defineGPIO_ETM_TASK_ACTION_TYPES 3 /*!< GPIO ETM action tasks are SET/CLEAR/TOGGLE */
18
+
16
19
/**
17
20
* @brief GPIO edges that can be used as ETM event
18
21
*/
19
22
typedefenum {
20
-
GPIO_ETM_EVENT_EDGE_POS,/*!< A rising edge on the GPIO will generate an ETM event signal */
21
-
GPIO_ETM_EVENT_EDGE_NEG, /*!< A falling edge on the GPIO will generate an ETM event signal */
22
-
GPIO_ETM_EVENT_EDGE_ANY, /*!< Any edge on the GPIO can generate an ETM event signal */
23
+
GPIO_ETM_EVENT_EDGE_POS=1, /*!< A rising edge on the GPIO will generate an ETM event signal */
24
+
GPIO_ETM_EVENT_EDGE_NEG, /*!< A falling edge on the GPIO will generate an ETM event signal */
25
+
GPIO_ETM_EVENT_EDGE_ANY, /*!< Any edge on the GPIO can generate an ETM event signal */
23
26
} gpio_etm_event_edge_t;
24
27
25
28
/**
26
29
* @brief GPIO ETM event configuration
30
+
*
31
+
* If more than one kind of ETM edge event want to be triggered on the same GPIO pin, you can configure them together.
32
+
* It helps to save GPIO ETM event channel resources for other GPIOs.
27
33
*/
28
34
typedefstruct {
29
-
gpio_etm_event_edge_tedge; /*!< Which kind of edge can trigger the ETM event module */
35
+
union {
36
+
gpio_etm_event_edge_tedge; /*!< Which kind of edge can trigger the ETM event module */
37
+
gpio_etm_event_edge_tedges[GPIO_ETM_EVENT_EDGE_TYPES]; /*!< Array of kinds of edges to trigger the ETM event module on the same GPIO */
38
+
};
30
39
} gpio_etm_event_config_t;
31
40
32
41
/**
33
42
* @brief Create an ETM event object for the GPIO peripheral
34
43
*
35
44
* @note The created ETM event object can be deleted later by calling `esp_etm_del_event`
36
45
* @note The newly created ETM event object is not bind to any GPIO, you need to call `gpio_etm_event_bind_gpio` to bind the wanted GPIO
46
+
* @note Every success call to this function will acquire a free GPIO ETM event channel
37
47
*
38
48
* @param[in] config GPIO ETM event configuration
39
49
* @param[out] ret_event Returned ETM event handle
50
+
* @param[out] ... Other returned ETM event handles if any (the order of the returned event handles is aligned with the array order in field `edges` in `gpio_etm_event_config_t`)
40
51
* @return
41
52
* - ESP_OK: Create ETM event successfully
42
53
* - ESP_ERR_INVALID_ARG: Create ETM event failed because of invalid argument
43
54
* - ESP_ERR_NO_MEM: Create ETM event failed because of out of memory
44
55
* - ESP_ERR_NOT_FOUND: Create ETM event failed because all events are used up and no more free one
45
56
* - ESP_FAIL: Create ETM event failed because of other reasons
@@ -65,16 +76,21 @@ esp_err_t gpio_etm_event_bind_gpio(esp_etm_event_handle_t event, int gpio_num);
65
76
* @brief GPIO actions that can be taken by the ETM task
66
77
*/
67
78
typedefenum {
68
-
GPIO_ETM_TASK_ACTION_SET,/*!< Set the GPIO level to high */
69
-
GPIO_ETM_TASK_ACTION_CLR, /*!< Clear the GPIO level to low */
70
-
GPIO_ETM_TASK_ACTION_TOG, /*!< Toggle the GPIO level */
79
+
GPIO_ETM_TASK_ACTION_SET=1, /*!< Set the GPIO level to high */
80
+
GPIO_ETM_TASK_ACTION_CLR, /*!< Clear the GPIO level to low */
81
+
GPIO_ETM_TASK_ACTION_TOG, /*!< Toggle the GPIO level */
71
82
} gpio_etm_task_action_t;
72
83
73
84
/**
74
85
* @brief GPIO ETM task configuration
86
+
*
87
+
* If multiple actions wants to be added to the same GPIO pin, you have to configure all the GPIO ETM tasks together.
75
88
*/
76
89
typedefstruct {
77
-
gpio_etm_task_action_taction; /*!< Which action to take by the ETM task module */
90
+
union {
91
+
gpio_etm_task_action_taction; /*!< Action to take by the ETM task module */
92
+
gpio_etm_task_action_tactions[GPIO_ETM_TASK_ACTION_TYPES]; /*!< Array of actions to take by the ETM task module on the same GPIO */
93
+
};
78
94
} gpio_etm_task_config_t;
79
95
80
96
/**
@@ -83,17 +99,19 @@ typedef struct {
83
99
* @note The created ETM task object can be deleted later by calling `esp_etm_del_task`
84
100
* @note The GPIO ETM task works like a container, a newly created ETM task object doesn't have GPIO members to be managed.
85
101
* You need to call `gpio_etm_task_add_gpio` to put one or more GPIOs to the container.
102
+
* @note Every success call to this function will acquire a free GPIO ETM task channel
86
103
*
87
104
* @param[in] config GPIO ETM task configuration
88
105
* @param[out] ret_task Returned ETM task handle
106
+
* @param[out] ... Other returned ETM task handles if any (the order of the returned task handles is aligned with the array order in field `actions` in `gpio_etm_task_config_t`)
89
107
* @return
90
108
* - ESP_OK: Create ETM task successfully
91
109
* - ESP_ERR_INVALID_ARG: Create ETM task failed because of invalid argument
92
110
* - ESP_ERR_NO_MEM: Create ETM task failed because of out of memory
93
111
* - ESP_ERR_NOT_FOUND: Create ETM task failed because all tasks are used up and no more free one
94
112
* - ESP_FAIL: Create ETM task failed because of other reasons
0 commit comments