ArduinoGalileo+CC3000测试wifi程序出现卡死现象,跳不出while循环
硬件:ArduinoGalileo+CC3000
测试Galileo_CC3000_Connecter程序
在开始初始化时
void Initialize(void)
{
unsigned char fancyBuffer[MAC_ADDR_LEN];
if (isInitialized) {
Serial.println("CC3000 already initialized. Shutting down and restarting...");
wlan_stop();
delay(1000);
}
Serial.println("Initializing CC3000...");
CC3000_Init();
Serial.println(" CC3000 init complete.");
if (nvmem_read_sp_version(fancyBuffer)==0) {
Serial.print(" Firmware version is: ");
Serial.print(fancyBuffer[0], DEC);
Serial.print(".");
Serial.println(fancyBuffer[1], DEC);
}
else {
Serial.println("Unable to get firmware version. Can't continue.");
return;
}
if (nvmem_get_mac_address(fancyBuffer)==0) {
Serial.print(" MAC address: ");
for (byte i=0; i<MAC_ADDR_LEN; i++) {
if (i!=0) {
Serial.print(":");
}
Serial.print(fancyBuffer[i], HEX);
}
Serial.println();
isInitialized=true;
}
else {
Serial.println("Unable to get MAC address. Can't continue.");
}
}
在CC3000_Init();处卡死,最后追根溯源在是在ArduinoCC3000SPI.C中的spiwrite函数中卡死。
long
SpiWrite(unsigned char *pUserBuffer, unsigned short usLength)
{
unsigned char ucPad = 0;
//
// Figure out the total length of the packet in order to figure out if there is padding or not
//
Serial.println("a1");
if(!(usLength & 0x0001))
{
ucPad++;
}
Serial.println("a1");
pUserBuffer[0] = WRITE;
pUserBuffer[1] = HI(usLength + ucPad);
pUserBuffer[2] = LO(usLength + ucPad);
pUserBuffer[3] = 0;
pUserBuffer[4] = 0;
Serial.println("a1");
usLength += (SPI_HEADER_SIZE + ucPad);
Serial.println("a1");
// The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
// for the purpose of overrun detection. If the magic number is overwritten - buffer overrun
// occurred - and we will be stuck here forever!
if (wlan_tx_buffer[CC3000_TX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)
{
while (1)
;
}
Serial.println("b1");
if (sSpiInformation.ulSpiState == eSPI_STATE_POWERUP)
{
while (sSpiInformation.ulSpiState != eSPI_STATE_INITIALIZED) {
Serial.println("no");//在此处一直跳不出
}
;
}
Serial.println("a1");//此句及以下未执行
if (sSpiInformation.ulSpiState == eSPI_STATE_INITIALIZED)
{
//
// This is time for first TX/RX transactions over SPI: the IRQ is down - so need to send read buffer size command
//
SpiFirstWrite(pUserBuffer, usLength);
}
else
{
//
// We need to prevent here race that can occur in case two back to back packets are sent to the
// device, so the state will move to IDLE and once again to not IDLE due to IRQ
//
tSLInformation.WlanInterruptDisable();
while (sSpiInformation.ulSpiState != eSPI_STATE_IDLE)
{
;
}
sSpiInformation.ulSpiState = eSPI_STATE_WRITE_IRQ;
sSpiInformation.pTxPacket = pUserBuffer;
sSpiInformation.usTxPacketLength = usLength;
//
// Assert the CS line and wait till SSI IRQ line is active and then initialize write operation
//
Set_CC3000_CS_Active();
//
// Re-enable IRQ - if it was not disabled - this is not a problem...
//
tSLInformation.WlanInterruptEnable();
//
// check for a missing interrupt between the CS assertion and enabling back the interrupts
//
if (tSLInformation.ReadWlanInterruptPin() == 0)
{
SpiWriteDataSynchronous(sSpiInformation.pTxPacket, sSpiInformation.usTxPacketLength);
sSpiInformation.ulSpiState = eSPI_STATE_IDLE;
Set_CC3000_CS_NotActive();
}
}
//
// Due to the fact that we are currently implementing a blocking situation
// here we will wait till end of transaction
//
while (eSPI_STATE_IDLE != sSpiInformation.ulSpiState)
;
return(0);
}
百思不得其解,求助。
初始化就没有成功,你能否参考一下这两个链接:
http://processors.wiki.ti.com/index.php/CC3000_Host_Driver_Porting_Guide
http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI)
着重看一下SPI那几条线上的波形是不是对的。