Skip to content

Commit

Permalink
drivers/netdev_ieee802154_submac: port to netdev_new_api
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Nov 14, 2024
1 parent 70aa1ec commit 6db1ff9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
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 @@ -174,6 +174,7 @@ static int _send(netdev_t *netdev, const iolist_t *pkt)
* 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 @@ static void submac_tx_done(ieee802154_submac_t *submac, int status,
}

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 @@ static int _init(netdev_t *netdev)
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 @@ static const netdev_driver_t netdev_submac_driver = {
.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

0 comments on commit 6db1ff9

Please sign in to comment.