Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OwnTech
Power API
Core
Commits
2cea2b7d
Commit
2cea2b7d
authored
Feb 01, 2022
by
Luiz-Fernando Lavado-Villa
Browse files
Updated the HRTIM driver and the urls of all the libraries
parent
66943054
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/owntech.ini
View file @
2cea2b7d
...
...
@@ -10,6 +10,7 @@
[env]
lib_deps
=
# quick_start=https://gitlab.laas.fr/owntech/power-api/opalib-quick-start.git
# pid_voltage=https://gitlab.laas.fr/owntech/power-api/opalib-pid.git
# pid_current=https://gitlab.laas.fr/owntech/power-api/opalib-pid-current-mode.git
peripherals
=
https://gitlab.laas.fr/owntech/power-api/opalib-peripherals.git
control_pid
=
https://gitlab.laas.fr/owntech/power-api/opalib-control-pid.git
power_conversion
=
https://gitlab.laas.fr/owntech/power-api/opalib-power-conversion.git
data_conversion
=
https://gitlab.laas.fr/owntech/power-api/opalib-data-conversion.git
zephyr/modules/owntech_hrtim_driver/zephyr/public_include/hrtim.h
View file @
2cea2b7d
/*
* Copyright (c) 2021 LAAS-CNRS
* Copyright (c) 2021
-2022
LAAS-CNRS
*
* 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
...
...
@@ -19,6 +19,7 @@
/**
* @author Clément Foucher <clement.foucher@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#ifndef HRTIM_H_
...
...
@@ -78,7 +79,12 @@ void hrtim_pwm_set(hrtim_t dev, hrtim_tu_t tu, uint16_t value, uint16_t shift);
void
hrtim_init_current
();
void
hrtim_init_voltage
();
void
hrtim_init_voltage_buck
();
void
hrtim_init_voltage_boost
();
void
hrtim_init_voltage_leg1_buck_leg2_boost
();
void
hrtim_init_voltage_leg1_boost_leg2_buck
();
#ifdef __cplusplus
}
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/public_include/leg.h
View file @
2cea2b7d
/*
* Copyright (c) 2020 LAAS-CNRS
* Copyright (c) 2020
-2022
LAAS-CNRS
*
* 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
...
...
@@ -23,12 +23,12 @@
* @ingroup owntech_modules
* @brief OwnTech PWM management layer by inverter leg
*
* @{
* @file
* @brief PWM management layer by inverter leg interface definitions
* @date 202
0
* @date 202
2
* @author Hugues Larrive <hugues.larrive@laas.fr>
* @author Antoine Boche <antoine.boche@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#ifndef LEG_H_
...
...
@@ -61,11 +61,12 @@ typedef struct {
/**
* @brief Initializes all the configured devices with the chosen switch convention
*
* @param[in] upper_switch_convention Choice of the switch convention
* @param[in] leg1_upper_switch_convention Choice of the switch convention for leg 1
* @param[in] leg2_upper_switch_convention Choice of the switch convention for leg 2
*
* @return HRTIM period
*/
uint16_t
leg_init
(
bool
upper_switch_convention
);
uint16_t
leg_init
(
bool
leg1_upper_switch_convention
,
bool
leg2_
upper_switch_convention
);
/**
* @brief Set the PWM pulse width for a given leg device
...
...
@@ -83,6 +84,13 @@ void leg_set(hrtim_tu_t timing_unit, uint16_t pulse_width, uint16_t phase_shift)
*/
void
leg_stop
(
hrtim_tu_t
timing_unit
);
/**
* @brief Start the leg (its 2 outputs goes low)
*
* @param[in] timing_unit timing_unit from TIMA to TIMF
*/
void
leg_start
(
hrtim_tu_t
timing_unit
);
/**
* @brief period getter
*
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/src/hrtim_common.c
View file @
2cea2b7d
/*
* Copyright (c) 2021 LAAS-CNRS
* Copyright (c) 2021
-2022
LAAS-CNRS
*
* 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
...
...
@@ -19,6 +19,7 @@
/**
* @author Clément Foucher <clement.foucher@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#include "voltage_mode/hrtim_voltage_mode.h"
...
...
@@ -33,9 +34,30 @@ void hrtim_init_current()
hrtim_cm_enable
();
}
void
hrtim_init_voltage
()
void
hrtim_init_voltage
_buck
()
{
leg_init
(
true
);
leg_init
(
true
,
true
);
hrtim_adc_trigger_en
(
0
,
ADC1R
,
AD13_TAC3
);
hrtim_cmp_set
(
0
,
TIMA
,
CMP3xR
,
1
);
}
void
hrtim_init_voltage_boost
()
{
leg_init
(
false
,
false
);
hrtim_adc_trigger_en
(
0
,
ADC1R
,
AD13_TAC3
);
hrtim_cmp_set
(
0
,
TIMA
,
CMP3xR
,
1
);
}
void
hrtim_init_voltage_leg1_buck_leg2_boost
()
{
leg_init
(
true
,
false
);
hrtim_adc_trigger_en
(
0
,
ADC1R
,
AD13_TAC3
);
hrtim_cmp_set
(
0
,
TIMA
,
CMP3xR
,
1
);
}
void
hrtim_init_voltage_leg1_boost_leg2_buck
()
{
leg_init
(
false
,
true
);
hrtim_adc_trigger_en
(
0
,
ADC1R
,
AD13_TAC3
);
hrtim_cmp_set
(
0
,
TIMA
,
CMP3xR
,
1
);
}
zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.c
View file @
2cea2b7d
/*
* Copyright (c) 2020-202
1
LAAS-CNRS
* Copyright (c) 2020-202
2
LAAS-CNRS
*
* 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
...
...
@@ -27,6 +27,7 @@
* @author Hugues Larrive <hugues.larrive@laas.fr>
* @author Clément Foucher <clement.foucher@laas.fr>
* @author Antoine Boche <antoine.boche@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#include <stm32_ll_rcc.h>
...
...
@@ -130,7 +131,7 @@ static inline uint32_t _period_ckpsc(hrtim_t hrtim, uint32_t freq,
return
frequency
;
}
uint16_t
hrtim_init
(
hrtim_t
hrtim
,
uint32_t
*
freq
,
uint16_t
dt
,
uint8_t
upper_switch_convention
)
uint16_t
hrtim_init
(
hrtim_t
hrtim
,
uint32_t
*
freq
,
uint16_t
dt
,
uint8_t
leg1_upper_switch_convention
,
uint8_t
leg2_
upper_switch_convention
)
{
/* Master timer initialization */
uint16_t
period
=
hrtim_init_master
(
hrtim
,
freq
);
...
...
@@ -147,7 +148,8 @@ uint16_t hrtim_init(hrtim_t hrtim, uint32_t *freq, uint16_t dt, uint8_t upper_sw
hrtim_cnt_en
(
hrtim
,
(
1
<<
(
HRTIM_MCR_TACEN_Pos
+
tu
)));
/* Setup outputs */
hrtim_cmpl_pwm_out
(
hrtim
,
tu
,
upper_switch_convention
);
hrtim_cmpl_pwm_out1
(
hrtim
,
tu
,
leg1_upper_switch_convention
);
hrtim_cmpl_pwm_out2
(
hrtim
,
tu
,
leg2_upper_switch_convention
);
/* Reset on master timer period event */
hrtim_rst_evt_en
(
hrtim
,
tu
,
RST_MSTPER
);
...
...
@@ -366,6 +368,40 @@ void hrtim_cmpl_pwm_out(hrtim_t hrtim, hrtim_tu_t tu, bool upper_switch_conventi
}
}
void
hrtim_cmpl_pwm_out1
(
hrtim_t
hrtim
,
hrtim_tu_t
tu
,
bool
leg1_upper_switch_convention
)
{
// Configuration for the upper switch convention
if
(
leg1_upper_switch_convention
==
true
)
{
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
SETx1R
=
PER
;
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
RSTx1R
=
CMP1
;
}
// Configuration for the lower switch convention
else
if
(
leg1_upper_switch_convention
==
false
)
{
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
SETx1R
=
CMP1
;
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
RSTx1R
=
PER
;
}
}
void
hrtim_cmpl_pwm_out2
(
hrtim_t
hrtim
,
hrtim_tu_t
tu
,
bool
leg2_upper_switch_convention
)
{
// Configuration for the upper switch convention
if
(
leg2_upper_switch_convention
==
true
)
{
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
SETx2R
=
CMP1
;
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
RSTx2R
=
PER
;
}
// Configuration for the lower switch convention
else
if
(
leg2_upper_switch_convention
==
false
)
{
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
SETx2R
=
PER
;
dev
(
hrtim
)
->
sTimerxRegs
[
tu
].
RSTx2R
=
CMP1
;
}
}
void
hrtim_period_set
(
hrtim_t
hrtim
,
hrtim_tu_t
tu
,
uint16_t
value
)
{
if
(
tu
==
MSTR
)
{
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.h
View file @
2cea2b7d
/*
* Copyright (c) 2020-202
1
LAAS-CNRS
* Copyright (c) 2020-202
2
LAAS-CNRS
*
* 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
...
...
@@ -28,6 +28,7 @@
* @author Hugues Larrive <hugues.larrive@laas.fr>
* @author Clément Foucher <clement.foucher@laas.fr>
* @author Antoine Boche <antoine.boche@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#ifndef HRTIM_VOLTAGE_MODE_H_
...
...
@@ -331,16 +332,16 @@ typedef enum {
* @brief Initialize an HRTIM device and all these timing units for
* complementary pwm outputs with a dead time.
*
* @param[in] dev HRTIM device to initialize
* @param[inout] freq HRTIM frequency in Hz
* @param[in] dt Desired dead time in ns
* @param[in] switch_convention Choice of the switch convention
* @param[in] dev HRTIM device to initialize
* @param[inout] freq HRTIM frequency in Hz
* @param[in] dt Desired dead time in ns
* @param[in] leg1_upper_switch_convention Choice of the switch convention for leg 1
* @param[in] leg2_upper_switch_convention Choice of the switch convention for leg 2
*
* @return actual HRTIM resolution on success
* @return 0 on error
*/
uint16_t
hrtim_init
(
hrtim_t
dev
,
uint32_t
*
freq
,
uint16_t
dt
,
uint8_t
switch_convention
);
uint16_t
hrtim_init
(
hrtim_t
dev
,
uint32_t
*
freq
,
uint16_t
dt
,
uint8_t
leg1_upper_switch_convention
,
uint8_t
leg2_upper_switch_convention
);
/**
* @brief Initialize an HRTIM device master timer
*
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/owntech_leg_driver.cpp
View file @
2cea2b7d
/*
* Copyright (c) 2020 LAAS-CNRS
* Copyright (c) 2020
-2022
LAAS-CNRS
*
* 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
...
...
@@ -21,9 +21,10 @@
/**
* @file
* @brief PWM management layer by inverter leg
* @date 202
0
* @date 202
2
* @author Hugues Larrive <hugues.larrive@laas.fr>
* @author Antoine Boche <antoine.boche@laas.fr>
* @author Luiz Villa <luiz.villa@laas.fr>
*/
#include "leg.h"
...
...
@@ -41,7 +42,7 @@ static leg_conf_t leg_conf[6]; /* a copy of leg_config with index
* on the power converter to a frequency of 200kHz
* Must be initialized in first position
*/
uint16_t
leg_init
(
bool
upper_switch_convention
)
uint16_t
leg_init
(
bool
leg1_upper_switch_convention
,
bool
leg2_
upper_switch_convention
)
{
uint32_t
freq
=
LEG_FREQ
;
...
...
@@ -51,7 +52,7 @@ uint16_t leg_init(bool upper_switch_convention)
leg_conf
[
leg_config
[
i
].
timing_unit
]
=
leg_config
[
i
];
}
period
=
hrtim_init
(
0
,
&
freq
,
LEG_DEFAULT_DT
,
upper_switch_convention
);
period
=
hrtim_init
(
0
,
&
freq
,
LEG_DEFAULT_DT
,
leg1_upper_switch_convention
,
leg2_
upper_switch_convention
);
dead_time
=
(
period
*
LEG_DEFAULT_DT
*
leg_get_freq
())
/
1000000
;
min_pw
=
(
period
*
0.1
)
+
dead_time
;
max_pw
=
(
period
*
0.9
)
+
dead_time
;
...
...
@@ -83,10 +84,14 @@ void leg_set(hrtim_tu_t timing_unit, uint16_t pulse_width, uint16_t phase_shift)
void
leg_stop
(
hrtim_tu_t
timing_unit
)
{
hrtim_pwm_set
(
leg_conf
[
timing_unit
].
hrtim
,
leg_conf
[
timing_unit
].
timing_unit
,
0
,
0
);
hrtim_out_dis
(
leg_conf
[
timing_unit
].
hrtim
,
leg_conf
[
timing_unit
].
timing_unit
,
OUT1
);
hrtim_out_dis
(
leg_conf
[
timing_unit
].
hrtim
,
leg_conf
[
timing_unit
].
timing_unit
,
OUT2
);
}
void
leg_start
(
hrtim_tu_t
timing_unit
)
{
hrtim_out_en
(
leg_conf
[
timing_unit
].
hrtim
,
leg_conf
[
timing_unit
].
timing_unit
,
OUT1
);
hrtim_out_en
(
leg_conf
[
timing_unit
].
hrtim
,
leg_conf
[
timing_unit
].
timing_unit
,
OUT2
);
}
uint16_t
leg_period
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment