1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

cc110x: make protocol configurable

This commit is contained in:
Oleg Hahm 2015-10-31 19:20:26 +09:00
parent e38eb13a4d
commit 2f5683b3f7
2 changed files with 23 additions and 5 deletions

View File

@ -103,11 +103,7 @@ static int _get(netdev2_t *dev, netopt_t opt, void *value, size_t value_len)
return 2;
case NETOPT_PROTO:
assert(value_len == sizeof(gnrc_nettype_t));
#ifdef MODULE_GNRC_SIXLOWPAN
*((gnrc_nettype_t*)value) = GNRC_NETTYPE_SIXLOWPAN;
#else
*((gnrc_nettype_t*)value) = GNRC_NETTYPE_UNDEF;
#endif
*((gnrc_nettype_t *)value) = cc110x->proto;
return sizeof(gnrc_nettype_t);
case NETOPT_CHANNEL:
assert(value_len > 1);
@ -155,6 +151,15 @@ static int _set(netdev2_t *dev, netopt_t opt, void *value, size_t value_len)
return -EINVAL;
}
return 1;
case NETOPT_PROTO:
if (value_len != sizeof(gnrc_nettype_t)) {
return -EINVAL;
}
else {
cc110x->proto = (gnrc_nettype_t) value;
return sizeof(gnrc_nettype_t);
}
break;
default:
return -ENOTSUP;
}
@ -214,5 +219,14 @@ int netdev2_cc110x_setup(netdev2_cc110x_t *netdev2_cc110x, const cc110x_params_t
DEBUG("netdev2_cc110x_setup()\n");
netdev2_cc110x->netdev.driver = &netdev2_cc110x_driver;
/* set default protocol */
#ifdef MODULE_GNRC_NETIF
# ifdef MODULE_GNRC_SIXLOWPAN
netdev2_cc110x->cc110x.proto = GNRC_NETTYPE_SIXLOWPAN;
# else
netdev2_cc110x->cc110x.proto = GNRC_NETTYPE_UNDEF;
# endif
#endif
return cc110x_setup(&netdev2_cc110x->cc110x, params);
}

View File

@ -27,6 +27,7 @@ extern "C" {
#include "periph/spi.h"
#include "periph/gpio.h"
#include "cc110x-internal.h"
#include "net/gnrc/nettype.h"
/**
* @brief Struct for holding cc110x IO parameters
@ -60,6 +61,9 @@ struct cc110x {
cc110x_pkt_buf_t pkt_buf; /**< RX/TX buffer */
void (*isr_cb)(cc110x_t *dev, void* arg); /**< isr callback */
void *isr_cb_arg; /**< isr callback argument */
#ifdef MODULE_GNRC_NETIF
gnrc_nettype_t proto; /**< protocol the radio expects */
#endif
};
/**