clicker2-stm32: Adds support for USB RNDIS device

This commit is contained in:
Anthony Merlino 2017-11-22 14:03:58 -05:00
parent 50f05d7514
commit 3be15c0f8f
3 changed files with 43 additions and 2 deletions

View File

@ -166,4 +166,13 @@ config CLICKER2_STM32_SYSLOG_FILE_DELAY
endif # CLICKER2_STM32_SYSLOG_FILE
config CLICKER2_STM32_RNDIS_MACADDR
hex "RNDIS MAC address"
default 0xfadedeadbeef
depends on RNDIS
---help---
If the hardware has no built-in MAC address then the fixed,
software-assigned MAC address MAC address must provided
with this selection.
endif # ARCH_BOARD_CLICKER2_STM32

View File

@ -52,9 +52,24 @@
# include <nuttx/usb/usbmonitor.h>
#endif
#ifdef CONFIG_RNDIS
# include <nuttx/usb/rndis.h>
# include <net/if.h>
#endif
#include "stm32.h"
#include "clicker2-stm32.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_RNDIS
# ifndef CONFIG_CLICKER2_STM32_RNDIS_MACADDR
# define CONFIG_CLICKER2_STM32_RNDIS_MACADDR 0xfadedeadbeef
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -168,6 +183,25 @@ int stm32_bringup(void)
}
#endif
#ifdef CONFIG_RNDIS
uint8_t mac[IFHWADDRLEN];
mac[0] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 5)) & 0xff;
mac[1] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 4)) & 0xff;
mac[2] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 3)) & 0xff;
mac[3] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 2)) & 0xff;
mac[4] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 1)) & 0xff;
mac[5] = (CONFIG_CLICKER2_STM32_RNDIS_MACADDR >> (8 * 0)) & 0xff;
/* Register USB RNDIS Driver */
ret = usbdev_rndis_initialize(mac);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: usbdev_rndis_initialize() failed %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}

View File

@ -228,9 +228,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
FAR struct ieee802154_radio_s *radio;
MACHANDLE mac;
FAR struct spi_dev_s *spi;
#ifdef CONFIG_IEEE802154_NETDEV
int ret;
#endif
/* Configure the interrupt pin */