Skip to content

Commit

Permalink
Merge #19886 #19892
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


19892: pkg/tinydtls: allow to set buffer size from application again r=benpicco a=leandrolanzieri

### Contribution description

Currently the buffer size on tinydtls is set in its Makefile whenever `gcoap` module is present. This limits the ability of the user to override the value. This adds a pre-check of the `CFLAGS` to see if it was set before.

### Testing procedure

Try setting `CFLAGS += -DDTLS_MAX_BUF=<some_value>` on `examples/gcoap_dtls`, you should be able to override the default value without errors.


### Issues/PRs references
Reported in #19838


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
  • Loading branch information
3 people authored Aug 23, 2023
3 parents 09c8496 + 559381c + e65f1c4 commit 35e69c6
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 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
15 changes: 0 additions & 15 deletions pkg/tinydtls/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ ifeq (llvm,$(TOOLCHAIN))
CFLAGS += -Wno-format-nonliteral
endif

ifneq (,$(filter gcoap,$(USEMODULE)))
# Configuring the buffer large enough that a full Gcoap packet can be
# encrypted or decrypted.

# This is the default in gcoap.h, which we don't have access to, so it is copied over.
CONFIG_GCOAP_PDU_BUF_SIZE := $(or $(CONFIG_GCOAP_PDU_BUF_SIZE),128)

# If there were another way to set up DTLS_MAX_BUF, we'd need to set the
# maximum of these here.
#
# 29 bytes are the overhead measured with Wireshark on packets exchanged in
# default configuration; adding some to be safe against variable size fields.
CFLAGS += "-DDTLS_MAX_BUF=($(CONFIG_GCOAP_PDU_BUF_SIZE) + 36)"
endif

# TinyDTLS emits several messages during connection establishment at the info
# level; this is way more verbose than common in RIOT.
TINYDTLS_LOG_LEVEL ?= LOG_WARNING
Expand Down
3 changes: 3 additions & 0 deletions pkg/tinydtls/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ HANDSHAKE_MAX := $(or $(CONFIG_DTLS_HANDSHAKE_MAX),$(patsubst -DCONFIG_DTLS_HAND
ifneq (,$(HANDSHAKE_MAX))
CFLAGS += -DDTLS_HANDSHAKE_MAX=$(HANDSHAKE_MAX)
endif

DTLS_MAX_BUF ?= 200
CFLAGS += "-DDTLS_MAX_BUF=$(DTLS_MAX_BUF)"
4 changes: 4 additions & 0 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,7 @@ endif
ifneq (,$(filter gcoap,$(USEMODULE)))
include $(RIOTBASE)/sys/net/application_layer/gcoap/Makefile.include
endif

ifneq (,$(filter nanocoap,$(USEMODULE)))
include $(RIOTBASE)/sys/net/application_layer/nanocoap/Makefile.include
endif
3 changes: 3 additions & 0 deletions sys/net/application_layer/gcoap/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ ifeq (2, $(words $(filter ipv4 ipv6, $(USEMODULE))))
$(shell $(COLOR_ECHO) "$(COLOR_YELLOW)Due to limitations in the gcoap API it is currently not \
possible to use a dual stack setup$(COLOR_RESET)" 1>&2)
endif

CONFIG_GCOAP_PDU_BUF_SIZE := $(or $(CONFIG_GCOAP_PDU_BUF_SIZE),128)
DTLS_MAX_BUF ?= ($(CONFIG_GCOAP_PDU_BUF_SIZE) + 36)
4 changes: 4 additions & 0 deletions sys/net/application_layer/nanocoap/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ifneq (,$(filter nanocoap_dtls,$(USEMODULE)))
CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT := $(or $(CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT),2)
DTLS_MAX_BUF ?= ((1 << ($(CONFIG_NANOCOAP_BLOCKSIZE_DEFAULT) + 3)) + 36)
endif

0 comments on commit 35e69c6

Please sign in to comment.