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
Luiz Fernando Lavado Villa
Core
Commits
021fcfe8
Commit
021fcfe8
authored
Jul 19, 2021
by
Luiz-Fernando Lavado-Villa
Browse files
Merge branch 'main' of gitlab.laas.fr:owntech/power-api/core into voltage_mode_new_acquisition
parents
423e838c
33071e7b
Changes
15
Hide whitespace changes
Inline
Side-by-side
zephyr/modules/owntech_comparator_driver/zephyr/CMakeLists.txt
0 → 100644
View file @
021fcfe8
if
(
CONFIG_OWNTECH_COMPARATOR_DRIVER
)
# Select directory to add to the include path
zephyr_include_directories
(
./public_include
)
# Define the current folder as a Zephyr library
zephyr_library
()
# Select source files to be compiled
zephyr_library_sources
(
./src/comparator_driver.c
)
endif
()
zephyr/modules/owntech_comparator_driver/zephyr/Kconfig
0 → 100644
View file @
021fcfe8
config OWNTECH_COMPARATOR_DRIVER
bool "Enable OwnTech comparator driver for STM32"
default y
zephyr/modules/owntech_comparator_driver/zephyr/module.yml
0 → 100644
View file @
021fcfe8
name
:
owntech_comparator_driver
build
:
cmake
:
zephyr
kconfig
:
zephyr/Kconfig
zephyr/modules/owntech_comparator_driver/zephyr/public_include/comparator.h
0 → 100644
View file @
021fcfe8
/*
* Copyright (c) 2021 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
* 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>
*/
#ifndef COMPARATOR_H_
#define COMPARATOR_H_
#ifdef __cplusplus
extern
"C"
{
#endif
void
comparator_init
();
#ifdef __cplusplus
}
#endif
#endif // COMPARATOR_H_
zephyr/modules/owntech_comparator_driver/zephyr/src/comparator_driver.c
0 → 100644
View file @
021fcfe8
/*
* Copyright (c) 2021 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
* 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>
*/
// Zephyr
#include
<zephyr.h>
// STM32 LL
#include
<stm32_ll_comp.h>
#include
<stm32_ll_gpio.h>
#include
<stm32_ll_bus.h>
// Current file header
#include
"comparator_driver.h"
void
comparator_init
()
{
_comparator_gpio_init
();
_comparator_comp1_init
();
_comparator_comp3_init
();
}
static
void
_comparator_gpio_init
()
{
// TODO : use Zephyr gpio_pin_configure
/*
COMP1 GPIO Configuration
PA1 ------> COMP1_INP
PB8-BOOT0 ------> COMP1_OUT
COMP3 GPIO Configuration
PC1 ------> COMP3_INP
PB15 ------> COMP3_OUT
*/
LL_AHB2_GRP1_EnableClock
(
LL_AHB2_GRP1_PERIPH_GPIOA
);
LL_AHB2_GRP1_EnableClock
(
LL_AHB2_GRP1_PERIPH_GPIOB
);
LL_AHB2_GRP1_EnableClock
(
LL_AHB2_GRP1_PERIPH_GPIOC
);
// Pin A.1 (cmp 1)
LL_GPIO_SetPinPull
(
GPIOA
,
LL_GPIO_PIN_1
,
LL_GPIO_PULL_NO
);
LL_GPIO_SetPinMode
(
GPIOA
,
LL_GPIO_PIN_1
,
LL_GPIO_MODE_ANALOG
);
// Pin C.1 (cmp 3)
LL_GPIO_SetPinPull
(
GPIOC
,
LL_GPIO_PIN_1
,
LL_GPIO_PULL_NO
);
LL_GPIO_SetPinMode
(
GPIOC
,
LL_GPIO_PIN_1
,
LL_GPIO_MODE_ANALOG
);
}
static
void
_comparator_comp1_init
()
{
LL_COMP_ConfigInputs
(
COMP1
,
LL_COMP_INPUT_MINUS_DAC1_CH1
,
LL_COMP_INPUT_PLUS_IO1
);
LL_COMP_SetInputHysteresis
(
COMP1
,
LL_COMP_HYSTERESIS_NONE
);
LL_COMP_SetOutputPolarity
(
COMP1
,
LL_COMP_OUTPUTPOL_NONINVERTED
);
LL_COMP_SetOutputBlankingSource
(
COMP1
,
LL_COMP_BLANKINGSRC_NONE
);
k_busy_wait
(
LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US
);
LL_EXTI_DisableEvent_0_31
(
LL_EXTI_LINE_21
);
LL_EXTI_DisableIT_0_31
(
LL_EXTI_LINE_21
);
LL_COMP_Enable
(
COMP1
);
}
static
void
_comparator_comp3_init
()
{
LL_COMP_ConfigInputs
(
COMP3
,
LL_COMP_INPUT_MINUS_DAC3_CH1
,
LL_COMP_INPUT_PLUS_IO2
);
LL_COMP_SetInputHysteresis
(
COMP3
,
LL_COMP_HYSTERESIS_NONE
);
LL_COMP_SetOutputPolarity
(
COMP3
,
LL_COMP_OUTPUTPOL_NONINVERTED
);
LL_COMP_SetOutputBlankingSource
(
COMP3
,
LL_COMP_BLANKINGSRC_NONE
);
k_busy_wait
(
LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US
);
LL_EXTI_DisableEvent_0_31
(
LL_EXTI_LINE_29
);
LL_EXTI_DisableIT_0_31
(
LL_EXTI_LINE_29
);
LL_COMP_Enable
(
COMP3
);
}
zephyr/modules/owntech_comparator_driver/zephyr/src/comparator_driver.h
0 → 100644
View file @
021fcfe8
/*
* Copyright (c) 2021 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
* 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>
*/
#ifndef COMPARATOR_DRIVER_H_
#define COMPARATOR_DRIVER_H_
#ifdef __cplusplus
extern
"C"
{
#endif
static
void
_comparator_comp1_init
();
static
void
_comparator_comp3_init
();
static
void
_comparator_gpio_init
();
#ifdef __cplusplus
}
#endif
#endif // COMPARATOR_DRIVER_H_
zephyr/modules/owntech_dac_driver/zephyr/public_include/dac.h
View file @
021fcfe8
...
...
@@ -64,6 +64,8 @@ typedef struct
typedef
void
(
*
dac_api_setconstvalue
)
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
value
);
typedef
void
(
*
dac_api_setfunction
)
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_function_config_t
*
config
);
typedef
void
(
*
dac_api_fn_upd_reset
)
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
reset_data
);
typedef
void
(
*
dac_api_fn_upd_step
)
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
step_data
);
typedef
void
(
*
dac_api_pinconfigure
)
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_pin_config_t
*
config
);
typedef
void
(
*
dac_api_start
)
(
const
struct
device
*
dev
,
uint8_t
channel
);
typedef
void
(
*
dac_api_stop
)
(
const
struct
device
*
dev
,
uint8_t
channel
);
...
...
@@ -72,6 +74,8 @@ __subsystem struct dac_driver_api
{
dac_api_setconstvalue
setconstvalue
;
dac_api_setfunction
setfunction
;
dac_api_fn_upd_reset
fn_upd_reset
;
dac_api_fn_upd_step
fn_upd_step
;
dac_api_pinconfigure
pinconfigure
;
dac_api_start
start
;
dac_api_stop
stop
;
...
...
@@ -91,6 +95,20 @@ static inline void dac_set_function(const struct device* dev, uint8_t channel, c
api
->
setfunction
(
dev
,
channel
,
function_config
);
}
static
inline
void
dac_function_update_reset
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
reset_data
)
{
const
struct
dac_driver_api
*
api
=
(
const
struct
dac_driver_api
*
)(
dev
->
api
);
api
->
fn_upd_reset
(
dev
,
channel
,
reset_data
);
}
static
inline
void
dac_function_update_step
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
step_data
)
{
const
struct
dac_driver_api
*
api
=
(
const
struct
dac_driver_api
*
)(
dev
->
api
);
api
->
fn_upd_step
(
dev
,
channel
,
step_data
);
}
static
inline
void
dac_pin_configure
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_pin_config_t
*
pin_config
)
{
const
struct
dac_driver_api
*
api
=
(
const
struct
dac_driver_api
*
)(
dev
->
api
);
...
...
zephyr/modules/owntech_dac_driver/zephyr/src/stm32_dac_driver.c
View file @
021fcfe8
...
...
@@ -65,6 +65,8 @@ static const struct dac_driver_api dac_funcs =
{
.
setconstvalue
=
dac_stm32_set_const_value
,
.
setfunction
=
dac_stm32_set_function
,
.
fn_upd_reset
=
dac_stm32_function_update_reset
,
.
fn_upd_step
=
dac_stm32_function_update_step
,
.
pinconfigure
=
dac_stm32_pin_configure
,
.
start
=
dac_stm32_start
,
.
stop
=
dac_stm32_stop
...
...
@@ -77,9 +79,10 @@ static void dac_stm32_set_const_value(const struct device* dev, uint8_t channel,
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
if
(
data
->
dac_mode
!=
dac_mode_constant
)
if
(
data
->
dac_mode
[
channel
-
1
]
!=
dac_mode_constant
)
{
data
->
dac_mode
=
dac_mode_constant
;
data
->
dac_mode
[
channel
-
1
]
=
dac_mode_constant
;
data
->
dac_config
->
constant_value
=
value
;
LL_DAC_SetSignedFormat
(
dac_dev
,
dac_channel
,
LL_DAC_SIGNED_FORMAT_DISABLE
);
...
...
@@ -99,10 +102,12 @@ static void dac_stm32_set_function(const struct device* dev, uint8_t channel, co
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
data
->
dac_mode
=
dac_mode_function
;
data
->
dac_mode
[
channel
-
1
]
=
dac_mode_function
;
if
(
function_config
->
dac_function
==
dac_function_sawtooth
)
{
data
->
dac_config
->
function_config
=
*
function_config
;
LL_DAC_SetSignedFormat
(
dac_dev
,
dac_channel
,
LL_DAC_SIGNED_FORMAT_DISABLE
);
LL_DAC_SetWaveAutoGeneration
(
dac_dev
,
dac_channel
,
LL_DAC_WAVE_AUTO_GENERATION_SAWTOOTH
);
...
...
@@ -117,6 +122,66 @@ static void dac_stm32_set_function(const struct device* dev, uint8_t channel, co
}
}
static
void
dac_stm32_function_update_reset
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
reset_data
)
{
struct
stm32_dac_driver_data
*
data
=
(
struct
stm32_dac_driver_data
*
)
dev
->
data
;
DAC_TypeDef
*
dac_dev
=
data
->
dac_struct
;
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
if
(
data
->
dac_mode
[
channel
-
1
]
==
dac_mode_function
)
{
data
->
dac_config
->
function_config
.
reset_data
=
reset_data
;
if
(
data
->
started
[
channel
-
1
]
==
1
)
{
LL_DAC_Disable
(
dac_dev
,
dac_channel
);
}
LL_DAC_SetWaveSawtoothResetData
(
dac_dev
,
dac_channel
,
reset_data
);
if
(
data
->
started
[
channel
-
1
]
==
1
)
{
LL_DAC_Enable
(
dac_dev
,
dac_channel
);
while
(
LL_DAC_IsReady
(
dac_dev
,
dac_channel
)
==
0
)
{
// Wait
}
}
}
}
static
void
dac_stm32_function_update_step
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
step_data
)
{
struct
stm32_dac_driver_data
*
data
=
(
struct
stm32_dac_driver_data
*
)
dev
->
data
;
DAC_TypeDef
*
dac_dev
=
data
->
dac_struct
;
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
if
(
data
->
dac_mode
[
channel
-
1
]
==
dac_mode_function
)
{
data
->
dac_config
->
function_config
.
step_data
=
step_data
;
if
(
data
->
started
[
channel
-
1
]
==
1
)
{
LL_DAC_Disable
(
dac_dev
,
dac_channel
);
}
LL_DAC_SetWaveSawtoothStepData
(
dac_dev
,
dac_channel
,
step_data
);
if
(
data
->
started
[
channel
-
1
]
==
1
)
{
LL_DAC_Enable
(
dac_dev
,
dac_channel
);
while
(
LL_DAC_IsReady
(
dac_dev
,
dac_channel
)
==
0
)
{
// Wait
}
}
}
}
static
void
dac_stm32_pin_configure
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_pin_config_t
*
pin_config
)
{
struct
stm32_dac_driver_data
*
data
=
(
struct
stm32_dac_driver_data
*
)
dev
->
data
;
...
...
@@ -134,11 +199,16 @@ static void dac_stm32_start(const struct device* dev, uint8_t channel)
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
LL_DAC_Enable
(
dac_dev
,
dac_channel
);
while
(
LL_DAC_IsReady
(
dac_dev
,
dac_channel
)
==
0
)
if
(
(
data
->
dac_mode
[
channel
-
1
]
!=
dac_mode_unset
)
&&
(
data
->
started
[
channel
-
1
]
==
0
)
)
{
// Wait
LL_DAC_Enable
(
dac_dev
,
dac_channel
);
while
(
LL_DAC_IsReady
(
dac_dev
,
dac_channel
)
==
0
)
{
// Wait
}
data
->
started
[
channel
-
1
]
=
1
;
}
}
...
...
@@ -149,7 +219,12 @@ static void dac_stm32_stop(const struct device* dev, uint8_t channel)
uint8_t
dac_channel
=
__LL_DAC_DECIMAL_NB_TO_CHANNEL
(
channel
);
LL_DAC_Disable
(
dac_dev
,
dac_channel
);
if
(
data
->
started
[
channel
-
1
]
==
1
)
{
LL_DAC_Disable
(
dac_dev
,
dac_channel
);
data
->
started
[
channel
-
1
]
=
0
;
}
}
...
...
@@ -162,7 +237,8 @@ static void dac_stm32_stop(const struct device* dev, uint8_t channel)
struct
stm32_dac_driver_data
dac1_data
=
{
.
dac_struct
=
DAC1
,
.
dac_mode
=
dac_mode_unset
.
dac_mode
=
{
dac_mode_unset
,
dac_mode_unset
},
.
started
=
{
0
,
0
}
};
DEVICE_DT_DEFINE
(
DAC1_NODELABEL
,
...
...
@@ -183,7 +259,8 @@ DEVICE_DT_DEFINE(DAC1_NODELABEL,
struct
stm32_dac_driver_data
dac2_data
=
{
.
dac_struct
=
DAC2
,
.
dac_mode
=
dac_mode_unset
.
dac_mode
=
{
dac_mode_unset
,
dac_mode_unset
},
.
started
=
{
0
,
0
}
};
DEVICE_DT_DEFINE
(
DAC2_NODELABEL
,
...
...
@@ -204,7 +281,8 @@ DEVICE_DT_DEFINE(DAC2_NODELABEL,
struct
stm32_dac_driver_data
dac3_data
=
{
.
dac_struct
=
DAC3
,
.
dac_mode
=
dac_mode_unset
.
dac_mode
=
{
dac_mode_unset
,
dac_mode_unset
},
.
started
=
{
0
,
0
}
};
DEVICE_DT_DEFINE
(
DAC3_NODELABEL
,
...
...
zephyr/modules/owntech_dac_driver/zephyr/src/stm32_dac_driver.h
View file @
021fcfe8
...
...
@@ -50,7 +50,13 @@ typedef enum
struct
stm32_dac_driver_data
{
DAC_TypeDef
*
dac_struct
;
dac_mode_t
dac_mode
;
dac_mode_t
dac_mode
[
2
];
uint8_t
started
[
2
];
union
{
uint32_t
constant_value
;
dac_function_config_t
function_config
;
}
dac_config
[
2
];
};
...
...
@@ -58,6 +64,8 @@ struct stm32_dac_driver_data
static
int
dac_stm32_init
(
const
struct
device
*
dev
);
static
void
dac_stm32_set_const_value
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
value
);
static
void
dac_stm32_set_function
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_function_config_t
*
function_config
);
static
void
dac_stm32_function_update_reset
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
reset_data
);
static
void
dac_stm32_function_update_step
(
const
struct
device
*
dev
,
uint8_t
channel
,
uint32_t
step_data
);
static
void
dac_stm32_pin_configure
(
const
struct
device
*
dev
,
uint8_t
channel
,
const
dac_pin_config_t
*
pin_config
);
static
void
dac_stm32_start
(
const
struct
device
*
dev
,
uint8_t
channel
);
static
void
dac_stm32_stop
(
const
struct
device
*
dev
,
uint8_t
channel
);
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/CMakeLists.txt
View file @
021fcfe8
...
...
@@ -7,6 +7,7 @@ if(CONFIG_OWNTECH_HRTIM_DRIVER)
zephyr_library_sources
(
./src/voltage_mode/hrtim_voltage_mode.c
./src/voltage_mode/owntech_leg_driver.cpp
./src/current_mode/hrtim_current_mode.c
./src/hrtim_common.c
)
endif
()
zephyr/modules/owntech_hrtim_driver/zephyr/public_include/hrtim.h
View file @
021fcfe8
...
...
@@ -77,6 +77,7 @@ 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
();
#ifdef __cplusplus
...
...
zephyr/modules/owntech_hrtim_driver/zephyr/src/current_mode/hrtim_current_mode.c
0 → 100644
View file @
021fcfe8
/*
* Copyright (c) 2020-2021 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
* 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>
*/
// STM32 LL
#include
<stm32_ll_hrtim.h>
#include
<stm32_ll_gpio.h>
#include
<stm32_ll_bus.h>
#include
<stm32_ll_dmamux.h>
void
hrtim_cm_init
()
{
/* Peripheral clock enable */
LL_APB2_GRP1_EnableClock
(
LL_APB2_GRP1_PERIPH_HRTIM1
);
LL_HRTIM_ConfigDLLCalibration
(
HRTIM1
,
LL_HRTIM_DLLCALIBRATION_MODE_CONTINUOUS
,
LL_HRTIM_DLLCALIBRATION_RATE_3
);
while
(
LL_HRTIM_IsActiveFlag_DLLRDY
(
HRTIM1
)
==
RESET
)
{
// Wait
}
LL_HRTIM_EE_SetPrescaler
(
HRTIM1
,
LL_HRTIM_EE_PRESCALER_DIV1
);
LL_HRTIM_EE_SetSrc
(
HRTIM1
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EEV4SRC_COMP1_OUT
);
LL_HRTIM_EE_SetPolarity
(
HRTIM1
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EE_POLARITY_HIGH
);
LL_HRTIM_EE_SetSensitivity
(
HRTIM1
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EE_SENSITIVITY_LEVEL
);
LL_HRTIM_EE_SetFastMode
(
HRTIM1
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EE_FASTMODE_DISABLE
);
LL_HRTIM_EE_SetSrc
(
HRTIM1
,
LL_HRTIM_EVENT_5
,
LL_HRTIM_EEV5SRC_COMP3_OUT
);
LL_HRTIM_EE_SetPolarity
(
HRTIM1
,
LL_HRTIM_EVENT_5
,
LL_HRTIM_EE_POLARITY_HIGH
);
LL_HRTIM_EE_SetSensitivity
(
HRTIM1
,
LL_HRTIM_EVENT_5
,
LL_HRTIM_EE_SENSITIVITY_LEVEL
);
LL_HRTIM_EE_SetFastMode
(
HRTIM1
,
LL_HRTIM_EVENT_5
,
LL_HRTIM_EE_FASTMODE_DISABLE
);
LL_HRTIM_ConfigADCTrig
(
HRTIM1
,
LL_HRTIM_ADCTRIG_1
,
LL_HRTIM_ADCTRIG_UPDATE_MASTER
,
LL_HRTIM_ADCTRIG_SRC13_MCMP3
);
LL_HRTIM_SetADCPostScaler
(
HRTIM1
,
LL_HRTIM_ADCTRIG_1
,
0
);
LL_HRTIM_TIM_SetPrescaler
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_PRESCALERRATIO_MUL16
);
LL_HRTIM_TIM_SetCounterMode
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_MODE_CONTINUOUS
);
LL_HRTIM_TIM_SetPeriod
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
13600
);
LL_HRTIM_TIM_SetRepetition
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
0x00
);
LL_HRTIM_TIM_DisableHalfMode
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
);
LL_HRTIM_TIM_SetInterleavedMode
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_INTERLEAVED_MODE_DISABLED
);
LL_HRTIM_TIM_DisableStartOnSync
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
);
LL_HRTIM_TIM_DisableResetOnSync
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
);
LL_HRTIM_TIM_SetDACTrig
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_DACTRIG_NONE
);
LL_HRTIM_TIM_DisablePreload
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
);
LL_HRTIM_TIM_SetUpdateGating
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_UPDATEGATING_INDEPENDENT
);
LL_HRTIM_TIM_SetUpdateTrig
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_UPDATETRIG_NONE
);
LL_HRTIM_TIM_SetBurstModeOption
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
LL_HRTIM_BURSTMODE_MAINTAINCLOCK
);
LL_HRTIM_ForceUpdate
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
);
LL_HRTIM_TIM_SetCompare1
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
1360
);
LL_HRTIM_TIM_SetCompare2
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
6800
);
LL_HRTIM_TIM_SetCompare3
(
HRTIM1
,
LL_HRTIM_TIMER_MASTER
,
2700
);
while
(
LL_HRTIM_IsActiveFlag_DLLRDY
(
HRTIM1
)
==
RESET
)
{
// Wait
}
LL_HRTIM_TIM_SetPrescaler
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_PRESCALERRATIO_MUL16
);
LL_HRTIM_TIM_SetCounterMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_MODE_CONTINUOUS
);
LL_HRTIM_TIM_SetPeriod
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
13600
);
LL_HRTIM_TIM_SetRepetition
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
0x00
);
LL_HRTIM_TIM_SetUpdateGating
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_UPDATEGATING_INDEPENDENT
);
LL_HRTIM_TIM_SetCountingMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_COUNTING_MODE_UP
);
LL_HRTIM_TIM_SetTriggeredHalfMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_TRIGHALF_DISABLED
);
LL_HRTIM_TIM_SetComp1Mode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_GTCMP1_EQUAL
);
LL_HRTIM_TIM_SetComp3Mode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_GTCMP3_EQUAL
);
LL_HRTIM_TIM_SetDualDacResetTrigger
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DCDR_COUNTER
);
LL_HRTIM_TIM_SetDualDacStepTrigger
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DCDS_CMP2
);
LL_HRTIM_TIM_EnableDualDacTrigger
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_SetDACTrig
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DACTRIG_NONE
);
LL_HRTIM_TIM_DisableHalfMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_SetInterleavedMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_INTERLEAVED_MODE_DISABLED
);
LL_HRTIM_TIM_DisableStartOnSync
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_DisableResetOnSync
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_DisablePreload
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_DisableResyncUpdate
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_SetUpdateTrig
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_UPDATETRIG_NONE
|
LL_HRTIM_UPDATETRIG_NONE
);
LL_HRTIM_TIM_SetResetTrig
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_RESETTRIG_MASTER_PER
);
LL_HRTIM_TIM_DisablePushPullMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_EnableDeadTime
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_SetBurstModeOption
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_BURSTMODE_MAINTAINCLOCK
);
LL_HRTIM_ForceUpdate
(
HRTIM1
,
LL_HRTIM_TIMER_A
);
LL_HRTIM_TIM_SetCompare1
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
544
);
LL_HRTIM_TIM_SetCompareMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_COMPAREUNIT_2
,
LL_HRTIM_COMPAREMODE_REGULAR
);
LL_HRTIM_TIM_SetCompare2
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
100
);
LL_HRTIM_TIM_SetCompare3
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
1360
);
LL_HRTIM_TIM_SetCompare4
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
10880
);
LL_HRTIM_TIM_SetCompareMode
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_COMPAREUNIT_4
,
LL_HRTIM_COMPAREMODE_REGULAR
);
LL_HRTIM_TIM_SetEventFilter
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EEFLTR_BLANKINGCMP3
);
LL_HRTIM_TIM_SetEventLatchStatus
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_EVENT_4
,
LL_HRTIM_EELATCH_DISABLED
);
LL_HRTIM_DT_SetPrescaler
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DT_PRESCALER_DIV1
);
LL_HRTIM_DT_SetRisingValue
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
16
);
LL_HRTIM_DT_SetRisingSign
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DT_RISING_POSITIVE
);
LL_HRTIM_DT_SetFallingValue
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
16
);
LL_HRTIM_DT_SetFallingSign
(
HRTIM1
,
LL_HRTIM_TIMER_A
,
LL_HRTIM_DT_FALLING_POSITIVE
);
LL_HRTIM_OUT_SetPolarity
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUT_POSITIVE_POLARITY
);
LL_HRTIM_OUT_SetOutputSetSrc
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUTPUTSET_TIMCMP1
);
LL_HRTIM_OUT_SetOutputResetSrc
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUTPUTRESET_TIMCMP4
|
LL_HRTIM_OUTPUTSET_EEV_5
);
LL_HRTIM_OUT_SetIdleMode
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUT_NO_IDLE
);
LL_HRTIM_OUT_SetIdleLevel
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUT_IDLELEVEL_INACTIVE
);
LL_HRTIM_OUT_SetFaultState
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUT_FAULTSTATE_NO_ACTION
);
LL_HRTIM_OUT_SetChopperMode
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA1
,
LL_HRTIM_OUT_CHOPPERMODE_DISABLED
);
LL_HRTIM_OUT_SetPolarity
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUT_POSITIVE_POLARITY
);
LL_HRTIM_OUT_SetOutputSetSrc
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUTPUTSET_NONE
);
LL_HRTIM_OUT_SetOutputResetSrc
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUTPUTRESET_NONE
);
LL_HRTIM_OUT_SetIdleMode
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUT_NO_IDLE
);
LL_HRTIM_OUT_SetIdleLevel
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUT_IDLELEVEL_INACTIVE
);
LL_HRTIM_OUT_SetFaultState
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUT_FAULTSTATE_NO_ACTION
);
LL_HRTIM_OUT_SetChopperMode
(
HRTIM1
,
LL_HRTIM_OUTPUT_TA2
,
LL_HRTIM_OUT_CHOPPERMODE_DISABLED
);
while
(
LL_HRTIM_IsActiveFlag_DLLRDY
(
HRTIM1
)
==
RESET
)
{
// Wait
}
LL_HRTIM_TIM_SetPrescaler
(
HRTIM1
,
LL_HRTIM_TIMER_B
,
LL_HRTIM_PRESCALERRATIO_MUL16
);
LL_HRTIM_TIM_SetCounterMode
(
HRTIM1
,
LL_HRTIM_TIMER_B
,
LL_HRTIM_MODE_CONTINUOUS
);