Select one of the symbols to view example projects that use it.
 
Outline
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "driver/mcpwm_types.h"
mcpwm_comparator_config_t
mcpwm_new_comparator(mcpwm_oper_handle_t, const mcpwm_comparator_config_t *, mcpwm_cmpr_handle_t *);
mcpwm_del_comparator(mcpwm_cmpr_handle_t);
mcpwm_comparator_event_callbacks_t
mcpwm_comparator_register_event_callbacks(mcpwm_cmpr_handle_t, const mcpwm_comparator_event_callbacks_t *, void *);
mcpwm_comparator_set_compare_value(mcpwm_cmpr_handle_t, uint32_t);
Files
loading (3/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_driver_mcpwm/include/driver/mcpwm_cmpr.h
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #pragma once #include <stdint.h> #include <stdbool.h> #include "esp_err.h" #include "driver/mcpwm_types.h" #ifdef __cplusplus extern "C" { #endif /** * @brief MCPWM comparator configuration *//* ... */ typedef struct { int intr_priority; /*!< MCPWM comparator interrupt priority, if set to 0, the driver will try to allocate an interrupt with a relative low priority (1,2,3) *//* ... */ struct { uint32_t update_cmp_on_tez: 1; /*!< Whether to update compare value when timer count equals to zero (tez) */ uint32_t update_cmp_on_tep: 1; /*!< Whether to update compare value when timer count equals to peak (tep) */ uint32_t update_cmp_on_sync: 1; /*!< Whether to update compare value on sync event */ }{ ... } flags; /*!< Extra configuration flags for comparator */ }{ ... } mcpwm_comparator_config_t; /** * @brief Create MCPWM comparator * * @param[in] oper MCPWM operator, allocated by `mcpwm_new_operator()`, the new comparator will be allocated from this operator * @param[in] config MCPWM comparator configuration * @param[out] ret_cmpr Returned MCPWM comparator * @return * - ESP_OK: Create MCPWM comparator successfully * - ESP_ERR_INVALID_ARG: Create MCPWM comparator failed because of invalid argument * - ESP_ERR_NO_MEM: Create MCPWM comparator failed because out of memory * - ESP_ERR_NOT_FOUND: Create MCPWM comparator failed because can't find free resource * - ESP_FAIL: Create MCPWM comparator failed because of other error *//* ... */ esp_err_t mcpwm_new_comparator(mcpwm_oper_handle_t oper, const mcpwm_comparator_config_t *config, mcpwm_cmpr_handle_t *ret_cmpr); /** * @brief Delete MCPWM comparator * * @param[in] cmpr MCPWM comparator handle, allocated by `mcpwm_new_comparator()` * @return * - ESP_OK: Delete MCPWM comparator successfully * - ESP_ERR_INVALID_ARG: Delete MCPWM comparator failed because of invalid argument * - ESP_FAIL: Delete MCPWM comparator failed because of other error *//* ... */ esp_err_t mcpwm_del_comparator(mcpwm_cmpr_handle_t cmpr); #if SOC_MCPWM_SUPPORT_EVENT_COMPARATOR /** * @brief MCPWM event comparator configuration *//* ... */ typedef struct { }{...} mcpwm_event_comparator_config_t; /** * @brief Create MCPWM event comparator * * @param[in] oper MCPWM operator, allocated by `mcpwm_new_operator()`, the new event comparator will be allocated from this operator * @param[in] config MCPWM comparator configuration * @param[out] ret_cmpr Returned MCPWM event comparator * @return * - ESP_OK: Create MCPWM event comparator successfully * - ESP_ERR_INVALID_ARG: Create MCPWM event comparator failed because of invalid argument * - ESP_ERR_NO_MEM: Create MCPWM event comparator failed because out of memory * - ESP_ERR_NOT_FOUND: Create MCPWM event comparator failed because can't find free resource * - ESP_FAIL: Create MCPWM event comparator failed because of other error *//* ... */ esp_err_t mcpwm_new_event_comparator(mcpwm_oper_handle_t oper, const mcpwm_event_comparator_config_t *config, mcpwm_cmpr_handle_t *ret_cmpr);/* ... */ #endif // SOC_MCPWM_SUPPORT_EVENT_COMPARATOR /** * @brief Group of supported MCPWM compare event callbacks * @note The callbacks are all running under ISR environment *//* ... */ typedef struct { mcpwm_compare_event_cb_t on_reach; /*!< ISR callback function which would be invoked when counter reaches compare value */ }{ ... } mcpwm_comparator_event_callbacks_t; /** * @brief Set event callbacks for MCPWM comparator * * @note User can deregister a previously registered callback by calling this function and setting the callback member in the `cbs` structure to NULL. * * @param[in] cmpr MCPWM comparator handle, allocated by `mcpwm_new_comparator()` * @param[in] cbs Group of callback functions * @param[in] user_data User data, which will be passed to callback functions directly * @return * - ESP_OK: Set event callbacks successfully * - ESP_ERR_INVALID_ARG: Set event callbacks failed because of invalid argument * - ESP_FAIL: Set event callbacks failed because of other error *//* ... */ esp_err_t mcpwm_comparator_register_event_callbacks(mcpwm_cmpr_handle_t cmpr, const mcpwm_comparator_event_callbacks_t *cbs, void *user_data); /** * @brief Set MCPWM comparator's compare value * * @param[in] cmpr MCPWM comparator handle, allocated by `mcpwm_new_comparator()` * @param[in] cmp_ticks The new compare value * @return * - ESP_OK: Set MCPWM compare value successfully * - ESP_ERR_INVALID_ARG: Set MCPWM compare value failed because of invalid argument (e.g. the cmp_ticks is out of range) * - ESP_ERR_INVALID_STATE: Set MCPWM compare value failed because the operator doesn't have a timer connected * - ESP_FAIL: Set MCPWM compare value failed because of other error *//* ... */ esp_err_t mcpwm_comparator_set_compare_value(mcpwm_cmpr_handle_t cmpr, uint32_t cmp_ticks); #ifdef __cplusplus }{...} #endif
Details