Skip to content
Snippets Groups Projects
Unverified Commit cb3c27dc authored by Martine Lenders's avatar Martine Lenders Committed by GitHub
Browse files

Merge pull request #7414 from miri64/gnrc_netif2/feat/cc110x

cc110x: port to gnrc_netif2
parents 099cdcf8 e3ef4284
No related branches found
No related tags found
No related merge requests found
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
#include "net/gnrc.h" #include "net/gnrc.h"
#include "cc110x.h" #include "cc110x.h"
#include "cc110x-netdev.h" #include "cc110x-netdev.h"
#include "net/gnrc/netdev.h" #include "net/gnrc/netif2.h"
#include "od.h" #include "od.h"
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt) static int _send(gnrc_netif2_t *netif, gnrc_pktsnip_t *pkt)
{ {
cc110x_pkt_t cc110x_pkt; cc110x_pkt_t cc110x_pkt;
netdev_t *dev = gnrc_netdev->dev; netdev_t *dev = netif->dev;
netdev_cc110x_t *netdev_cc110x = (netdev_cc110x_t *) dev; netdev_cc110x_t *netdev_cc110x = (netdev_cc110x_t *) dev;
cc110x_t *cc110x = &netdev_cc110x->cc110x; cc110x_t *cc110x = &netdev_cc110x->cc110x;
...@@ -36,7 +36,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt) ...@@ -36,7 +36,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
payload = pkt->next; payload = pkt->next;
if (pkt->type != GNRC_NETTYPE_NETIF) { if (pkt->type != GNRC_NETTYPE_NETIF) {
DEBUG("gnrc_netdev_cc110x: First header was not generic netif header\n"); DEBUG("gnrc_cc110x: First header was not generic netif header\n");
gnrc_pktbuf_release(pkt); gnrc_pktbuf_release(pkt);
return -EBADMSG; return -EBADMSG;
} }
...@@ -82,7 +82,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt) ...@@ -82,7 +82,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
payload_len += payload->size; payload_len += payload->size;
if (payload_len > CC110X_MAX_DATA_LENGTH) { if (payload_len > CC110X_MAX_DATA_LENGTH) {
DEBUG("gnrc_netdev_cc110x: payload length exceeds maximum" DEBUG("gnrc_cc110x: payload length exceeds maximum"
"(%u>%u)\n", payload_len, CC110X_MAX_DATA_LENGTH); "(%u>%u)\n", payload_len, CC110X_MAX_DATA_LENGTH);
gnrc_pktbuf_release(pkt); gnrc_pktbuf_release(pkt);
return -EBADMSG; return -EBADMSG;
...@@ -98,7 +98,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt) ...@@ -98,7 +98,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
cc110x_pkt.length = (uint8_t) payload_len + CC110X_HEADER_LENGTH; cc110x_pkt.length = (uint8_t) payload_len + CC110X_HEADER_LENGTH;
DEBUG("gnrc_netdev_cc110x: sending packet from %u to %u with payload " DEBUG("gnrc_cc110x: sending packet from %u to %u with payload "
"length %u\n", "length %u\n",
(unsigned)cc110x_pkt.phy_src, (unsigned)cc110x_pkt.phy_src,
(unsigned)cc110x_pkt.address, (unsigned)cc110x_pkt.address,
...@@ -107,9 +107,9 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt) ...@@ -107,9 +107,9 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
return dev->driver->send(dev, &vector, 1); return dev->driver->send(dev, &vector, 1);
} }
static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev) static gnrc_pktsnip_t *_recv(gnrc_netif2_t *netif)
{ {
netdev_t *dev = gnrc_netdev->dev; netdev_t *dev = netif->dev;
cc110x_t *cc110x = &((netdev_cc110x_t*) dev)->cc110x; cc110x_t *cc110x = &((netdev_cc110x_t*) dev)->cc110x;
cc110x_pkt_t *cc110x_pkt = &cc110x->pkt_buf.packet; cc110x_pkt_t *cc110x_pkt = &cc110x->pkt_buf.packet;
...@@ -182,11 +182,16 @@ static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev) ...@@ -182,11 +182,16 @@ static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
return pkt; return pkt;
} }
int gnrc_netdev_cc110x_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev) static const gnrc_netif2_ops_t _cc110x_ops = {
{ .send = _send,
gnrc_netdev->send = _send; .recv = _recv,
gnrc_netdev->recv = _recv; .get = gnrc_netif2_get_from_netdev,
gnrc_netdev->dev = dev; .set = gnrc_netif2_set_from_netdev,
};
return 0; gnrc_netif2_t *gnrc_netif2_cc110x_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev)
{
return gnrc_netif2_create(stack, stacksize, priority, name, dev,
&_cc110x_ops);
} }
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_netif2
* @{
*
* @file
* @brief CC110x adaption for @ref net_gnrc_netif2
*
* @author Martine Lenders <m.lenders@fu-berlin.de>
*/
#ifndef GNRC_NETIF2_CC110X_H
#define GNRC_NETIF2_CC110X_H
#include "net/gnrc/netif2.h"
#ifdef __cplusplus
extern "C" {
#endif
gnrc_netif2_t *gnrc_netif2_cc110x_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
#ifdef __cplusplus
}
#endif
#endif /* GNRC_NETIF2_CC110X_H */
/** @} */
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "log.h" #include "log.h"
#include "debug.h" #include "debug.h"
#include "board.h" #include "board.h"
#include "net/gnrc/netdev.h" #include "gnrc_netif2_cc110x.h"
#include "gnrc_netdev_cc110x.h" #include "cc110x-netdev.h"
#include "net/gnrc.h" #include "net/gnrc.h"
#include "cc110x.h" #include "cc110x.h"
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
*/ */
#define CC110X_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE) #define CC110X_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
#ifndef CC110X_MAC_PRIO #ifndef CC110X_MAC_PRIO
#define CC110X_MAC_PRIO (GNRC_NETDEV_MAC_PRIO) #define CC110X_MAC_PRIO (GNRC_NETIF2_PRIO)
#endif #endif
#define CC110X_NUM (sizeof(cc110x_params)/sizeof(cc110x_params[0])) #define CC110X_NUM (sizeof(cc110x_params)/sizeof(cc110x_params[0]))
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
static netdev_cc110x_t cc110x_devs[CC110X_NUM]; static netdev_cc110x_t cc110x_devs[CC110X_NUM];
static char _stacks[CC110X_NUM][CC110X_MAC_STACKSIZE]; static char _stacks[CC110X_NUM][CC110X_MAC_STACKSIZE];
static gnrc_netdev_t _gnrc_netdev_devs[CC110X_NUM];
void auto_init_cc110x(void) void auto_init_cc110x(void)
{ {
for (unsigned i = 0; i < CC110X_NUM; i++) { for (unsigned i = 0; i < CC110X_NUM; i++) {
...@@ -57,12 +55,9 @@ void auto_init_cc110x(void) ...@@ -57,12 +55,9 @@ void auto_init_cc110x(void)
LOG_ERROR("[auto_init_netif] error initializing cc110x #%u\n", i); LOG_ERROR("[auto_init_netif] error initializing cc110x #%u\n", i);
} }
else { else {
gnrc_netdev_cc110x_init(&_gnrc_netdev_devs[i], &cc110x_devs[i]); gnrc_netif2_cc110x_create(_stacks[i], CC110X_MAC_STACKSIZE,
res = gnrc_netdev_init(_stacks[i], CC110X_MAC_STACKSIZE, CC110X_MAC_PRIO, "cc110x",
CC110X_MAC_PRIO, "cc110x", &_gnrc_netdev_devs[i]); (netdev_t *)&cc110x_devs[i]);
if (res < 0) {
LOG_ERROR("[auto_init_netif] error starting gnrc_cc110x thread\n");
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment