summaryrefslogtreecommitdiff
path: root/bsp/novosns/ns800/libraries/HAL_Drivers/drivers/drv_epwm.h
blob: 079fc7b9af734fabc29727f23180181eb1a9b14c (plain)
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
/**************************************************************************//**
*
* @copyright (C) 2026 Novosense Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date            Author           Notes
* 2026-6-15        Eric           First version
*
******************************************************************************/

#ifndef __DRV_EPWM_H__
#define __DRV_EPWM_H__

#include <rtdef.h>

/* custom command to configure phase */
#define PWM_CMD_EXT_SET_SLAVE_PHASE     (RT_DEVICE_CTRL_BASE(PWM) + 99)

#define EPWM_PIN_INFO(epwm_port_a, epwm_pin_a, pin_mux_a,   \
                    epwm_port_b, epwm_pin_b, pin_mux_b)     \
    {                                           \
        .port_a = epwm_port_a,                  \
        .pin_a = epwm_pin_a,                    \
        .mux_a = pin_mux_a,                     \
        .port_b = epwm_port_b,                  \
        .pin_b = epwm_pin_b,                    \
        .mux_b = pin_mux_b                      \
    }

#define EPWM_DRV_INIT(num, cnt_mode, clk_div, hs_clk_div)   \
    {                                       \
        .name = "epwm"#num ,                \
        .instance = EPWM##num,              \
        .count_mode = cnt_mode,             \
        .clock_div = clk_div,               \
        .hs_clock_div = hs_clk_div          \
    }

/**
 *  @brief  EPWMx channel
 */
enum
{
    EPWMX_A = 0,
    EPWMX_B
};

/**
 *  @brief  EPWMx phase configuration
 */
struct rt_epwm_slave_phase_ext
{
    /*  EPWM master reference device,
        slave pwm phase compare with this master devcie */
    rt_device_t master_dev;
    /* unit: degree, 0~360 */
    rt_uint32_t phase_angle;
};

#endif