Skip to content

Commit

Permalink
added unique layer skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
anroOfCode committed Jan 13, 2013
1 parent 97b8662 commit b526006
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions module.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
#include "interface.h"
#include "sack.h"
#include "csma.h"
#include "unique.h"

#define DRIVER_AUTHOR "Andrew Robinson <[email protected]>"
#define DRIVER_DESC "A driver for the CC2520 radio. Be afraid."

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;
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
44 changes: 44 additions & 0 deletions unique.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/hrtimer.h>

#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);
}
12 changes: 12 additions & 0 deletions unique.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b526006

Please sign in to comment.