[bsp/at32] add support dac driver

This commit is contained in:
sheltonyu
2023-04-18 17:16:57 +08:00
committed by guo
parent a25d3fd301
commit 8612d5e119
26 changed files with 499 additions and 5 deletions
+3
View File
@@ -43,6 +43,7 @@ AT32F403A-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| IIC | 支持 | GPIO模拟I2C |
| SPI | 支持 | SPI1/2 |
| ADC | 支持 | ADC1/2 |
| DAC | 支持 | DAC1 |
| PWM | 支持 | TMR1/2 |
| HWTIMER | 支持 | TMR3/4/5 |
| SDIO | 支持 | SDIO1 |
@@ -91,6 +92,8 @@ AT32F403A-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC3 | ADC1/2_IN13 |
| PC4 | ADC1/2_IN14 |
| PC5 | ADC1/2_IN15 |
| PA4 | DAC_OUT1 |
| PA5 | DAC_OUT2 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
+10
View File
@@ -278,6 +278,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_CAN
bool "Enable CAN"
default n
@@ -20,5 +20,6 @@ void at32_msp_adc_init(void *instance);
void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_usb_init(void *instance);
void at32_msp_dac_init(void *instance);
#endif /* __AT32_MSP_H__ */
+25 -1
View File
@@ -381,5 +381,29 @@ void at32_msp_usb_init(void *instance)
}
}
}
#endif /* BSP_USING_USBD */
#ifdef BSP_USING_DAC
void at32_msp_dac_init(void *instance)
{
gpio_init_type gpio_init_struct;
dac_type *dac_x = (dac_type *)instance;
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
#ifdef BSP_USING_DAC1
if(dac_x == DAC)
{
/* dac & gpio clock enable */
crm_periph_clock_enable(CRM_DAC_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
/* configure adc channel as analog output */
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init(GPIOA, &gpio_init_struct);
}
#endif
}
#endif /* BSP_USING_DAC */
+3
View File
@@ -43,6 +43,7 @@ AT32F407-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| IIC | 支持 | GPIO模拟I2C |
| SPI | 支持 | SPI1/2 |
| ADC | 支持 | ADC1/2 |
| DAC | 支持 | DAC1 |
| PWM | 支持 | TMR1/2 |
| HWTIMER | 支持 | TMR3/4/5 |
| SDIO | 支持 | SDIO1 |
@@ -92,6 +93,8 @@ AT32F407-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC3 | ADC1/2_IN13 |
| PC4 | ADC1/2_IN14 |
| PC5 | ADC1/2_IN15 |
| PA4 | DAC_OUT1 |
| PA5 | DAC_OUT2 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
+10
View File
@@ -295,6 +295,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_CAN
bool "Enable CAN"
default n
@@ -21,5 +21,6 @@ void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_emac_init(void *instance);
void at32_msp_usb_init(void *instance);
void at32_msp_dac_init(void *instance);
#endif /* __AT32_MSP_H__ */
+24 -1
View File
@@ -422,6 +422,29 @@ void at32_msp_usb_init(void *instance)
}
}
}
#endif /* BSP_USING_USBD */
#ifdef BSP_USING_DAC
void at32_msp_dac_init(void *instance)
{
gpio_init_type gpio_init_struct;
dac_type *dac_x = (dac_type *)instance;
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
#ifdef BSP_USING_DAC1
if(dac_x == DAC)
{
/* dac & gpio clock enable */
crm_periph_clock_enable(CRM_DAC_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
/* configure adc channel as analog output */
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init(GPIOA, &gpio_init_struct);
}
#endif
}
#endif /* BSP_USING_DAC */
+3
View File
@@ -43,6 +43,7 @@ AT32F423-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| IIC | 支持 | GPIO模拟I2C |
| SPI | 支持 | SPI1/2 |
| ADC | 支持 | ADC1 |
| DAC | 支持 | DAC1 |
| PWM | 支持 | TMR1/2 |
| HWTIMER | 支持 | TMR3 |
| CAN | 支持 | CAN1/2 |
@@ -84,6 +85,8 @@ AT32F423-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC3 | ADC1_IN13 |
| PC4 | ADC1_IN14 |
| PC5 | ADC1_IN15 |
| PA4 | DAC_OUT1 |
| PA5 | DAC_OUT2 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
+10
View File
@@ -287,6 +287,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_CAN
bool "Enable CAN"
default n
@@ -18,5 +18,6 @@ void at32_msp_adc_init(void *instance);
void at32_msp_hwtmr_init(void *instance);
void at32_msp_can_init(void *instance);
void at32_msp_usb_init(void *instance);
void at32_msp_dac_init(void *instance);
#endif /* __AT32_MSP_H__ */
+25 -1
View File
@@ -316,5 +316,29 @@ void at32_msp_usb_init(void *instance)
}
}
}
#endif /* BSP_USING_USBFS */
#ifdef BSP_USING_DAC
void at32_msp_dac_init(void *instance)
{
gpio_init_type gpio_init_struct;
dac_type *dac_x = (dac_type *)instance;
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
#ifdef BSP_USING_DAC1
if(dac_x == DAC)
{
/* dac & gpio clock enable */
crm_periph_clock_enable(CRM_DAC_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
/* configure adc channel as analog output */
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init(GPIOA, &gpio_init_struct);
}
#endif
}
#endif /* BSP_USING_DAC */
+3
View File
@@ -43,6 +43,7 @@ AT32F437-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| IIC | 支持 | GPIO模拟I2C |
| SPI | 支持 | SPI1/2 |
| ADC | 支持 | ADC1/2 |
| DAC | 支持 | DAC1 |
| PWM | 支持 | TMR1/2 |
| HWTIMER | 支持 | TMR3/4/5 |
| SDIO | 支持 | SDIO1 |
@@ -93,6 +94,8 @@ AT32F437-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC3 | ADC1/2_IN13 |
| PC4 | ADC1/2_IN14 |
| PC5 | ADC1/2_IN15 |
| PA4 | DAC_OUT1 |
| PA5 | DAC_OUT2 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
+10
View File
@@ -327,6 +327,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_CAN
bool "Enable CAN"
default n
@@ -22,5 +22,6 @@ void at32_msp_can_init(void *instance);
void at32_msp_qspi_init(void *instance);
void at32_msp_sdram_init(void *instance);
void at32_msp_usb_init(void *instance);
void at32_msp_dac_init(void *instance);
#endif /* __AT32_MSP_H__ */
+25 -1
View File
@@ -570,5 +570,29 @@ void at32_msp_usb_init(void *instance)
}
}
}
#endif /* BSP_USING_USBFS */
#ifdef BSP_USING_DAC
void at32_msp_dac_init(void *instance)
{
gpio_init_type gpio_init_struct;
dac_type *dac_x = (dac_type *)instance;
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
#ifdef BSP_USING_DAC1
if(dac_x == DAC)
{
/* dac & gpio clock enable */
crm_periph_clock_enable(CRM_DAC_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
/* configure adc channel as analog output */
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init(GPIOA, &gpio_init_struct);
}
#endif
}
#endif /* BSP_USING_DAC */
+3
View File
@@ -43,6 +43,7 @@ AT32F437-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| IIC | 支持 | GPIO模拟I2C |
| SPI | 支持 | SPI1/2 |
| ADC | 支持 | ADC1/2 |
| DAC | 支持 | DAC1 |
| PWM | 支持 | TMR1/2 |
| HWTIMER | 支持 | TMR3/4/5 |
| SDIO | 支持 | SDIO1 |
@@ -94,6 +95,8 @@ AT32F437-START板级包支持MDK4﹑MDK5﹑IAR开发环境和GCC编译器,以
| PC3 | ADC1/2_IN13 |
| PC4 | ADC1/2_IN14 |
| PC5 | ADC1/2_IN15 |
| PA4 | DAC_OUT1 |
| PA5 | DAC_OUT2 |
| PB8 | CAN1_RX |
| PB9 | CAN1_TX |
| PB5 | CAN2_RX |
+10
View File
@@ -344,6 +344,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_CAN
bool "Enable CAN"
default n
@@ -23,5 +23,6 @@ void at32_msp_qspi_init(void *instance);
void at32_msp_sdram_init(void *instance);
void at32_msp_emac_init(void *instance);
void at32_msp_usb_init(void *instance);
void at32_msp_dac_init(void *instance);
#endif /* __AT32_MSP_H__ */
+25 -1
View File
@@ -610,5 +610,29 @@ void at32_msp_usb_init(void *instance)
}
}
}
#endif /* BSP_USING_USBFS */
#ifdef BSP_USING_DAC
void at32_msp_dac_init(void *instance)
{
gpio_init_type gpio_init_struct;
dac_type *dac_x = (dac_type *)instance;
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
#ifdef BSP_USING_DAC1
if(dac_x == DAC)
{
/* dac & gpio clock enable */
crm_periph_clock_enable(CRM_DAC_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
/* configure adc channel as analog output */
gpio_init_struct.gpio_pins = GPIO_PINS_4 | GPIO_PINS_5;
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init(GPIOA, &gpio_init_struct);
}
#endif
}
#endif /* BSP_USING_DAC */
+3
View File
@@ -47,6 +47,9 @@ if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
if GetDepend(['BSP_USING_ADC']):
src += Glob('drv_adc.c')
if GetDepend(['BSP_USING_DAC']):
src += Glob('drv_dac.c')
if GetDepend('BSP_USING_RTC'):
src += ['drv_rtc.c']
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-04-18 shelton first version
*/
#ifndef __DAC_CONFIG_H__
#define __DAC_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_DAC1)
#define DAC1_CONFIG \
{ \
.name = "dac1", \
.dac_x = DAC, \
}
#endif /* BSP_USING_DAC1 */
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-04-18 shelton first version
*/
#ifndef __DAC_CONFIG_H__
#define __DAC_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_DAC1)
#define DAC1_CONFIG \
{ \
.name = "dac1", \
.dac_x = DAC, \
}
#endif /* BSP_USING_DAC1 */
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-04-18 shelton first version
*/
#ifndef __DAC_CONFIG_H__
#define __DAC_CONFIG_H__
#include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_DAC1)
#define DAC1_CONFIG \
{ \
.name = "dac1", \
.dac_x = DAC, \
}
#endif /* BSP_USING_DAC1 */
#ifdef __cplusplus
}
#endif
#endif
@@ -25,6 +25,7 @@ extern "C" {
#include "f403a_407/uart_config.h"
#include "f403a_407/spi_config.h"
#include "f403a_407/usb_config.h"
#include "f403a_407/dac_config.h"
#elif defined(SOC_SERIES_AT32F413)
#include "f413/dma_config.h"
#include "f413/uart_config.h"
@@ -44,6 +45,7 @@ extern "C" {
#include "f423/uart_config.h"
#include "f423/spi_config.h"
#include "f423/usb_config.h"
#include "f423/dac_config.h"
#elif defined(SOC_SERIES_AT32F425)
#include "f425/dma_config.h"
#include "f425/uart_config.h"
@@ -54,6 +56,7 @@ extern "C" {
#include "f435_437/uart_config.h"
#include "f435_437/spi_config.h"
#include "f435_437/usb_config.h"
#include "f435_437/dac_config.h"
#endif
#ifdef __cplusplus
File diff suppressed because it is too large Load Diff