hrtim.h 2.52 KB
Newer Older
1
/*
2
 * Copyright (c) 2021-2022 LAAS-CNRS
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: LGLPV2.1
 */

/**
 * @author Clément Foucher <clement.foucher@laas.fr>
22
 * @author Luiz Villa <luiz.villa@laas.fr>
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
23
 * @author Ayoub Farah Hassan <ayoub.farah-hassan@laas.fr>
24
25
26
27
28
29
30
31
 */

#ifndef HRTIM_H_
#define HRTIM_H_


#include <stdint.h>

Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
32
33
#include <stm32_ll_hrtim.h>

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

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief   HRTIM have 5 or 6 timing units
 */
#ifdef HRTIM_MCR_TFCEN
#define HRTIM_STU_NUMOF (6U)        /**< number of slave timing units */
#else
#define HRTIM_STU_NUMOF (5U)
#endif

/**
 * @brief   Default HRTIM type definition
 */
#ifndef HAVE_HRTIM_T
typedef unsigned int hrtim_t;
#endif

/**
 * @brief   HRTIM timing units definition
 */
typedef enum {
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
59
60
61
62
63
    TIMA = LL_HRTIM_TIMER_A,
    TIMB = LL_HRTIM_TIMER_B,
    TIMC = LL_HRTIM_TIMER_C,
    TIMD = LL_HRTIM_TIMER_D,
    TIME = LL_HRTIM_TIMER_E,
64
#if (HRTIM_STU_NUMOF == 6)
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
65
    TIMF = LL_HRTIM_TIMER_F,
66
#endif
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
67
    MSTR = LL_HRTIM_TIMER_MASTER
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
} hrtim_tu_t;


/**
 * @brief   Set the duty-cycle, dead-time and phase shift for a given
 *          timing unit of a given HRTIM device
 *
 * @param[in] dev           HRTIM device
 * @param[in] tu            Timing unit
 * @param[in] value         Duty cycle
 * @param[in] shift         Phase shifting
 */
void hrtim_pwm_set(hrtim_t dev, hrtim_tu_t tu, uint16_t value, uint16_t shift);



84
void hrtim_init_current();
85
void hrtim_init_voltage_buck();
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
86
void hrtim_init_voltage_buck_center_aligned();
87
void hrtim_init_voltage_boost();
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
88
void hrtim_init_voltage_boost_center_aligned();
89
void hrtim_init_voltage_leg1_buck_leg2_boost();
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
90
void hrtim_init_voltage_leg1_buck_leg2_boost_center_aligned();
91
void hrtim_init_voltage_leg1_boost_leg2_buck();
Ayoub Farah Hassan's avatar
Ayoub Farah Hassan committed
92
void hrtim_init_voltage_leg1_boost_leg2_buck_center_aligned();
93
void hrtim_update_adc_trig_interleaved(uint16_t new_trig);
94
95


96
97
98
99
100
101

#ifdef __cplusplus
}
#endif

#endif // HRTIM_H_