|
14 | 14 | #include "cc2420_settings.h"
|
15 | 15 | #include "cc2420_arch.h"
|
16 | 16 | #include "hwtimer.h"
|
| 17 | +#include "kernel_types.h" |
17 | 18 | #include "netdev/802154.h"
|
18 | 19 | #include "netdev/base.h"
|
19 | 20 | #include "transceiver.h"
|
|
28 | 29 | /* startup timeout (2 ms) in 16MHz-clock cycles */
|
29 | 30 | #define CC2420_STARTUP_TIMEOUT 32000U
|
30 | 31 |
|
| 32 | +/* event type to signalize receive event */ |
| 33 | +#define CC2420_NETDEV_EVENT_RX (3452342219) |
| 34 | + |
31 | 35 | /* default source address length for sending in number of byte */
|
32 | 36 | static size_t _default_src_addr_len = 2;
|
33 | 37 |
|
| 38 | +/* TODO: allow for multiple devices */ |
| 39 | +static kernel_pid_t cc2420_netdev_event_handler = KERNEL_PID_UNDEF; |
| 40 | + |
34 | 41 | /* implementation of driver's functions */
|
35 | 42 |
|
36 | 43 | int cc2420_initialize(netdev_t *dev)
|
@@ -149,13 +156,36 @@ void cc2420_rxoverflow_irq(void)
|
149 | 156 |
|
150 | 157 | void cc2420_rx_irq(void)
|
151 | 158 | {
|
| 159 | +#ifdef MODULE_TRANSCEIVER |
152 | 160 | cc2420_rx_handler();
|
| 161 | +#else |
| 162 | + msg_t msg; |
| 163 | + msg.type = NETDEV_MSG_EVENT_TYPE; |
| 164 | + msg.content.value = CC2420_NETDEV_EVENT_RX; |
| 165 | + msg_send_int(&msg, cc2420_netdev_event_handler); |
| 166 | +#endif |
153 | 167 | }
|
154 | 168 |
|
155 | 169 | void cc2420_event(netdev_t *dev, uint32_t event_type)
|
156 | 170 | {
|
157 | 171 | (void)dev;
|
158 |
| - (void)event_type; |
| 172 | + |
| 173 | + switch (event_type) { |
| 174 | + case CC2420_NETDEV_EVENT_RX: |
| 175 | + cc2420_rx_handler(); |
| 176 | + |
| 177 | + break; |
| 178 | + |
| 179 | + default: |
| 180 | + |
| 181 | + break; |
| 182 | + } |
| 183 | +} |
| 184 | + |
| 185 | +void cc2420_set_event_handler(netdev_t *dev, kernel_pid_t event_handler) |
| 186 | +{ |
| 187 | + (void)dev; |
| 188 | + cc2420_netdev_event_handler = event_handler; |
159 | 189 | }
|
160 | 190 |
|
161 | 191 | void cc2420_set_monitor(int mode)
|
@@ -746,6 +776,7 @@ const netdev_802154_driver_t cc2420_driver = {
|
746 | 776 | cc2420_get_state,
|
747 | 777 | cc2420_set_state,
|
748 | 778 | cc2420_event,
|
| 779 | + cc2420_set_event_handler, |
749 | 780 | cc2420_load_tx_buf,
|
750 | 781 | cc2420_transmit_tx_buf,
|
751 | 782 | netdev_802154_send,
|
|
0 commit comments