IoT Board/Spirit: Fix a few issues that interfered with testing. Move console to the VCOM port (USART) for all configurations. Rename the spirit-mac configuration to spirit-6lowpan. Add lots of debug output the spirit network driver.

This commit is contained in:
Gregory Nutt 2017-07-31 18:25:59 -06:00
parent cd3ca1140e
commit 959f2042a4
7 changed files with 66 additions and 43 deletions

View File

@ -196,18 +196,6 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: stm32_boardinitialize
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
*
************************************************************************************/
void stm32_boardinitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}

View File

@ -38,7 +38,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32L4_UART4=y
CONFIG_UART4_SERIAL_CONSOLE=y
CONFIG_STM32L4_USART1=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WATCHDOG=y

View File

@ -21,14 +21,13 @@ CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_IOB_BUFSIZE=96
CONFIG_IOB_NBUFFERS=32
CONFIG_IOB_NCHAINS=8
CONFIG_IOB_THROTTLE=0
CONFIG_LIBM=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=2
CONFIG_NET_6LOWPAN=y
CONFIG_NET_6LOWPAN_FRAMELEN=96
CONFIG_NET_6LOWPAN=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMPv6=y
CONFIG_NET_IPv6=y
@ -60,8 +59,8 @@ CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32L4_SPI3=y
CONFIG_STM32L4_UART4=y
CONFIG_UART4_SERIAL_CONSOLE=y
CONFIG_STM32L4_USART1=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WATCHDOG=y
CONFIG_WIRELESS_PKTRADIO=y

View File

@ -73,7 +73,7 @@
# undef HAVE_SPSGRF
#endif
#if !defined(CONFIG_SCHED_HPWORK) || !defined(CONFIG_SCHED_LPWORK)
#if !defined(CONFIG_SCHED_HPWORK) && !defined(CONFIG_SCHED_LPWORK)
# undef HAVE_SPSGRF
#endif
@ -120,10 +120,6 @@
GPIO_SPEED_50MHz | GPIO_OUTPUT_SET | \
GPIO_PORTB | GPIO_PIN15)
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public data
****************************************************************************/

View File

@ -1771,6 +1771,8 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
FAR struct spirit_library_s *spirit = &priv->spirit;
int ret;
wlinfo("Initialize spirit hardware\n");
/* Configures the Spirit1 radio library */
spirit->spi = spi;
@ -1778,10 +1780,12 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
/* Reset the Spirit1 radio part */
wlinfo("Spirit Reset\n");
DEBUGASSERT(priv->lower != NULL && priv->lower->reset != NULL);
ret = priv->lower->reset(priv->lower) ;
if (ret < 0)
{
wlerr("ERROR: SDN reset failed: %d\n", ret);
return ret;
}
@ -1790,6 +1794,7 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
ret = spirit_command(spirit, COMMAND_SRES);
if (ret < 0)
{
wlerr("ERROR: Soft reset failed} %d\n", ret);
return ret;
}
@ -1797,91 +1802,109 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
/* Perform VCO calibration WA when the radio is initialized */
wlinfo("Peform VCO calibration\n");
spirit_radio_enable_wavco_calibration(spirit, S_ENABLE);
/* Configure the Spirit1 radio part */
wlinfo("Configure the spirit radio\n");
ret = spirit_radio_initialize(spirit, &g_radio_init);
if (ret < 0)
{
wlerr("ERROR: pirit_radio_initialize failed: %d\n", ret);
return ret;
}
ret = spirit_radio_set_palevel_dbm(spirit, 0, SPIRIT_POWER_DBM);
if (ret < 0)
{
wlerr("ERROR: spirit_radio_set_palevel_dbm failed: %d\n", ret);
return ret;
}
ret =spirit_radio_set_palevel_maxindex(spirit, 0);
if (ret < 0)
{
wlerr("ERROR: spirit_radio_set_palevel_maxindex failed: %d\n", ret);
return ret;
}
/* Configures the SPIRIT1 packet handling logic */
wlinfo("Configure the basic packets\n");
ret = spirit_pktbasic_initialize(spirit, &g_pktbasic_init);
if (ret < 0)
{
wlerr("ERROR: spirit_radio_set_palevel_maxindex failed: %d\n", ret);
return ret;
}
/* Configure address filtering */
wlinfo("Configure address filtering\n");
ret = spirit_pktbasic_addr_initialize(spirit, &g_addrinit);
if (ret < 0)
{
wlerr("ERROR: spirit_pktbasic_addr_initialize failed: %d\n", ret);
return ret;
}
/* Enable the following interrupt sources, routed to GPIO */
wlinfo("Configure Interrupts\n");
ret = spirit_irq_disable_all(spirit);
if (ret < 0)
{
wlerr("ERROR: spirit_irq_disable_all failed: %d\n", ret);
return ret;
}
ret = spirit_irq_clr_pending(spirit);
if (ret < 0)
{
wlerr("ERROR: spirit_irq_clr_pending failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, TX_DATA_SENT, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable TX_DATA_SENT failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, RX_DATA_READY, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable RX_DATA_READY failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, VALID_SYNC, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable VALID_SYNC failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, RX_DATA_DISC, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable RX_DATA_DISC failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, TX_FIFO_ERROR, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable TX_FIFO_ERROR failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, RX_FIFO_ERROR, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable RX_FIFO_ERROR failed: %d\n", ret);
return ret;
}
@ -1889,39 +1912,46 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
ret = spirit_irq_enable(spirit, TX_FIFO_ALMOST_EMPTY, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable TX_FIFO_ALMOST_EMPTY failed: %d\n", ret);
return ret;
}
ret = spirit_irq_enable(spirit, RX_FIFO_ALMOST_FULL, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: Enable RX_FIFO_ALMOST_FULL failed: %d\n", ret);
return ret;
}
#endif
/* Configure Spirit1 */
wlinfo("Configure Spriti1\n");
ret = spirit_radio_persistentrx(spirit, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: spirit_radio_persistentrx failed: %d\n", ret);
return ret;
}
ret = spirit_qi_set_sqithreshold(spirit, SQI_TH_0);
if (ret < 0)
{
wlerr("ERROR: spirit_qi_set_sqithreshold failed: %d\n", ret);
return ret;
}
ret = spirit_qi_enable_sqicheck(spirit, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: spirit_qi_enable_sqicheck failed: %d\n", ret);
return ret;
}
ret = spirit_qi_set_rssithreshold_dbm(spirit, SPIRIT_CCA_THRESHOLD);
if (ret < 0)
{
wlerr("ERROR: spirit_qi_set_rssithreshold_dbm failed: %d\n", ret);
return ret;
}
@ -1929,18 +1959,21 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
SQI_ABOVE_THRESHOLD);
if (ret < 0)
{
wlerr("ERROR: spirit_timer_set_rxtimeout_stopcondition failed: %d\n", ret);
return ret;
}
ret = spirit_timer_set_rxtimeout_counter(spirit, 0); /* 0=No timeout */
if (ret < 0)
{
wlerr("ERROR: spirit_timer_set_rxtimeout_counter failed: %d\n", ret);
return ret;
}
ret = spirit_radio_afcfreezeonsync(spirit, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: spirit_radio_afcfreezeonsync failed: %d\n", ret);
return ret;
}
@ -1948,31 +1981,38 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
ret = spirit_calibration_rco(spirit, S_ENABLE);
if (ret < 0)
{
wlerr("ERROR: spirit_calibration_rco failed: %d\n", ret);
return ret;
}
#endif
/* Configure the radio to route the IRQ signal to its GPIO 3 */
wlinfo("Configure Spirt GPIOs\n");
ret = spirit_gpio_initialize(spirit, &g_gpioinit);
if (ret < 0)
{
wlerr("ERROR: spirit_gpio_initialize failed: %d\n", ret);
return ret;
}
/* Setup CSMA/CA */
wlinfo("Configure Spirt CSMA\n");
ret = spirit_csma_initialize(spirit, &g_csma_init);
if (ret < 0)
{
wlerr("ERROR: spirit_csma_initialize failed: %d\n", ret);
return ret;
}
/* Puts the SPIRIT1 in STANDBY mode (125us -> rx/tx) */
wlinfo("Go to STNDBY\n");
ret = spirit_command(spirit, CMD_STANDBY);
if (ret < 0)
{
wlerr("ERROR: Failed to go to STANDBY: %d\n", ret);
return ret;
}
@ -2064,23 +2104,9 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
#endif
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
/* Put the interface in the down state. This usually amounts to resetting
* the device and/or calling spirit_ifdown().
*/
/* Make sure that the PktRadio common logic has been initialized */
/* Read the MAC address from the hardware into dev->d_mac.ether.ether_addr_octet */
/* Register the device with the OS so that socket IOCTLs can be performed. */
(void)netdev_register(dev, NET_LL_PKTRADIO);
/* Attach irq */
ret = lower->attach(lower, spirit_interrupt, priv);
if (ret < 0)
{
goto errout_with_pktbuf;
}
pktradio_metadata_initialize();
/* Initialize device */
@ -2091,9 +2117,23 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
goto errout_with_attach;
}
/* Make sure that the PktRadio common logic has been initialized */
/* Register the device with the OS so that socket IOCTLs can be performed. */
pktradio_metadata_initialize();
ret = netdev_register(dev, NET_LL_PKTRADIO);
if (ret < 0)
{
wlerr("ERROR: netdev_register failed: %d\n", ret);
goto errout_with_attach;
}
/* Attach irq */
ret = lower->attach(lower, spirit_interrupt, priv);
if (ret < 0)
{
wlerr("ERROR: Failed to attach interrupt: %d\n", ret);
goto errout_with_pktbuf;
}
/* Enable Radio IRQ */

View File

@ -185,7 +185,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
#endif
int devnum;
if (dev)
if (dev != NULL)
{
#ifdef CONFIG_NET_MULTILINK
/* We are supporting multiple network devices and using different link

View File

@ -16,7 +16,7 @@ config NET_6LOWPAN_FRAG
config NET_6LOWPAN_FRAMELEN
int "IEEE802.15.4 MAC Frame Length"
default 127
range 127 999999
range 1 999999
---help---
Some wireless devices may use non-standard frame lengths. This
setting should never be smaller than 127.