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
386e1983
Commit
386e1983
authored
Mar 28, 2022
by
Clément Foucher
Browse files
Make DAC driver public interface independent from LL headers.
parent
a998efad
Changes
3
Hide whitespace changes
Inline
Side-by-side
zephyr/modules/owntech_dac_driver/zephyr/public_include/dac.h
View file @
386e1983
...
...
@@ -54,12 +54,24 @@ typedef enum
dac_function_sawtooth
}
dac_function_t
;
typedef
enum
{
dac_polarity_decrement
,
dac_polarity_increment
}
dac_polarity_t
;
typedef
enum
{
hrtim_trig1
,
hrtim_trig2
}
dac_trigger_t
;
typedef
struct
{
dac_function_t
dac_function
;
uint32_t
trigger_source
;
uint32_t
step_trigger_source
;
uint32_t
polarity
;
dac_trigger_t
reset_
trigger_source
;
dac_trigger_t
step_trigger_source
;
dac_polarity_t
polarity
;
uint32_t
reset_data
;
uint32_t
step_data
;
}
dac_function_config_t
;
...
...
@@ -70,7 +82,6 @@ typedef enum
dac_pin_external
}
dac_pin_config_t
;
/////
// API
...
...
zephyr/modules/owntech_dac_driver/zephyr/src/stm32_dac_driver.c
View file @
386e1983
...
...
@@ -109,12 +109,30 @@ static void dac_stm32_set_function(const struct device* dev, uint8_t channel, co
{
data
->
dac_config
->
function_config
=
*
function_config
;
uint32_t
reset_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_RST_TRG1
;
if
(
function_config
->
reset_trigger_source
==
hrtim_trig2
)
{
reset_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_RST_TRG2
;
}
uint32_t
step_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_STEP_TRG1
;
if
(
function_config
->
step_trigger_source
==
hrtim_trig2
)
{
step_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_STEP_TRG2
;
}
uint32_t
polarity
=
LL_DAC_SAWTOOTH_POLARITY_DECREMENT
;
if
(
function_config
->
polarity
==
dac_polarity_increment
)
{
polarity
=
LL_DAC_SAWTOOTH_POLARITY_INCREMENT
;
}
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
);
LL_DAC_SetWaveSawtoothResetTriggerSource
(
dac_dev
,
dac_channel
,
function_config
->
trigger_source
);
LL_DAC_SetWaveSawtoothStepTriggerSource
(
dac_dev
,
dac_channel
,
function_config
->
step_trigger_source
);
LL_DAC_SetWaveSawtoothPolarity
(
dac_dev
,
dac_channel
,
function_config
->
polarity
);
LL_DAC_SetWaveSawtoothResetTriggerSource
(
dac_dev
,
dac_channel
,
reset_
trigger_source
);
LL_DAC_SetWaveSawtoothStepTriggerSource
(
dac_dev
,
dac_channel
,
step_trigger_source
);
LL_DAC_SetWaveSawtoothPolarity
(
dac_dev
,
dac_channel
,
polarity
);
LL_DAC_SetWaveSawtoothResetData
(
dac_dev
,
dac_channel
,
function_config
->
reset_data
);
LL_DAC_SetWaveSawtoothStepData
(
dac_dev
,
dac_channel
,
function_config
->
step_data
);
...
...
zephyr/modules/owntech_hardware_configuration/zephyr/src/dac_configuration.cpp
View file @
386e1983
...
...
@@ -19,6 +19,7 @@
/**
* @date 2022
*
* @author Clément Foucher <clement.foucher@laas.fr>
*/
...
...
@@ -26,37 +27,33 @@
// Zephyr
#include <zephyr.h>
// STM32LL
#include <stm32_ll_dac.h>
// Owntech driver
#include "dac.h"
void
dac_config_dac1_dac3_current_mode_init
()
{
const
struct
device
*
dac1
=
device_get_binding
(
DAC1_DEVICE
);
const
struct
device
*
dac3
=
device_get_binding
(
DAC3_DEVICE
);
// DAC 1
dac_function_config_t
function_config
=
{
.
dac_function
=
dac_function_sawtooth
,
.
trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_RST_TRG
1
,
.
step_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_STEP_TRG
1
,
.
polarity
=
LL_DAC_SAWTOOTH_POLARITY_DECREMENT
,
.
reset_
trigger_source
=
hrtim_trig
1
,
.
step_trigger_source
=
hrtim_trig
1
,
.
polarity
=
dac_polarity_decrement
,
.
reset_data
=
4000
,
.
step_data
=
200
};
// DAC 1
dac_set_function
(
dac1
,
1
,
&
function_config
);
dac_pin_configure
(
dac1
,
1
,
dac_pin_internal
);
dac_start
(
dac1
,
1
);
// DAC 3
function_config
.
trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_RST_TRG
2
;
function_config
.
step_trigger_source
=
LL_DAC_TRIG_EXT_HRTIM_STEP_TRG
2
;
function_config
.
reset_
trigger_source
=
hrtim_trig
2
;
function_config
.
step_trigger_source
=
hrtim_trig
2
;
dac_set_function
(
dac3
,
1
,
&
function_config
);
dac_pin_configure
(
dac3
,
1
,
dac_pin_internal
);
...
...
Clément Foucher
@cfoucher
mentioned in issue
#25 (closed)
·
Mar 29, 2022
mentioned in issue
#25 (closed)
mentioned in issue #25
Toggle commit list
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