Clicker2-STM32: Add some mostly bogus MAC initializatinon logic.
This commit is contained in:
parent
40a8ef3c00
commit
9e4052e506
@ -47,6 +47,8 @@
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/wireless/ieee80154/ieee802154_radio.h>
|
||||
#include <nuttx/wireless/ieee80154/ieee802154_mac.h>
|
||||
#include <nuttx/wireless/ieee80154/mrf24j40.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
@ -87,6 +89,7 @@
|
||||
#endif
|
||||
|
||||
#define RADIO_DEVNAME "/dev/mrf24j40"
|
||||
#define MAC_DEVNAME "/dev/mrf24j40mac"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -222,6 +225,9 @@ static void stm32_enable_irq(FAR struct mrf24j40_lower_s *lower, int state)
|
||||
static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
||||
{
|
||||
FAR struct ieee802154_radio_s *radio;
|
||||
#ifdef CONFIG_IEEE802154_MAC
|
||||
FAR struct ieee802154_mac_s *mac;
|
||||
#endif
|
||||
FAR struct spi_dev_s *spi;
|
||||
|
||||
/* Configure the interrupt pin */
|
||||
@ -246,9 +252,9 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IEEE802154_DEV
|
||||
#if defined(CONFIG_IEEE802154_DEV)
|
||||
/* Register a character driver to access the IEEE 802.15.4 radio from
|
||||
* user-space
|
||||
* user-space
|
||||
*/
|
||||
|
||||
ret = radio802154dev_register(radio, RADIO_DEVNAME);
|
||||
@ -258,6 +264,27 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
||||
RADIO_DEVNAME, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#elif 0 /* defined(CONFIG_IEEE802154_MAC) */
|
||||
/* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. */
|
||||
|
||||
mac = mac802154_register(radio, 0);
|
||||
if (radio == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* If want to call these APIs from userspace, you have to wrap your mac
|
||||
* in a character device via mac802154_device.c.
|
||||
*/
|
||||
|
||||
ret = mac802154dev_register(mac, MAC_DEVNAME);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to register the radio device %s: %d\n",
|
||||
RADIO_DEVNAME, ret);
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
@ -378,17 +378,26 @@ extern "C"
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Instanciate a 802.15.4 MAC from a 802.15.4 radio device.
|
||||
* To create a 802.15.4 MAC, you need to pass:
|
||||
* - an instance of a radio driver in radiodev
|
||||
* - a pointer to a structure that contains MAC callback routines to
|
||||
* handle confirmations and indications. NULL entries indicate no callback.
|
||||
* In return you get a mac structure that has pointers to MAC operations and
|
||||
* responses.
|
||||
* This API does not create any device accessible to userspace. If you want to
|
||||
* call these APIs from userspace, you have to wrap your mac in a character
|
||||
* device via mac802154_device.c .
|
||||
*/
|
||||
/****************************************************************************
|
||||
* Name: mac802154_register
|
||||
*
|
||||
* Description:
|
||||
* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device.
|
||||
* To create a 802.15.4 MAC, you need to pass:
|
||||
*
|
||||
* - an instance of a radio driver in radiodev
|
||||
* - a pointer to a structure that contains MAC callback routines to
|
||||
* handle confirmations and indications. NULL entries indicate no
|
||||
* callback.
|
||||
*
|
||||
* In return you get a mac structure that has pointers to MAC operations
|
||||
* and responses.
|
||||
*
|
||||
* This API does not create any device accessible to userspace. If you
|
||||
* want to call these APIs from userspace, you have to wrap your mac in a
|
||||
* character device via mac802154_device.c.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_mac_s *
|
||||
mac802154_register(FAR struct ieee802154_radio_s *radiodev,
|
||||
|
@ -524,6 +524,19 @@ static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
|
||||
*
|
||||
* Description:
|
||||
* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device.
|
||||
* To create a 802.15.4 MAC, you need to pass:
|
||||
*
|
||||
* - an instance of a radio driver in radiodev
|
||||
* - a pointer to a structure that contains MAC callback routines to
|
||||
* handle confirmations and indications. NULL entries indicate no
|
||||
* callback.
|
||||
*
|
||||
* In return you get a mac structure that has pointers to MAC operations
|
||||
* and responses.
|
||||
*
|
||||
* This API does not create any device accessible to userspace. If you
|
||||
* want to call these APIs from userspace, you have to wrap your mac in a
|
||||
* character device via mac802154_device.c.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -537,7 +550,8 @@ FAR struct ieee802154_mac_s *
|
||||
|
||||
mac = (FAR struct ieee802154_privmac_s *)
|
||||
kmm_zalloc(sizeof(struct ieee802154_privmac_s));
|
||||
if(!mac)
|
||||
|
||||
if (mac == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -546,7 +560,9 @@ FAR struct ieee802154_mac_s *
|
||||
|
||||
mac->pubmac.radio = radiodev;
|
||||
mac->pubmac.ops = mac802154ops;
|
||||
|
||||
mac802154_defaultmib(mac);
|
||||
mac802154_applymib(mac);
|
||||
|
||||
return &mac->pubmac;
|
||||
}
|
||||
|
@ -487,7 +487,8 @@ static int radio802154dev_ioctl(FAR struct file *filep, int cmd,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int radio802154dev_register(FAR struct ieee802154_radio_s *radio, FAR char *devname)
|
||||
int radio802154dev_register(FAR struct ieee802154_radio_s *radio,
|
||||
FAR char *devname)
|
||||
{
|
||||
FAR struct radio802154_devwrapper_s *dev;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user