1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00
19887: cpu/efm32/periph: add DAC support for EFM32 Series 1 (VDAC) r=aabadie a=gschorcht

### Contribution description

This PR provides a small change for `periph_dac` to support the VDACs of EFM32 Series 1 MCUs. It was tested with `sltb009a` board for which this PR includes the DAC configuration.

### Testing procedure

`tests/periph/dac` should work for the `sltb009a` board. I've tested it already.
```
BOARD=sltb009a make -j8 -C tests/periph/dac flash
```

### Issues/PRs references

Depends on PR #19886 

19898: tests/net/gcoap_fileserver: disable test on CI r=aabadie a=benpicco




Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
This commit is contained in:
bors[bot] 2023-08-30 17:35:08 +00:00 committed by GitHub
commit 26cb4db130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 3 deletions

View File

@ -13,6 +13,7 @@ config BOARD_SLTB009A
select BOARD_COMMON_SILABS
select CPU_MODEL_EFM32GG12B810F1024GM64
select HAS_PERIPH_ADC
select HAS_PERIPH_DAC
select HAS_PERIPH_I2C
select HAS_PERIPH_RTC
select HAS_PERIPH_RTT

View File

@ -4,6 +4,7 @@ CPU_MODEL = efm32gg12b810f1024gm64
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_dac
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_rtt

View File

@ -80,6 +80,29 @@ static const adc_chan_conf_t adc_channel_config[] = {
#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
/** @} */
/**
* @name DAC configuration
* @{
*/
static const dac_conf_t dac_config[] = {
{
.dev = VDAC0,
.ref = vdacRefAvdd,
.cmu = cmuClock_VDAC0,
},
};
static const dac_chan_conf_t dac_channel_config[] = {
{
.dev = 0,
.index = 0,
},
};
#define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
#define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
/** @} */
/**
* @name I2C configuration
* @{

View File

@ -29,6 +29,7 @@
******************************************************************************/
#include <stdint.h>
#include "periph_conf.h"
#include "em_device.h"
/*******************************************************************************

View File

@ -40,6 +40,8 @@
#include "em_rtc.h"
#if defined(_SILICON_LABS_32B_SERIES_0)
#include "em_dac.h"
#elif defined (_SILICON_LABS_32B_SERIES_1) || defined(_SILICON_LABS_32B_SERIES_2)
#include "em_vdac.h"
#endif
#ifdef __cplusplus
@ -90,6 +92,24 @@ typedef struct {
uint8_t dev; /**< device index */
uint8_t index; /**< channel index */
} dac_chan_conf_t;
#elif defined(VDAC_COUNT) && VDAC_COUNT > 0
/**
* @brief DAC device configuration (VDAC configuration of EFM32 Series 1)
*/
typedef struct {
VDAC_TypeDef *dev; /**< DAC device used */
VDAC_Ref_TypeDef ref; /**< DAC voltage reference */
CMU_Clock_TypeDef cmu; /**< the device CMU channel */
} dac_conf_t;
/**
* @brief DAC channel configuration (VDAC configuration of EFM32 Series 1)
*/
typedef struct {
uint8_t dev; /**< device index */
uint8_t index; /**< channel index */
} dac_chan_conf_t;
#endif
/**

View File

@ -20,6 +20,7 @@
*/
#include "cpu.h"
#include "macros/units.h"
#include "periph_conf.h"
#include "periph/dac.h"
@ -27,6 +28,23 @@
#include "em_cmu.h"
#if defined(DAC_COUNT) && DAC_COUNT > 0
#include "em_dac.h"
#elif defined(VDAC_COUNT) && VDAC_COUNT > 0
#include "em_vdac.h"
#endif
/* DAC implementation can be used for VDAC by mapping the symbols */
#if defined(VDAC_COUNT) && VDAC_COUNT > 0
#define DAC_INIT_DEFAULT VDAC_INIT_DEFAULT
#define DAC_INITCHANNEL_DEFAULT VDAC_INITCHANNEL_DEFAULT
#define DAC_Init_TypeDef VDAC_Init_TypeDef
#define DAC_InitChannel_TypeDef VDAC_InitChannel_TypeDef
#define DAC_Reset VDAC_Reset
#define DAC_Init VDAC_Init
#define DAC_InitChannel VDAC_InitChannel
#define DAC_ChannelOutputSet VDAC_ChannelOutputSet
#endif
int8_t dac_init(dac_t line)
@ -45,7 +63,11 @@ int8_t dac_init(dac_t line)
/* reset and initialize peripheral */
DAC_Init_TypeDef init = DAC_INIT_DEFAULT;
#if defined(VDAC_COUNT)
init.reference = dac_config[dev].ref;
init.prescaler = VDAC_PrescaleCalc(MHZ(1000000), true, 0);
#endif
DAC_Reset(dac_config[dev].dev);
DAC_Init(dac_config[dev].dev, &init);

View File

@ -21,10 +21,12 @@ USEMODULE += vfs_auto_format
USEMODULE += hashes
USEMODULE += shell_cmd_md5sum
# This integration test uncovers a bug somwehere in our stack, but there
# are currently no resources to debug it, so blacklist it to keep CI running
TEST_ON_CI_BLACKLIST += all
# automated test only works on native
TEST_ON_CI_WHITELIST += native
# FIXME: for some reason the test fails very often when built with clang
TOOLCHAINS_BLACKLIST += llvm
# TEST_ON_CI_WHITELIST += native
# use small blocksize for test to increase chance for errors
CFLAGS += -DCONFIG_NANOCOAP_BLOCKSIZE_DEFAULT=COAP_BLOCKSIZE_16