mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
Merge pull request #7414 from miri64/gnrc_netif2/feat/cc110x
cc110x: port to gnrc_netif2
This commit is contained in:
commit
cb3c27dc29
@ -14,16 +14,16 @@
|
||||
#include "net/gnrc.h"
|
||||
#include "cc110x.h"
|
||||
#include "cc110x-netdev.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "net/gnrc/netif2.h"
|
||||
#include "od.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#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;
|
||||
netdev_t *dev = gnrc_netdev->dev;
|
||||
netdev_t *dev = netif->dev;
|
||||
netdev_cc110x_t *netdev_cc110x = (netdev_cc110x_t *) dev;
|
||||
cc110x_t *cc110x = &netdev_cc110x->cc110x;
|
||||
|
||||
@ -36,7 +36,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
|
||||
payload = pkt->next;
|
||||
|
||||
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);
|
||||
return -EBADMSG;
|
||||
}
|
||||
@ -82,7 +82,7 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
|
||||
payload_len += payload->size;
|
||||
|
||||
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);
|
||||
gnrc_pktbuf_release(pkt);
|
||||
return -EBADMSG;
|
||||
@ -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;
|
||||
|
||||
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",
|
||||
(unsigned)cc110x_pkt.phy_src,
|
||||
(unsigned)cc110x_pkt.address,
|
||||
@ -107,9 +107,9 @@ static int _send(gnrc_netdev_t *gnrc_netdev, gnrc_pktsnip_t *pkt)
|
||||
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_pkt_t *cc110x_pkt = &cc110x->pkt_buf.packet;
|
||||
@ -182,11 +182,16 @@ static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
|
||||
return pkt;
|
||||
}
|
||||
|
||||
int gnrc_netdev_cc110x_init(gnrc_netdev_t *gnrc_netdev, netdev_t *dev)
|
||||
{
|
||||
gnrc_netdev->send = _send;
|
||||
gnrc_netdev->recv = _recv;
|
||||
gnrc_netdev->dev = dev;
|
||||
static const gnrc_netif2_ops_t _cc110x_ops = {
|
||||
.send = _send,
|
||||
.recv = _recv,
|
||||
.get = gnrc_netif2_get_from_netdev,
|
||||
.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);
|
||||
}
|
||||
35
drivers/cc110x/include/gnrc_netif2_cc110x.h
Normal file
35
drivers/cc110x/include/gnrc_netif2_cc110x.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 @@
|
||||
#include "log.h"
|
||||
#include "debug.h"
|
||||
#include "board.h"
|
||||
#include "net/gnrc/netdev.h"
|
||||
#include "gnrc_netdev_cc110x.h"
|
||||
#include "gnrc_netif2_cc110x.h"
|
||||
#include "cc110x-netdev.h"
|
||||
#include "net/gnrc.h"
|
||||
|
||||
#include "cc110x.h"
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
#define CC110X_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
|
||||
#ifndef CC110X_MAC_PRIO
|
||||
#define CC110X_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
|
||||
#define CC110X_MAC_PRIO (GNRC_NETIF2_PRIO)
|
||||
#endif
|
||||
|
||||
#define CC110X_NUM (sizeof(cc110x_params)/sizeof(cc110x_params[0]))
|
||||
@ -43,8 +43,6 @@
|
||||
static netdev_cc110x_t cc110x_devs[CC110X_NUM];
|
||||
static char _stacks[CC110X_NUM][CC110X_MAC_STACKSIZE];
|
||||
|
||||
static gnrc_netdev_t _gnrc_netdev_devs[CC110X_NUM];
|
||||
|
||||
void auto_init_cc110x(void)
|
||||
{
|
||||
for (unsigned i = 0; i < CC110X_NUM; i++) {
|
||||
@ -57,12 +55,9 @@ void auto_init_cc110x(void)
|
||||
LOG_ERROR("[auto_init_netif] error initializing cc110x #%u\n", i);
|
||||
}
|
||||
else {
|
||||
gnrc_netdev_cc110x_init(&_gnrc_netdev_devs[i], &cc110x_devs[i]);
|
||||
res = gnrc_netdev_init(_stacks[i], CC110X_MAC_STACKSIZE,
|
||||
CC110X_MAC_PRIO, "cc110x", &_gnrc_netdev_devs[i]);
|
||||
if (res < 0) {
|
||||
LOG_ERROR("[auto_init_netif] error starting gnrc_cc110x thread\n");
|
||||
}
|
||||
gnrc_netif2_cc110x_create(_stacks[i], CC110X_MAC_STACKSIZE,
|
||||
CC110X_MAC_PRIO, "cc110x",
|
||||
(netdev_t *)&cc110x_devs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user