Merged in merlin17/nuttx/ieee802154 (pull request #319)

wireless/ieee802154: Bind MAC phyif to radio

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Anthony Merlino 2017-04-15 17:58:29 +00:00 committed by Gregory Nutt
commit b35c3d2493
2 changed files with 28 additions and 2 deletions

View File

@ -172,9 +172,10 @@ struct ieee802154_trans_s
uint8_t psdu[CONFIG_IEEE802154_MTU];
};
struct ieee802154_radio_s; /* Forward reference */
struct ieee802154_phyif_s
struct ieee802154_phyif_s; /* Forward Reference */
struct ieee802154_phyifops_s
{
CODE int (*poll_csma) (FAR struct ieee802154_phyif_s *phyif,
FAR struct ieee802154_txdesc_s *tx_desc,
@ -183,12 +184,19 @@ struct ieee802154_phyif_s
CODE int (*poll_gts) (FAR struct ieee802154_phyif_s *phyif,
FAR struct ieee802154_txdesc_s *tx_desc,
uint8_t *buf);
};
struct ieee802154_phyif_s
{
FAR const struct ieee802154_phyifops_s *ops;
/* Driver-specific information */
void * priv;
};
struct ieee802154_radio_s; /* Forward reference */
struct ieee802154_radioops_s
{
CODE int (*bind) (FAR struct ieee802154_radio_s *dev,

View File

@ -67,6 +67,7 @@ struct ieee802154_privmac_s
{
FAR struct ieee802154_radio_s *radio; /* Contained IEEE802.15.4 radio dev */
FAR const struct ieee802154_maccb_s *cb; /* Contained MAC callbacks */
FAR struct ieee802154_phyif_s phyif; /* Interface to bind to radio */
sem_t excl_sem; /* Support exclusive access */
@ -225,6 +226,16 @@ struct mac802154_unsec_mhr_s
};
};
/****************************************************************************
* Private Data
****************************************************************************/
static const struct ieee802154_phyifops_s mac802154_phyifops =
{
mac802154_poll_csma,
mac802154_poll_gts
};
/****************************************************************************
* Private Functions
****************************************************************************/
@ -330,6 +341,13 @@ MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev)
mac802154_defaultmib(mac);
mac802154_applymib(mac);
mac->phyif.ops = &mac802154_phyifops;
mac->phyif.priv = mac;
/* Bind our PHY interface to the radio */
radiodev->ops->bind(radiodev, mac->phyif);
return (MACHANDLE)mac;
}