diff --git a/Makefile b/Makefile index e5d35ab..e6d9770 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ DRIVER = spike TARGET = cc2520 -OBJS = radio.o interface.o module.o platform.o sack.o lpl.o packet.o csma.o +OBJS = radio.o interface.o module.o platform.o sack.o lpl.o packet.o csma.o unique.o obj-m += $(TARGET).o -cc2520-objs = radio.o interface.o module.o platform.o sack.o lpl.o packet.o csma.o +cc2520-objs = radio.o interface.o module.o platform.o sack.o lpl.o packet.o csma.o unique.o # Set this is your linux kernel checkout. KDIR := /home/androbin/rpi/linux diff --git a/module.c b/module.c index f3b01db..b0e9223 100644 --- a/module.c +++ b/module.c @@ -16,6 +16,7 @@ #include "interface.h" #include "sack.h" #include "csma.h" +#include "unique.h" #define DRIVER_AUTHOR "Andrew Robinson " #define DRIVER_DESC "A driver for the CC2520 radio. Be afraid." @@ -23,7 +24,8 @@ struct cc2520_state state; const char cc2520_name[] = "cc2520"; -struct cc2520_interface interface_to_lpl; +struct cc2520_interface interface_to_unique; +struct cc2520_interface unique_to_lpl; struct cc2520_interface lpl_to_csma; struct cc2520_interface csma_to_sack; struct cc2520_interface sack_to_radio; @@ -36,8 +38,10 @@ void setup_bindings(void) csma_bottom = &csma_to_sack; csma_top = &lpl_to_csma; lpl_bottom = &lpl_to_csma; - lpl_top = &interface_to_lpl; - interface_bottom = &interface_to_lpl; + lpl_top = &unique_to_lpl; + unique_bottom = &unique_to_lpl; + unique_top = &interface_to_unique; + interface_bottom = &interface_to_unique; } int init_module() @@ -92,10 +96,18 @@ int init_module() goto error1; } + err = cc2520_unique_init(); + if (err) { + ERR((KERN_ALERT "[cc2520] - unique init error. aborting.\n")); + goto error0; + } + state.wq = create_singlethread_workqueue(cc2520_name); return 0; + error0: + cc2520_csma_free(); error1: cc2520_sack_free(); error2: diff --git a/unique.c b/unique.c new file mode 100644 index 0000000..afc3c21 --- /dev/null +++ b/unique.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +#include "unique.h" +#include "packet.h" +#include "cc2520.h" + +struct cc2520_interface *unique_top; +struct cc2520_interface *unique_bottom; + +static int cc2520_unique_tx(u8 * buf, u8 len); +static void cc2520_unique_tx_done(u8 status); +static void cc2520_unique_rx_done(u8 *buf, u8 len); + +int cc2520_unique_init() +{ + unique_top->tx = cc2520_unique_tx; + unique_bottom->tx_done = cc2520_unique_tx_done; + unique_bottom->rx_done = cc2520_unique_rx_done; + + return 0; +} + +void cc2520_unique_free() +{ + +} + +static int cc2520_unique_tx(u8 * buf, u8 len) +{ + return unique_bottom->tx(buf, len); +} + +static void cc2520_unique_tx_done(u8 status) +{ + unique_top->tx_done(status); +} + +static void cc2520_unique_rx_done(u8 *buf, u8 len) +{ + unique_top->rx_done(buf, len); +} \ No newline at end of file diff --git a/unique.h b/unique.h new file mode 100644 index 0000000..9f292c4 --- /dev/null +++ b/unique.h @@ -0,0 +1,12 @@ +#ifndef UNIQUE_H +#define UNIQUE_H + +#include "cc2520.h" + +extern struct cc2520_interface *unique_top; +extern struct cc2520_interface *unique_bottom; + +int cc2520_unique_init(void); +void cc2520_unique_free(void); + +#endif \ No newline at end of file