Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/tests/driver_at86rf2xx/Makefile b/tests/driver_at86rf2xx/Makefile
index 3964b90e6..6c12db43c 100644
--- a/tests/driver_at86rf2xx/Makefile
+++ b/tests/driver_at86rf2xx/Makefile
@@ -10,6 +10,7 @@ USEMODULE += od
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
+USEMODULE += core_tasklet
# define the driver to be used for selected boards
ifneq (,$(filter samr21-xpro,$(BOARD)))
diff --git a/tests/driver_at86rf2xx/main.c b/tests/driver_at86rf2xx/main.c
index 7f1dace64..5c5132262 100644
--- a/tests/driver_at86rf2xx/main.c
+++ b/tests/driver_at86rf2xx/main.c
@@ -23,16 +23,11 @@
#include "net/netdev.h"
#include "shell.h"
#include "shell_commands.h"
-#include "thread.h"
#include "xtimer.h"
-#include "common.h"
-
-#define _STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF)
-#define MSG_TYPE_ISR (0x3456)
+#include "tasklet.h"
-static char stack[_STACKSIZE];
-static kernel_pid_t _recv_pid;
+#include "common.h"
at86rf2xx_t devs[AT86RF2XX_NUM];
@@ -42,17 +37,18 @@ static const shell_command_t shell_commands[] = {
{ NULL, NULL, NULL }
};
+static tasklet_t tasklet;
+
+void tasklet_isr(void *arg)
+{
+ netdev_t *dev = (netdev_t*) arg;
+ dev->driver->isr(dev);
+}
+
static void _event_cb(netdev_t *dev, netdev_event_t event)
{
if (event == NETDEV_EVENT_ISR) {
- msg_t msg;
-
- msg.type = MSG_TYPE_ISR;
- msg.content.ptr = dev;
-
- if (msg_send(&msg, _recv_pid) <= 0) {
- puts("gnrc_netdev: possibly lost interrupt.");
- }
+ tasklet_schedule(&tasklet);
}
else {
switch (event) {
@@ -69,22 +65,6 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
}
}
-void *_recv_thread(void *arg)
-{
- (void)arg;
- while (1) {
- msg_t msg;
- msg_receive(&msg);
- if (msg.type == MSG_TYPE_ISR) {
- netdev_t *dev = msg.content.ptr;
- dev->driver->isr(dev);
- }
- else {
- puts("unexpected message type");
- }
- }
-}
-
int main(void)
{
puts("AT86RF2xx device driver test");
@@ -111,14 +91,7 @@ int main(void)
return 1;
}
- _recv_pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1,
- THREAD_CREATE_STACKTEST, _recv_thread, NULL,
- "recv_thread");
-
- if (_recv_pid <= KERNEL_PID_UNDEF) {
- puts("Creation of receiver thread failed");
- return 1;
- }
+ tasklet_init(&tasklet, tasklet_isr, devs);
/* start the shell */
puts("Initialization successful - starting the shell now");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment