mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
drivers/at86rf2xx: move netdev logic out of reset function
This commit is contained in:
parent
5207a82e03
commit
72c3f9192a
@ -177,17 +177,12 @@ void at86rf2xx_disable_smart_idle(at86rf2xx_t *dev)
|
||||
void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||
{
|
||||
uint8_t tmp;
|
||||
netdev_ieee802154_reset(&dev->netdev);
|
||||
|
||||
/* Reset state machine to ensure a known state */
|
||||
if (dev->state == AT86RF2XX_STATE_P_ON) {
|
||||
at86rf2xx_set_state(dev, AT86RF2XX_STATE_FORCE_TRX_OFF);
|
||||
}
|
||||
|
||||
/* set short and long address */
|
||||
at86rf2xx_set_addr_long(dev, (eui64_t *)dev->netdev.long_addr);
|
||||
at86rf2xx_set_addr_short(dev, (network_uint16_t *)dev->netdev.short_addr);
|
||||
|
||||
/* set default channel and page */
|
||||
at86rf2xx_configure_phy(dev, AT86RF2XX_DEFAULT_CHANNEL, AT86RF2XX_DEFAULT_PAGE);
|
||||
/* set default TX power */
|
||||
@ -197,10 +192,6 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
|
||||
if (!IS_ACTIVE(AT86RF2XX_BASIC_MODE)) {
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_AUTOACK, true);
|
||||
at86rf2xx_set_option(dev, AT86RF2XX_OPT_CSMA, true);
|
||||
|
||||
static const netopt_enable_t enable = NETOPT_ENABLE;
|
||||
netdev_ieee802154_set(&dev->netdev, NETOPT_ACK_REQ,
|
||||
&enable, sizeof(enable));
|
||||
}
|
||||
|
||||
/* enable safe mode (protect RX FIFO until reading data starts) */
|
||||
|
@ -92,6 +92,14 @@ static int _init(netdev_t *netdev)
|
||||
}
|
||||
|
||||
/* reset device to default values and put it into RX state */
|
||||
netdev_ieee802154_reset(&dev->netdev);
|
||||
at86rf2xx_set_addr_long(dev, (eui64_t *)dev->netdev.long_addr);
|
||||
at86rf2xx_set_addr_short(dev, (network_uint16_t *)dev->netdev.short_addr);
|
||||
if (!IS_ACTIVE(AT86RF2XX_BASIC_MODE)) {
|
||||
static const netopt_enable_t enable = NETOPT_ENABLE;
|
||||
netdev_ieee802154_set(&dev->netdev, NETOPT_ACK_REQ,
|
||||
&enable, sizeof(enable));
|
||||
}
|
||||
at86rf2xx_reset(dev);
|
||||
|
||||
/* signal link UP */
|
||||
@ -265,6 +273,16 @@ static int _set_state(at86rf2xx_t *dev, netopt_state_t state)
|
||||
break;
|
||||
case NETOPT_STATE_RESET:
|
||||
at86rf2xx_hardware_reset(dev);
|
||||
netdev_ieee802154_reset(&dev->netdev);
|
||||
/* set short and long address */
|
||||
at86rf2xx_set_addr_long(dev, (eui64_t *)dev->netdev.long_addr);
|
||||
at86rf2xx_set_addr_short(dev, (network_uint16_t *)dev->netdev.short_addr);
|
||||
|
||||
if (!IS_ACTIVE(AT86RF2XX_BASIC_MODE)) {
|
||||
static const netopt_enable_t enable = NETOPT_ENABLE;
|
||||
netdev_ieee802154_set(&dev->netdev, NETOPT_ACK_REQ,
|
||||
&enable, sizeof(enable));
|
||||
}
|
||||
at86rf2xx_reset(dev);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user