drivers/mrf24j40: Hook in setdevmode from newly added radio attribute setting

This commit is contained in:
Anthony Merlino 2017-07-12 00:54:29 -04:00
parent 420db06b37
commit b1eb796d97
2 changed files with 9 additions and 22 deletions

View File

@ -290,19 +290,10 @@ int mrf24j40_setcoordeaddr(FAR struct mrf24j40_radio_s *dev,
*
****************************************************************************/
int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
uint8_t mode)
int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev, uint8_t mode)
{
int ret = OK;
uint8_t reg;
/* Disable slotted mode until I decide to implement slotted mode */
reg = mrf24j40_getreg(dev->spi, MRF24J40_TXMCR);
reg &= ~MRF24J40_TXMCR_SLOTTED;
mrf24j40_setreg(dev->spi, MRF24J40_TXMCR, reg);
mrf24j40_setreg(dev->spi, MRF24J40_ORDER, 0xFF);
/* Define dev mode */
reg = mrf24j40_getreg(dev->spi, MRF24J40_RXMCR);
@ -329,7 +320,7 @@ int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
mrf24j40_setreg(dev->spi, MRF24J40_RXMCR, reg);
dev->devmode = mode;
return ret;
return OK;
}
/****************************************************************************

View File

@ -530,42 +530,37 @@ int mrf24j40_setattr(FAR struct ieee802154_radio_s *radio,
FAR const union ieee802154_attr_u *attrval)
{
FAR struct mrf24j40_radio_s *dev = (FAR struct mrf24j40_radio_s *)radio;
int ret;
int ret = IEEE802154_STATUS_SUCCESS;;
switch (attr)
{
case IEEE802154_ATTR_MAC_PANID:
{
mrf24j40_setpanid(dev, attrval->mac.panid);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_MAC_SADDR:
{
mrf24j40_setsaddr(dev, attrval->mac.saddr);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_MAC_EADDR:
{
mrf24j40_seteaddr(dev, attrval->mac.eaddr);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_MAC_COORD_SADDR:
{
mrf24j40_setcoordsaddr(dev, attrval->mac.coordsaddr);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_MAC_COORD_EADDR:
{
mrf24j40_setcoordeaddr(dev, attrval->mac.coordeaddr);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
@ -579,16 +574,18 @@ int mrf24j40_setattr(FAR struct ieee802154_radio_s *radio,
{
mrf24j40_setrxmode(dev, MRF24J40_RXMODE_NORMAL);
}
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_PHY_CHAN:
{
mrf24j40_setchannel(dev, attrval->phy.chan);
ret = IEEE802154_STATUS_SUCCESS;
}
break;
case IEEE802154_ATTR_MAC_DEVMODE:
{
mrf24j40_setdevmode(dev, attrval->mac.devmode);
}
break;
@ -709,4 +706,3 @@ int mrf24j40_sfupdate(FAR struct ieee802154_radio_s *radio,
return OK;
}