Spirit: Add more debug output. Make sure device is in READY state after reset and before changing to STANDBY.
This commit is contained in:
parent
ceca6c69a8
commit
09bb6ff16b
@ -496,6 +496,7 @@ static int spirit_transmit(FAR struct spirit_driver_s *priv)
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_TX, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to TX state: %d\n", ret);
|
||||
goto errout_with_iob;
|
||||
}
|
||||
|
||||
@ -1206,6 +1207,7 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_READY, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to READY state: %d\n", ret);
|
||||
goto error_with_ifalmostup;
|
||||
}
|
||||
|
||||
@ -1220,6 +1222,7 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_RX, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to RX state: %d\n", ret);
|
||||
goto error_with_ifalmostup;
|
||||
}
|
||||
|
||||
@ -1336,6 +1339,7 @@ static int spirit_ifdown(FAR struct net_driver_s *dev)
|
||||
status = spirit_waitstatus(spirit, MC_STATE_READY, 5);
|
||||
if (status < 0 && ret == 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to READY state: %d\n", ret);
|
||||
ret = status;
|
||||
}
|
||||
|
||||
@ -1350,6 +1354,7 @@ static int spirit_ifdown(FAR struct net_driver_s *dev)
|
||||
status = spirit_waitstatus(spirit, MC_STATE_STANDBY, 5);
|
||||
if (status < 0 && ret == 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to STANBY state: %d\n", ret);
|
||||
ret = status;
|
||||
}
|
||||
|
||||
@ -1714,6 +1719,8 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
||||
spirit->spi = spi;
|
||||
spirit->xtal_frequency = SPIRIT_XTAL_FREQUENCY;
|
||||
|
||||
priv->ifup = false;
|
||||
|
||||
/* Reset the Spirit1 radio part */
|
||||
|
||||
wlinfo("Spirit Reset\n");
|
||||
@ -1727,14 +1734,21 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
||||
|
||||
/* Soft reset of Spirit1 core */
|
||||
|
||||
#if 0
|
||||
ret = spirit_command(spirit, COMMAND_SRES);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Soft reset failed} %d\n", ret);
|
||||
wlerr("ERROR: Soft reset failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
priv->ifup = false;
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_READY, 100);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to READY state: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Perform VCO calibration WA when the radio is initialized */
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "spirit_config.h"
|
||||
#include "spirit_types.h"
|
||||
@ -176,7 +177,6 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
|
||||
uint8_t regval;
|
||||
uint8_t value;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Workaround for Vtune */
|
||||
|
||||
@ -203,6 +203,15 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_CHANNEL_SPACE(radioinit->chspace, spirit->xtal_frequency));
|
||||
DEBUGASSERT(IS_F_DEV(radioinit->freqdev, spirit->xtal_frequency));
|
||||
|
||||
/* Make sure that we are in the READY state */
|
||||
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_READY, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to READY state: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Disable the digital, ADC, SMPS reference clock divider if fXO > 24MHz or
|
||||
* fXO < 26MHz
|
||||
*/
|
||||
@ -215,13 +224,14 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
|
||||
|
||||
/* Delay for state transition */
|
||||
|
||||
for (i = 0; i != 0xff; i++);
|
||||
usleep(100);
|
||||
|
||||
/* Wait for the device to enter STANDBY */
|
||||
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_STANDBY, 5000);
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_STANDBY, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to STANDBY state: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -251,13 +261,14 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
|
||||
|
||||
/* Delay for state transition */
|
||||
|
||||
for (i = 0; i != 0xff; i++);
|
||||
usleep(100);
|
||||
|
||||
/* Make sure that the device becomes READY */
|
||||
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_READY, 5000);
|
||||
ret = spirit_waitstatus(spirit, MC_STATE_READY, 5);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to go to READY state: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
@ -565,6 +566,14 @@ int spirit_waitstatus(FAR struct spirit_library_s *spirit,
|
||||
systime_t elapsed;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_DEBUG_SPI_INFO
|
||||
/* If the SPI logic is generating debug output, then a longer timeout is
|
||||
* probably needed.
|
||||
*/
|
||||
|
||||
msec <<= 4;
|
||||
#endif
|
||||
|
||||
/* Convert the MSEC timedelay to clock ticks, making sure that the
|
||||
* resulting delay in ticks is greater than or equal to the requested time
|
||||
* in MSEC.
|
||||
@ -598,5 +607,14 @@ int spirit_waitstatus(FAR struct spirit_library_s *spirit,
|
||||
}
|
||||
while (spirit->u.state.MC_STATE != state && elapsed <= ticks);
|
||||
|
||||
return (spirit->u.state.MC_STATE == state) ? OK : -ETIMEDOUT;
|
||||
if (spirit->u.state.MC_STATE == state)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
wlwarn("WARNING: Timed out: %lu > %lu (%u msec)\n",
|
||||
(unsigned long)elapsed, (unsigned long)ticks, msec);
|
||||
wlwarn(" MC status: current=%02x desired=%02x\n",
|
||||
spirit->u.state.MC_STATE, state);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user