Browse Source

cpu/nrf5x: moved nrfmin driver to nrf5x_common

pr/spi.typo
Hauke Petersen 6 years ago
parent
commit
a05233633f
  1. 5
      cpu/nrf51/Makefile
  2. 3
      cpu/nrf51/radio/nrfmin/Makefile
  3. 5
      cpu/nrf5x_common/Makefile
  4. 6
      cpu/nrf5x_common/include/nrfmin.h
  5. 4
      cpu/nrf5x_common/include/nrfmin_gnrc.h
  6. 9
      cpu/nrf5x_common/radio/nrfmin/Makefile
  7. 7
      cpu/nrf5x_common/radio/nrfmin/nrfmin.c
  8. 12
      cpu/nrf5x_common/radio/nrfmin/nrfmin_gnrc.c

5
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

3
cpu/nrf51/radio/nrfmin/Makefile

@ -1,3 +0,0 @@
MODULE = nrfmin
include $(RIOTBASE)/Makefile.base

5
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

6
cpu/nrf51/include/nrfmin.h → 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

4
cpu/nrf51/include/nrfmin_gnrc.h → 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
*
* @{

9
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

7
cpu/nrf51/radio/nrfmin/nrfmin.c → 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 */

12
cpu/nrf51/radio/nrfmin/nrfmin_gnrc.c → 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),
Loading…
Cancel
Save