mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-24 12:59:42 +08:00
Merge pull request #4037 from KyleChenjh/master
add dac driver for stm32l4
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-06-16 thread-liu first version
|
||||
*/
|
||||
|
||||
#ifndef __DAC_CONFIG_H__
|
||||
#define __DAC_CONFIG_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_DAC1
|
||||
#ifndef DAC1_CONFIG
|
||||
#define DAC1_CONFIG \
|
||||
{ \
|
||||
.Instance = DAC1, \
|
||||
}
|
||||
#endif /* DAC2_CONFIG */
|
||||
#endif /* BSP_USING_DAC2 */
|
||||
|
||||
#ifdef BSP_USING_DAC2
|
||||
#ifndef DAC2_CONFIG
|
||||
#define DAC2_CONFIG \
|
||||
{ \
|
||||
.Instance = DAC2, \
|
||||
}
|
||||
#endif /* DAC2_CONFIG */
|
||||
#endif /* BSP_USING_DAC2 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DAC_CONFIG_H__ */
|
||||
@@ -73,6 +73,7 @@ extern "C" {
|
||||
#include "l4/spi_config.h"
|
||||
#include "l4/qspi_config.h"
|
||||
#include "l4/adc_config.h"
|
||||
#include "l4/dac_config.h"
|
||||
#include "l4/tim_config.h"
|
||||
#include "l4/sdio_config.h"
|
||||
#include "l4/pwm_config.h"
|
||||
|
||||
@@ -43,7 +43,7 @@ static rt_err_t stm32_dac_enabled(struct rt_dac_device *device, rt_uint32_t chan
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
stm32_dac_handler = device->parent.user_data;
|
||||
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
|
||||
HAL_DAC_Start(stm32_dac_handler, channel);
|
||||
#endif
|
||||
|
||||
@@ -56,7 +56,7 @@ static rt_err_t stm32_dac_disabled(struct rt_dac_device *device, rt_uint32_t cha
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
stm32_dac_handler = device->parent.user_data;
|
||||
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
|
||||
HAL_DAC_Stop(stm32_dac_handler, channel);
|
||||
#endif
|
||||
|
||||
@@ -96,7 +96,7 @@ static rt_err_t stm32_set_dac_value(struct rt_dac_device *device, rt_uint32_t ch
|
||||
|
||||
rt_memset(&DAC_ChanConf, 0, sizeof(DAC_ChanConf));
|
||||
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
|
||||
if ((channel <= 2) && (channel > 0))
|
||||
{
|
||||
/* 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
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7)
|
||||
#if defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32L4)
|
||||
DAC_ChanConf.DAC_Trigger = DAC_TRIGGER_NONE;
|
||||
DAC_ChanConf.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
|
||||
#endif
|
||||
|
||||
@@ -59,6 +59,10 @@ if GetDepend(['RT_USING_ADC']):
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c']
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c']
|
||||
|
||||
if GetDepend(['RT_USING_DAC']):
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c']
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c']
|
||||
|
||||
if GetDepend(['RT_USING_RTC']):
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rtc.c']
|
||||
src += ['STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rtc_ex.c']
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -77,7 +77,7 @@ extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
|
||||
@@ -308,6 +308,16 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_DAC
|
||||
bool "Enable DAC"
|
||||
default n
|
||||
select RT_USING_DAC
|
||||
if BSP_USING_DAC
|
||||
config BSP_USING_DAC1
|
||||
bool "Enable DAC1"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_ONCHIP_RTC
|
||||
bool "Enable RTC"
|
||||
select RT_USING_RTC
|
||||
|
||||
Reference in New Issue
Block a user