Skip to content

Commit

Permalink
Merge #19886
Browse files Browse the repository at this point in the history
19886: cpu/efm32: fix DAC configuration r=benpicco a=gschorcht

### Contribution description

The EFM32 MCU allows the reference voltage to be configured per DAC device, not per DAC channel. Also, the DAC reference voltage was defined in the configuration but not used anywhere.

At the moment we have only defined one board (`stwstk6220a`) that uses the DAC, so changing the configuration interface shouldn't be critical.

### Testing procedure

`tests/periph/dac` should still work for the `stwstk6220a`
```
BOARD=slwstk6220a make -j8 -C tests/periph/dac flash
```
I don't have a `stwstk6220a` board (EFM32 Series 0) so that I can't test it. I could only test it for the `sltb009a` board (EFM32 Series 1) with the change for VDAC in PR #19887.

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
  • Loading branch information
bors[bot] and gschorcht authored Aug 23, 2023
2 parents 09c8496 + 559381c commit eed5022
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion boards/slwstk6220a/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ static const dac_conf_t dac_config[] = {
{
.dev = DAC0,
.cmu = cmuClock_DAC0,
.ref = dacRefVDD,
}
};

static const dac_chan_conf_t dac_channel_config[] = {
{
.dev = 0,
.index = 1,
.ref = dacRefVDD,
}
};

Expand Down
2 changes: 1 addition & 1 deletion boards/stk3600/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ static const dac_conf_t dac_config[] = {
{
.dev = DAC0,
.cmu = cmuClock_DAC0,
.ref = dacRefVDD,
}
};

static const dac_chan_conf_t dac_channel_config[] = {
{
.dev = 0,
.index = 1,
.ref = dacRefVDD,
}
};

Expand Down
2 changes: 1 addition & 1 deletion boards/stk3700/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ static const dac_conf_t dac_config[] = {
{
.dev = DAC0,
.cmu = cmuClock_DAC0,
.ref = dacRefVDD,
}
};

static const dac_chan_conf_t dac_channel_config[] = {
{
.dev = 0,
.index = 1,
.ref = dacRefVDD,
}
};

Expand Down
2 changes: 1 addition & 1 deletion cpu/efm32/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef struct {
*/
typedef struct {
DAC_TypeDef *dev; /**< DAC device used */
DAC_Ref_TypeDef ref; /**< DAC voltage reference */
CMU_Clock_TypeDef cmu; /**< the device CMU channel */
} dac_conf_t;

Expand All @@ -88,7 +89,6 @@ typedef struct {
typedef struct {
uint8_t dev; /**< device index */
uint8_t index; /**< channel index */
DAC_Ref_TypeDef ref; /**< channel voltage reference */
} dac_chan_conf_t;
#endif

Expand Down
1 change: 1 addition & 0 deletions cpu/efm32/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int8_t dac_init(dac_t line)
/* reset and initialize peripheral */
DAC_Init_TypeDef init = DAC_INIT_DEFAULT;

init.reference = dac_config[dev].ref;
DAC_Reset(dac_config[dev].dev);
DAC_Init(dac_config[dev].dev, &init);

Expand Down

0 comments on commit eed5022

Please sign in to comment.