From a05233633f5f12045b682605f4a4fd7ab8cc03a0 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 11 Nov 2016 11:44:43 +0100 Subject: [PATCH] cpu/nrf5x: moved nrfmin driver to nrf5x_common --- cpu/nrf51/Makefile | 5 ----- cpu/nrf51/radio/nrfmin/Makefile | 3 --- cpu/nrf5x_common/Makefile | 5 +++++ cpu/{nrf51 => nrf5x_common}/include/nrfmin.h | 6 +++--- cpu/{nrf51 => nrf5x_common}/include/nrfmin_gnrc.h | 4 ++-- cpu/nrf5x_common/radio/nrfmin/Makefile | 9 +++++++++ cpu/{nrf51 => nrf5x_common}/radio/nrfmin/nrfmin.c | 7 ++++--- .../radio/nrfmin/nrfmin_gnrc.c | 12 ++++++------ 8 files changed, 29 insertions(+), 22 deletions(-) delete mode 100644 cpu/nrf51/radio/nrfmin/Makefile rename cpu/{nrf51 => nrf5x_common}/include/nrfmin.h (98%) rename cpu/{nrf51 => nrf5x_common}/include/nrfmin_gnrc.h (90%) create mode 100644 cpu/nrf5x_common/radio/nrfmin/Makefile rename cpu/{nrf51 => nrf5x_common}/radio/nrfmin/nrfmin.c (98%) rename cpu/{nrf51 => nrf5x_common}/radio/nrfmin/nrfmin_gnrc.c (95%) diff --git a/cpu/nrf51/Makefile b/cpu/nrf51/Makefile index 92346bfa1d..7600b58931 100644 --- a/cpu/nrf51/Makefile +++ b/cpu/nrf51/Makefile @@ -4,11 +4,6 @@ MODULE = cpu # add a list of subdirectories, that should also be build DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/nrf5x_common -# build one of the radio drivers, if enabled -ifneq (,$(filter nrfmin,$(USEMODULE))) - DIRS += radio/nrfmin -endif - # (file triggers compiler bug. see #5775) SRC_NOLTO += vectors.c diff --git a/cpu/nrf51/radio/nrfmin/Makefile b/cpu/nrf51/radio/nrfmin/Makefile deleted file mode 100644 index b1443349eb..0000000000 --- a/cpu/nrf51/radio/nrfmin/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = nrfmin - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/nrf5x_common/Makefile b/cpu/nrf5x_common/Makefile index e09377cd1e..3b0970ca13 100644 --- a/cpu/nrf5x_common/Makefile +++ b/cpu/nrf5x_common/Makefile @@ -1,3 +1,8 @@ DIRS = periph +# build one of the radio drivers, if enabled +ifneq (,$(filter nrfmin,$(USEMODULE))) + DIRS += radio/nrfmin +endif + include $(RIOTBASE)/Makefile.base diff --git a/cpu/nrf51/include/nrfmin.h b/cpu/nrf5x_common/include/nrfmin.h similarity index 98% rename from cpu/nrf51/include/nrfmin.h rename to cpu/nrf5x_common/include/nrfmin.h index 205039b9b9..aa8e39eae0 100644 --- a/cpu/nrf51/include/nrfmin.h +++ b/cpu/nrf5x_common/include/nrfmin.h @@ -7,8 +7,8 @@ */ /** - * @defgroup drivers_nrf51822_nrfmin NRF Minimal Radio Driver - * @ingroup drivers_netdev + * @defgroup drivers_nrf5x_nrfmin NRF Minimal Radio Driver + * @ingroup drivers_netdev2 * @brief Minimal driver for the NRF51 radio * * This driver uses the nRF5x radio in a proprietary/custom way, defining our @@ -42,7 +42,7 @@ * - dst_addr: 16-bit destination address * - proto: type of data transferred (similar to an Ethertype field) * - * SUMMERY: + * SUMMARY: * This driver / link layer supports: * - 16-bit addressing (16-bit) * -> extract default address from CPU ID diff --git a/cpu/nrf51/include/nrfmin_gnrc.h b/cpu/nrf5x_common/include/nrfmin_gnrc.h similarity index 90% rename from cpu/nrf51/include/nrfmin_gnrc.h rename to cpu/nrf5x_common/include/nrfmin_gnrc.h index 1135ec1d06..dc1a971a40 100644 --- a/cpu/nrf51/include/nrfmin_gnrc.h +++ b/cpu/nrf5x_common/include/nrfmin_gnrc.h @@ -7,8 +7,8 @@ */ /** - * @defgroup drivers_nrf51822_nrfmin_gnrc GNRC adapter for nrfmin - * @ingroup drivers_nrf51822_nrfmin + * @defgroup drivers_nrf5x_nrfmin_gnrc GNRC adapter for nrfmin + * @ingroup drivers_nrf5x_nrfmin * @brief Minimal driver for the NRF51 radio * * @{ diff --git a/cpu/nrf5x_common/radio/nrfmin/Makefile b/cpu/nrf5x_common/radio/nrfmin/Makefile new file mode 100644 index 0000000000..5b85af78ae --- /dev/null +++ b/cpu/nrf5x_common/radio/nrfmin/Makefile @@ -0,0 +1,9 @@ +MODULE = nrfmin + +SRC = nrfmin.c + +ifneq (,$(filter gnrc_netdev_default,$(USEMODULE))) + SRC += nrfmin_gnrc.c +endif + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/nrf51/radio/nrfmin/nrfmin.c b/cpu/nrf5x_common/radio/nrfmin/nrfmin.c similarity index 98% rename from cpu/nrf51/radio/nrfmin/nrfmin.c rename to cpu/nrf5x_common/radio/nrfmin/nrfmin.c index b278f4cdce..c6cc5a390c 100644 --- a/cpu/nrf51/radio/nrfmin/nrfmin.c +++ b/cpu/nrf5x_common/radio/nrfmin/nrfmin.c @@ -7,7 +7,7 @@ */ /** - * @ingroup drivers_nrf51_nrfmin + * @ingroup drivers_nrf5x_nrfmin * @{ * * @file @@ -428,8 +428,9 @@ static int nrfmin_init(netdev2_t *dev) (CONF_BASE_ADDR_LEN << RADIO_PCNF1_BALEN_Pos) | (CONF_STATLEN << RADIO_PCNF1_STATLEN_Pos) | (NRFMIN_PKT_MAX << RADIO_PCNF1_MAXLEN_Pos)); - /* configure the CRC unit */ - NRF_RADIO->CRCCNF = CONF_CRC_LEN; + /* configure the CRC unit, we skip the address field as this seems to lead + * to wrong checksum calculation on nRF52 devices in some cases */ + NRF_RADIO->CRCCNF = CONF_CRC_LEN | RADIO_CRCCNF_SKIPADDR_Msk; NRF_RADIO->CRCPOLY = CONF_CRC_POLY; NRF_RADIO->CRCINIT = CONF_CRC_INIT; /* set shortcuts for more efficient transfer */ diff --git a/cpu/nrf51/radio/nrfmin/nrfmin_gnrc.c b/cpu/nrf5x_common/radio/nrfmin/nrfmin_gnrc.c similarity index 95% rename from cpu/nrf51/radio/nrfmin/nrfmin_gnrc.c rename to cpu/nrf5x_common/radio/nrfmin/nrfmin_gnrc.c index 7beca49a34..9253d490f4 100644 --- a/cpu/nrf51/radio/nrfmin/nrfmin_gnrc.c +++ b/cpu/nrf5x_common/radio/nrfmin/nrfmin_gnrc.c @@ -7,7 +7,7 @@ */ /** - * @ingroup drivers_nrf51_nrfmin + * @ingroup drivers_nrf5x_nrfmin_gnrc * @{ * * @file @@ -81,7 +81,7 @@ static int hdr_netif_to_nrfmin(nrfmin_hdr_t *nrfmin, gnrc_pktsnip_t *pkt) return 0; } -static int nrfmin_gnrc_send(gnrc_netdev2_t *dev, gnrc_pktsnip_t *pkt) +static int gnrc_nrfmin_send(gnrc_netdev2_t *dev, gnrc_pktsnip_t *pkt) { int res; struct iovec *vec; @@ -124,7 +124,7 @@ static int nrfmin_gnrc_send(gnrc_netdev2_t *dev, gnrc_pktsnip_t *pkt) return res; } -static gnrc_pktsnip_t *nrfmin_gnrc_recv(gnrc_netdev2_t *dev) +static gnrc_pktsnip_t *gnrc_nrfmin_recv(gnrc_netdev2_t *dev) { int pktsize; nrfmin_hdr_t *nrfmin; @@ -185,14 +185,14 @@ static gnrc_pktsnip_t *nrfmin_gnrc_recv(gnrc_netdev2_t *dev) return pkt_snip; } -void nrfmin_gnrc_init(void) +void gnrc_nrfmin_init(void) { /* setup the NRFMIN driver */ nrfmin_setup(); /* initialize the GNRC plug struct */ - plug.send = nrfmin_gnrc_send; - plug.recv = nrfmin_gnrc_recv; + plug.send = gnrc_nrfmin_send; + plug.recv = gnrc_nrfmin_recv; plug.dev = &nrfmin_dev; gnrc_netdev2_init(stack, sizeof(stack),