mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #12053 from maribu/cc110x_default_channel
drivers/cc110x: Default channel configuration
This commit is contained in:
commit
741d5437a7
@ -44,13 +44,18 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
|
||||
}
|
||||
|
||||
int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf,
|
||||
const cc110x_chanmap_t *chanmap)
|
||||
const cc110x_chanmap_t *chanmap, uint8_t channel)
|
||||
{
|
||||
DEBUG("[cc110x] Applying new configuration\n");
|
||||
if (!dev || !chanmap) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((channel >= CC110X_MAX_CHANNELS) || (chanmap->map[channel] == 0xff)) {
|
||||
/* Channel out of range or not supported in current channel map */
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
if (cc110x_acquire(dev) != SPI_OK) {
|
||||
return -EIO;
|
||||
}
|
||||
@ -72,11 +77,10 @@ int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf,
|
||||
cc110x_write(dev, CC110X_REG_DEVIATN, conf->deviatn);
|
||||
}
|
||||
|
||||
/* Set current channel to zero, as the new map might not support the current
|
||||
* virtual channel number. cc110x_full_calibration() will tune in that
|
||||
* channel after calibration.
|
||||
/* We only need to store the channel, cc110x_full_calibration() will tune it
|
||||
* in after calibration.
|
||||
*/
|
||||
dev->channel = 0;
|
||||
dev->channel = channel;
|
||||
dev->channels = chanmap;
|
||||
cc110x_release(dev);
|
||||
|
||||
|
@ -347,19 +347,18 @@ static int cc110x_init(netdev_t *netdev)
|
||||
/* Apply configuration (if non-NULL) and channel map, which also calls
|
||||
* cc110x_full_calibration
|
||||
*/
|
||||
retval = cc110x_apply_config(dev, dev->params.config, dev->params.channels);
|
||||
retval = cc110x_apply_config(dev, dev->params.config, dev->params.channels,
|
||||
CC110X_DEFAULT_CHANNEL);
|
||||
if (retval) {
|
||||
gpio_irq_disable(dev->params.gdo0);
|
||||
gpio_irq_disable(dev->params.gdo2);
|
||||
DEBUG("[cc110x] netdev_driver_t::init(): cc110x_apply_config() "
|
||||
"failed\n");
|
||||
/* Pass through received error code */
|
||||
/* Pass through received error code */
|
||||
return retval;
|
||||
}
|
||||
else {
|
||||
DEBUG("[cc110x] netdev_driver_t::init(): Success\n");
|
||||
}
|
||||
|
||||
DEBUG("[cc110x] netdev_driver_t::init(): Success\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,13 @@ extern "C" {
|
||||
#define CC110X_DEFAULT_PROTOCOL (GNRC_NETTYPE_UNDEF)
|
||||
#endif
|
||||
|
||||
#ifndef CC110X_DEFAULT_CHANNEL
|
||||
/**
|
||||
* @brief The default channel to set up after initializing the device
|
||||
*/
|
||||
#define CC110X_DEFAULT_CHANNEL (0U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The state of the CC1100/CC1101 transceiver
|
||||
*
|
||||
@ -558,10 +565,12 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params);
|
||||
* @param dev Device descriptor of the transceiver
|
||||
* @param conf Configuration to apply or `NULL` to only change channel map
|
||||
* @param chanmap Channel map to apply (must be compatible with @p conf)
|
||||
* @param channel The channel to tune in after applying the config
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval -EINVAL Called with invalid argument
|
||||
* @retval -EIO Communication with the transceiver failed
|
||||
* @retval -ERANGE Channel out of range or not supported by channel map
|
||||
*
|
||||
* @pre The application developer checked in the documentation that the
|
||||
* channel map in @p chanmap is compatible with the configuration in
|
||||
@ -574,7 +583,7 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params);
|
||||
* @ref cc110x_full_calibration is called to update it.
|
||||
*/
|
||||
int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf,
|
||||
const cc110x_chanmap_t *chanmap);
|
||||
const cc110x_chanmap_t *chanmap, uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Perform a calibration of the frequency generator for each supported
|
||||
|
@ -71,10 +71,4 @@ endif
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -116,10 +116,4 @@ host-tools:
|
||||
$(Q)env -u CC -u CFLAGS make -C $(RIOTTOOLS)
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -36,10 +36,4 @@ QUIET ?= 1
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -65,10 +65,4 @@ QUIET ?= 1
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -60,6 +60,5 @@ QUIET ?= 1
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
# Set a custom channel if needed
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -49,3 +49,6 @@ DEVELHELP ?= 1
|
||||
QUIET ?= 1
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -61,10 +61,4 @@ QUIET ?= 1
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
13
makefiles/default-channel.inc.mk
Normal file
13
makefiles/default-channel.inc.mk
Normal file
@ -0,0 +1,13 @@
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter cc110x,$(USEMODULE))) # radio is cc110x sub-GHz
|
||||
DEFAULT_CHANNEL ?= 0
|
||||
CFLAGS += -DCC110X_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
endif
|
@ -42,8 +42,7 @@ USEMODULE += gnrc_gomach
|
||||
# reduce the size of the packet buffer a bit
|
||||
CFLAGS += -DGNRC_PKTBUF_SIZE=1024
|
||||
|
||||
# Set a custom channel if needed
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -34,8 +34,7 @@ USEMODULE += gnrc_lwmac
|
||||
# reduce the size of the packet buffer a bit
|
||||
CFLAGS += -DGNRC_PKTBUF_SIZE=512
|
||||
|
||||
# Set a custom channel if needed
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -31,10 +31,4 @@ USEMODULE += netstats_ipv6
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
@ -65,15 +65,4 @@ QUIET ?= 1
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
# Set a custom channel if needed
|
||||
ifneq (,$(filter cc110x,$(USEMODULE))) # radio is cc110x sub-GHz
|
||||
DEFAULT_CHANNEL ?= 0
|
||||
CFLAGS += -DCC110X_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else
|
||||
ifneq (,$(filter at86rf212b,$(USEMODULE))) # radio is IEEE 802.15.4 sub-GHz
|
||||
DEFAULT_CHANNEL ?= 5
|
||||
CFLAGS += -DIEEE802154_DEFAULT_SUBGHZ_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
else # radio is IEEE 802.15.4 2.4 GHz
|
||||
DEFAULT_CHANNEL ?= 26
|
||||
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=$(DEFAULT_CHANNEL)
|
||||
endif
|
||||
endif
|
||||
include $(RIOTMAKE)/default-channel.inc.mk
|
||||
|
Loading…
Reference in New Issue
Block a user