Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/netdev_ieee802154_submac: port to netdev_new_api #20992

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/include/net/netdev/ieee802154_submac.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef struct {
ieee802154_submac_t submac; /**< IEEE 802.15.4 SubMAC descriptor */
ztimer_t ack_timer; /**< ztimer descriptor for the ACK timeout timer */
int isr_flags; /**< netdev submac @ref NETDEV_EVENT_ISR flags */
int bytes_tx; /**< size of the sent frame or tx error */
int8_t retrans; /**< number of frame retransmissions of the last TX */
bool dispatch; /**< whether an event should be dispatched or not */
netdev_event_t ev; /**< event to be dispatched */
Expand Down
5 changes: 5 additions & 0 deletions drivers/netdev_ieee802154_submac/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
USEMODULE += netdev_ieee802154
USEMODULE += netdev_new_api
USEMODULE += ieee802154
USEMODULE += ieee802154_submac
USEMODULE += ztimer_usec
25 changes: 15 additions & 10 deletions drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
static int _get(netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
{
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev, netdev_ieee802154_t, netdev);
netdev_ieee802154_submac_t *netdev_submac = container_of(netdev_ieee802154, netdev_ieee802154_submac_t, dev);

Check warning on line 46 in drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
ieee802154_submac_t *submac = &netdev_submac->submac;

switch (opt) {
Expand Down Expand Up @@ -174,6 +174,7 @@
* inside the TX Done callback */
netdev_submac->ev = NETDEV_EVENT_TX_STARTED;
}
netdev_submac->bytes_tx = res;
return res;
}

Expand Down Expand Up @@ -280,21 +281,14 @@
}

netdev_submac->dispatch = true;
netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE;

switch (status) {
case TX_STATUS_SUCCESS:
netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE;
break;
case TX_STATUS_FRAME_PENDING:
netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE_DATA_PENDING;
break;
case TX_STATUS_MEDIUM_BUSY:
netdev_submac->ev = NETDEV_EVENT_TX_MEDIUM_BUSY;
netdev_submac->bytes_tx = -EBUSY;
break;
case TX_STATUS_NO_ACK:
netdev_submac->ev = NETDEV_EVENT_TX_NOACK;
break;
default:
netdev_submac->bytes_tx = -EHOSTUNREACH;
break;
}
}
Expand Down Expand Up @@ -377,6 +371,16 @@
return 0;
}

static int _confirm_send(netdev_t *netdev, void *info)
{
(void)info;
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev, netdev_ieee802154_t, netdev);
netdev_ieee802154_submac_t *netdev_submac = container_of(netdev_ieee802154,
netdev_ieee802154_submac_t,
dev);
return netdev_submac->bytes_tx;
}

int netdev_ieee802154_submac_init(netdev_ieee802154_submac_t *netdev_submac)
{
netdev_t *netdev = &netdev_submac->dev.netdev;
Expand All @@ -402,6 +406,7 @@
.recv = _recv,
.isr = _isr,
.init = _init,
.confirm_send = _confirm_send,
};

/** @} */
8 changes: 0 additions & 8 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,6 @@ ifneq (,$(filter netdev_ieee802154,$(USEMODULE)))
USEMODULE += random
endif

ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE)))
USEMODULE += netdev_ieee802154
USEMODULE += netdev_legacy_api
USEMODULE += ieee802154
USEMODULE += ieee802154_submac
USEMODULE += ztimer_usec
endif

ifneq (,$(filter uhcpc,$(USEMODULE)))
USEMODULE += posix_inet
USEMODULE += ztimer_msec
Expand Down
Loading