From f1ca73e9342a1337debfa25c415d46816dfd87f9 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Thu, 28 Jul 2022 18:28:37 +0200 Subject: [PATCH] tests/ieee802154_hal: add support for kw2xrf radios Co-authored-by: Michel Rottleuthner --- tests/ieee802154_hal/Makefile | 5 +++++ tests/ieee802154_hal/common.h | 4 +++- tests/ieee802154_hal/init_devs.c | 24 ++++++++++++++++++++++++ tests/ieee802154_hal/main.c | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/ieee802154_hal/Makefile b/tests/ieee802154_hal/Makefile index 73627c20dc..cc66787e17 100644 --- a/tests/ieee802154_hal/Makefile +++ b/tests/ieee802154_hal/Makefile @@ -16,6 +16,7 @@ BOARD_WHITELIST := \ remote-pa \ remote-reva \ remote-revb \ + pba-d-01-kw2x \ # DISABLE_MODULE += auto_init_at86rf2xx auto_init_nrf802154 @@ -45,3 +46,7 @@ USEMODULE += netdev_default CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE=1024 include $(RIOTBASE)/Makefile.include + +ifneq (,$(filter bhp,$(USEMODULE))) + USEMODULE += bhp_event +endif diff --git a/tests/ieee802154_hal/common.h b/tests/ieee802154_hal/common.h index ecd3e6a246..4b30dc5d46 100644 --- a/tests/ieee802154_hal/common.h +++ b/tests/ieee802154_hal/common.h @@ -27,7 +27,8 @@ #define RADIOS_NUMOF IS_USED(MODULE_CC2538_RF) + \ IS_USED(MODULE_NRF802154) + \ - SOCKET_ZEP_MAX + SOCKET_ZEP_MAX + \ + IS_USED(MODULE_KW2XRF) #if RADIOS_NUMOF == 0 #error "Radio is not supported" @@ -46,6 +47,7 @@ typedef enum { IEEE802154_DEV_TYPE_CC2538_RF, IEEE802154_DEV_TYPE_NRF802154, IEEE802154_DEV_TYPE_SOCKET_ZEP, + IEEE802154_DEV_TYPE_KW2XRF, } ieee802154_dev_type_t; typedef ieee802154_dev_t* (*ieee802154_dev_cb_t)(ieee802154_dev_type_t type, diff --git a/tests/ieee802154_hal/init_devs.c b/tests/ieee802154_hal/init_devs.c index 2d60fe3850..eeb838629e 100644 --- a/tests/ieee802154_hal/init_devs.c +++ b/tests/ieee802154_hal/init_devs.c @@ -22,6 +22,7 @@ #include "kernel_defines.h" #include "net/ieee802154/radio.h" #include "common.h" +#include "bhp/event.h" #ifdef MODULE_CC2538_RF #include "cc2538_rf.h" @@ -36,6 +37,17 @@ #include "socket_zep_params.h" #endif +#ifdef MODULE_KW2XRF +#include "kw2xrf.h" +#include "kw2xrf_params.h" +#include "event/thread.h" +#define KW2XRF_NUM ARRAY_SIZE(kw2xrf_params) +extern void auto_init_event_thread(void); +static kw2xrf_t kw2xrf_dev[KW2XRF_NUM]; +static bhp_event_t kw2xrf_bhp[KW2XRF_NUM]; + +#endif + void ieee802154_hal_test_init_devs(ieee802154_dev_cb_t cb, void *opaque) { /* Call the init function of the device (this should be handled by @@ -56,6 +68,18 @@ void ieee802154_hal_test_init_devs(ieee802154_dev_cb_t cb, void *opaque) } #endif +#ifdef MODULE_KW2XRF + auto_init_event_thread(); + if ((radio = cb(IEEE802154_DEV_TYPE_KW2XRF, opaque)) ){ + for (unsigned i = 0; i < KW2XRF_NUM; i++) { + const kw2xrf_params_t *p = &kw2xrf_params[i]; + bhp_event_init(&kw2xrf_bhp[i], EVENT_PRIO_HIGHEST, &kw2xrf_radio_hal_irq_handler, radio); + kw2xrf_init(&kw2xrf_dev[i], p, radio, bhp_event_isr_cb, &kw2xrf_bhp[i]); + break; + } + } +#endif + #ifdef MODULE_SOCKET_ZEP static socket_zep_t _socket_zeps[SOCKET_ZEP_MAX]; if ((radio = cb(IEEE802154_DEV_TYPE_SOCKET_ZEP, opaque)) ){ diff --git a/tests/ieee802154_hal/main.c b/tests/ieee802154_hal/main.c index b07441426e..accbc682ee 100644 --- a/tests/ieee802154_hal/main.c +++ b/tests/ieee802154_hal/main.c @@ -262,6 +262,9 @@ static ieee802154_dev_t *_reg_callback(ieee802154_dev_type_t type, void *opaque) case IEEE802154_DEV_TYPE_SOCKET_ZEP: printf("socket_zep"); break; + case IEEE802154_DEV_TYPE_KW2XRF: + printf("kw2xrf"); + break; } puts(".");