-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97b8662
commit b526006
Showing
4 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |