Clicker2-STM32: Add some mostly bogus MAC initializatinon logic.

This commit is contained in:
Gregory Nutt 2017-03-23 07:20:10 -06:00
parent 40a8ef3c00
commit 9e4052e506
4 changed files with 68 additions and 15 deletions

View File

@ -47,6 +47,8 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/fs/fs.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 <nuttx/wireless/ieee80154/mrf24j40.h>
#include "stm32_gpio.h" #include "stm32_gpio.h"
@ -87,6 +89,7 @@
#endif #endif
#define RADIO_DEVNAME "/dev/mrf24j40" #define RADIO_DEVNAME "/dev/mrf24j40"
#define MAC_DEVNAME "/dev/mrf24j40mac"
/**************************************************************************** /****************************************************************************
* Private Types * 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) static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
{ {
FAR struct ieee802154_radio_s *radio; FAR struct ieee802154_radio_s *radio;
#ifdef CONFIG_IEEE802154_MAC
FAR struct ieee802154_mac_s *mac;
#endif
FAR struct spi_dev_s *spi; FAR struct spi_dev_s *spi;
/* Configure the interrupt pin */ /* Configure the interrupt pin */
@ -246,9 +252,9 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
return -ENODEV; return -ENODEV;
} }
#ifdef CONFIG_IEEE802154_DEV #if defined(CONFIG_IEEE802154_DEV)
/* Register a character driver to access the IEEE 802.15.4 radio from /* Register a character driver to access the IEEE 802.15.4 radio from
* user-space * user-space
*/ */
ret = radio802154dev_register(radio, RADIO_DEVNAME); ret = radio802154dev_register(radio, RADIO_DEVNAME);
@ -258,6 +264,27 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
RADIO_DEVNAME, ret); RADIO_DEVNAME, ret);
return 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 #endif
return OK; return OK;

View File

@ -378,17 +378,26 @@ extern "C"
* Public Function Prototypes * 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: * Name: mac802154_register
* - an instance of a radio driver in radiodev *
* - a pointer to a structure that contains MAC callback routines to * Description:
* handle confirmations and indications. NULL entries indicate no callback. * Create a 802.15.4 MAC device from a 802.15.4 compatible radio device.
* In return you get a mac structure that has pointers to MAC operations and * To create a 802.15.4 MAC, you need to pass:
* responses. *
* This API does not create any device accessible to userspace. If you want to * - an instance of a radio driver in radiodev
* call these APIs from userspace, you have to wrap your mac in a character * - a pointer to a structure that contains MAC callback routines to
* device via mac802154_device.c . * 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 * FAR struct ieee802154_mac_s *
mac802154_register(FAR struct ieee802154_radio_s *radiodev, mac802154_register(FAR struct ieee802154_radio_s *radiodev,

View File

@ -524,6 +524,19 @@ static int mac802154_rsporphan(FAR struct ieee802154_mac_s *mac,
* *
* Description: * Description:
* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. * 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 *) mac = (FAR struct ieee802154_privmac_s *)
kmm_zalloc(sizeof(struct ieee802154_privmac_s)); kmm_zalloc(sizeof(struct ieee802154_privmac_s));
if(!mac)
if (mac == NULL)
{ {
return NULL; return NULL;
} }
@ -546,7 +560,9 @@ FAR struct ieee802154_mac_s *
mac->pubmac.radio = radiodev; mac->pubmac.radio = radiodev;
mac->pubmac.ops = mac802154ops; mac->pubmac.ops = mac802154ops;
mac802154_defaultmib(mac); mac802154_defaultmib(mac);
mac802154_applymib(mac); mac802154_applymib(mac);
return &mac->pubmac; return &mac->pubmac;
} }

View File

@ -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; FAR struct radio802154_devwrapper_s *dev;