1 /*
2  * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include "soc/clk_tree_defs.h"
10 #include "soc/soc_caps.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief MCPWM timer clock source
18  */
19 #if SOC_MCPWM_SUPPORTED
20 typedef soc_periph_mcpwm_timer_clk_src_t mcpwm_timer_clock_source_t;
21 #else
22 typedef int mcpwm_timer_clock_source_t;
23 #endif // SOC_MCPWM_SUPPORTED
24 
25 /**
26  * @brief MCPWM capture clock source
27  */
28 #if SOC_MCPWM_SUPPORTED
29 typedef soc_periph_mcpwm_capture_clk_src_t mcpwm_capture_clock_source_t;
30 #else
31 typedef int mcpwm_capture_clock_source_t;
32 #endif // SOC_MCPWM_SUPPORTED
33 
34 /**
35  * @brief MCPWM carrier clock source
36  */
37 #if SOC_MCPWM_SUPPORTED
38 typedef soc_periph_mcpwm_carrier_clk_src_t mcpwm_carrier_clock_source_t;
39 #else
40 typedef int mcpwm_carrier_clock_source_t;
41 #endif // SOC_MCPWM_SUPPORTED
42 
43 /**
44  * @brief MCPWM timer count direction
45  */
46 typedef enum {
47     MCPWM_TIMER_DIRECTION_UP,   /*!< Counting direction: Increase */
48     MCPWM_TIMER_DIRECTION_DOWN, /*!< Counting direction: Decrease */
49 } mcpwm_timer_direction_t;
50 
51 /**
52  * @brief MCPWM timer events
53  */
54 typedef enum {
55     MCPWM_TIMER_EVENT_EMPTY,   /*!< MCPWM timer counts to zero (i.e. counter is empty) */
56     MCPWM_TIMER_EVENT_FULL,    /*!< MCPWM timer counts to peak (i.e. counter is full) */
57     MCPWM_TIMER_EVENT_INVALID, /*!< MCPWM timer invalid event */
58 } mcpwm_timer_event_t;
59 
60 /**
61  * @brief MCPWM timer count modes
62  */
63 typedef enum {
64     MCPWM_TIMER_COUNT_MODE_PAUSE,   /*!< MCPWM timer paused */
65     MCPWM_TIMER_COUNT_MODE_UP,      /*!< MCPWM timer counting up */
66     MCPWM_TIMER_COUNT_MODE_DOWN,    /*!< MCPWM timer counting down */
67     MCPWM_TIMER_COUNT_MODE_UP_DOWN, /*!< MCPWM timer counting up and down */
68 } mcpwm_timer_count_mode_t;
69 
70 /**
71  * @brief MCPWM timer commands, specify the way to start or stop the timer
72  */
73 typedef enum {
74     MCPWM_TIMER_STOP_EMPTY,       /*!< MCPWM timer stops when next count reaches zero */
75     MCPWM_TIMER_STOP_FULL,        /*!< MCPWM timer stops when next count reaches peak */
76     MCPWM_TIMER_START_NO_STOP,    /*!< MCPWM timer starts couting, and don't stop until received stop command */
77     MCPWM_TIMER_START_STOP_EMPTY, /*!< MCPWM timer starts counting and stops when next count reaches zero */
78     MCPWM_TIMER_START_STOP_FULL,  /*!< MCPWM timer starts counting and stops when next count reaches peak */
79 } mcpwm_timer_start_stop_cmd_t;
80 
81 /**
82  * @brief MCPWM generator actions
83  */
84 typedef enum {
85     MCPWM_GEN_ACTION_KEEP,   /*!< Generator action: Keep the same level */
86     MCPWM_GEN_ACTION_LOW,    /*!< Generator action: Force to low level */
87     MCPWM_GEN_ACTION_HIGH,   /*!< Generator action: Force to high level */
88     MCPWM_GEN_ACTION_TOGGLE, /*!< Generator action: Toggle level */
89 } mcpwm_generator_action_t;
90 
91 /**
92  * @brief MCPWM operator brake mode
93  */
94 typedef enum {
95     MCPWM_OPER_BRAKE_MODE_CBC,     /*!< Brake mode: CBC (cycle by cycle)*/
96     MCPWM_OPER_BRAKE_MODE_OST,     /*!< Brake mode: OST (one shot) */
97     MCPWM_OPER_BRAKE_MODE_INVALID, /*!< MCPWM operator invalid brake mode */
98 } mcpwm_operator_brake_mode_t;
99 
100 /**
101  * @brief MCPWM capture edge
102  */
103 typedef enum {
104     MCPWM_CAP_EDGE_POS, /*!< Capture on the positive edge */
105     MCPWM_CAP_EDGE_NEG, /*!< Capture on the negative edge */
106 } mcpwm_capture_edge_t;
107 
108 #ifdef __cplusplus
109 }
110 #endif
111