Skip to content

Commit df3d4b7

Browse files
authored
Merge pull request #4037 from KyleChenjh/master
add dac driver for stm32l4
2 parents d7c367d + 3fa1f52 commit df3d4b7

File tree

12 files changed

+736
-535
lines changed

12 files changed

+736
-535
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-06-16 thread-liu first version
9+
*/
10+
11+
#ifndef __DAC_CONFIG_H__
12+
#define __DAC_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#ifdef BSP_USING_DAC1
21+
#ifndef DAC1_CONFIG
22+
#define DAC1_CONFIG \
23+
{ \
24+
.Instance = DAC1, \
25+
}
26+
#endif /* DAC2_CONFIG */
27+
#endif /* BSP_USING_DAC2 */
28+
29+
#ifdef BSP_USING_DAC2
30+
#ifndef DAC2_CONFIG
31+
#define DAC2_CONFIG \
32+
{ \
33+
.Instance = DAC2, \
34+
}
35+
#endif /* DAC2_CONFIG */
36+
#endif /* BSP_USING_DAC2 */
37+
38+
#ifdef __cplusplus
39+
}
40+
#endif
41+
42+
#endif /* __DAC_CONFIG_H__ */

bsp/stm32/libraries/HAL_Drivers/drv_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extern "C" {
7373
#include "l4/spi_config.h"
7474
#include "l4/qspi_config.h"
7575
#include "l4/adc_config.h"
76+
#include "l4/dac_config.h"
7677
#include "l4/tim_config.h"
7778
#include "l4/sdio_config.h"
7879
#include "l4/pwm_config.h"

bsp/stm32/libraries/HAL_Drivers/drv_dac.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static rt_err_t stm32_dac_enabled(struct rt_dac_device *device, rt_uint32_t chan
4343
RT_ASSERT(device != RT_NULL);
4444
stm32_dac_handler = device->parent.user_data;
4545

46-
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
46+
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
4747
HAL_DAC_Start(stm32_dac_handler, channel);
4848
#endif
4949

@@ -56,7 +56,7 @@ static rt_err_t stm32_dac_disabled(struct rt_dac_device *device, rt_uint32_t cha
5656
RT_ASSERT(device != RT_NULL);
5757
stm32_dac_handler = device->parent.user_data;
5858

59-
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
59+
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
6060
HAL_DAC_Stop(stm32_dac_handler, channel);
6161
#endif
6262

@@ -96,7 +96,7 @@ static rt_err_t stm32_set_dac_value(struct rt_dac_device *device, rt_uint32_t ch
9696

9797
rt_memset(&DAC_ChanConf, 0, sizeof(DAC_ChanConf));
9898

99-
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
99+
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
100100
if ((channel <= 2) && (channel > 0))
101101
{
102102
/* set stm32 dac channel */
@@ -109,7 +109,7 @@ static rt_err_t stm32_set_dac_value(struct rt_dac_device *device, rt_uint32_t ch
109109
}
110110
#endif
111111

112-
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
112+
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
113113
DAC_ChanConf.DAC_Trigger = DAC_TRIGGER_NONE;
114114
DAC_ChanConf.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
115115
#endif

bsp/stm32/libraries/STM32L4xx_HAL/SConscript

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ if GetDepend(['RT_USING_ADC']):
5959
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c']
6060
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c']
6161

62+
if GetDepend(['RT_USING_DAC']):
63+
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c']
64+
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c']
65+
6266
if GetDepend(['RT_USING_RTC']):
6367
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rtc.c']
6468
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rtc_ex.c']

bsp/stm32/stm32l475-atk-pandora/board/CubeMX_Config/.mxproject

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)