1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

netdev_ieee802154_submac: set addresses using netdev_register

This commit is contained in:
Jose Alamos 2020-10-16 11:49:05 +02:00
parent 217dc9e6e0
commit fa0dd8b5e2
4 changed files with 23 additions and 27 deletions

View File

@ -197,6 +197,7 @@ void cc2538_setup(cc2538_rf_t *dev)
(void) dev;
#if IS_USED(MODULE_NETDEV_IEEE802154_SUBMAC)
extern ieee802154_dev_t cc2538_rf_dev;
netdev_register((netdev_t* )dev, NETDEV_CC2538, 0);
netdev_ieee802154_submac_init(&dev->netdev, &cc2538_rf_dev);
#endif
cc2538_init();

View File

@ -233,8 +233,6 @@ static int _init(netdev_t *dev)
{
(void)dev;
netdev_register(&nrf802154_dev->netdev, NETDEV_NRF802154, 0);
int result = timer_init(NRF802154_TIMER, TIMER_FREQ, _timer_cb, NULL);
assert(result >= 0);
(void)result;

View File

@ -718,6 +718,8 @@ void nrf802154_setup(nrf802154_t *dev)
{
(void) dev;
#if IS_USED(MODULE_NETDEV_IEEE802154_SUBMAC)
netdev_t *netdev = (netdev_t*) dev;
netdev_register(netdev, NETDEV_NRF802154, 0);
netdev_ieee802154_submac_init(&dev->netdev, &nrf802154_hal_dev);
#endif
nrf802154_init();

View File

@ -274,33 +274,9 @@ static int _init(netdev_t *netdev)
{
netdev_ieee802154_submac_t *netdev_submac =
(netdev_ieee802154_submac_t *)netdev;
/* Call the init function of the device (this will be handled by
* `auto_init`) */
ieee802154_submac_t *submac = &netdev_submac->submac;
ieee802154_submac_init(submac);
netdev_ieee802154_t *netdev_ieee802154 = (netdev_ieee802154_t *)netdev;
/* This function already sets the PAN ID to the default one */
netdev_ieee802154_reset(netdev_ieee802154);
uint16_t chan = CONFIG_IEEE802154_DEFAULT_CHANNEL;
int16_t tx_power = CONFIG_IEEE802154_DEFAULT_TXPOWER;
netopt_enable_t enable = NETOPT_ENABLE;
/* Initialise netdev_ieee802154_t struct */
netdev_ieee802154_set(netdev_ieee802154, NETOPT_CHANNEL,
&chan, sizeof(chan));
netdev_ieee802154_set(netdev_ieee802154, NETOPT_ADDRESS,
&submac->short_addr, sizeof(submac->short_addr));
netdev_ieee802154_set(netdev_ieee802154, NETOPT_ADDRESS_LONG,
&submac->ext_addr, sizeof(submac->ext_addr));
netdev_ieee802154_set(netdev_ieee802154, NETOPT_ACK_REQ,
&enable, sizeof(enable));
netdev_submac->dev.txpower = tx_power;
ieee802154_submac_init(submac, (network_uint16_t*) netdev_ieee802154->short_addr, (eui64_t*) netdev_ieee802154->long_addr);
return 0;
}
@ -323,6 +299,25 @@ int netdev_ieee802154_submac_init(netdev_ieee802154_submac_t *netdev_submac,
netdev_submac->ack_timer.callback = _ack_timeout;
netdev_submac->ack_timer.arg = netdev_submac;
netdev_ieee802154_t *netdev_ieee802154 = (netdev_ieee802154_t *)netdev;
/* This function already sets the PAN ID to the default one */
netdev_ieee802154_reset(netdev_ieee802154);
uint16_t chan = CONFIG_IEEE802154_DEFAULT_CHANNEL;
int16_t tx_power = CONFIG_IEEE802154_DEFAULT_TXPOWER;
netopt_enable_t enable = NETOPT_ENABLE;
netdev_ieee802154_setup(netdev_ieee802154);
/* Initialise netdev_ieee802154_t struct */
netdev_ieee802154_set(netdev_ieee802154, NETOPT_CHANNEL,
&chan, sizeof(chan));
netdev_ieee802154_set(netdev_ieee802154, NETOPT_ACK_REQ,
&enable, sizeof(enable));
netdev_submac->dev.txpower = tx_power;
return 0;
}