Esempio n. 1
0
int init_spi(void)
{

  DEBUGPRINT_F("\tCC3000: init_spi\n\r");
  
  /* Set POWER_EN pin to output and disable the CC3000 by default */
  pinMode(g_vbatPin, OUTPUT);
  digitalWrite(g_vbatPin, 0);
  delay(500);

  /* Set CS pin to output (don't de-assert yet) */
  pinMode(g_csPin, OUTPUT);
  //pinMode(g_csPin - 1, OUTPUT);
  
  /* Set interrupt/gpio pin to input */
//#if defined(INPUT_PULLUP)
//  pinMode(g_irqPin, INPUT_PULLUP);/
//#else
  pinMode(g_irqPin, INPUT);
 // digitalWrite(g_irqPin, HIGH); // w/weak pullup
//#endif

  SpiConfigStoreOld(); // prime ccspi_old* values for DEASSERT

  /* Initialise SPI (Mode 1) */
  
  theCcspi->setDataMode(SPI_MODE1);
  theCcspi->setBitOrder(true);
  //theCcspi->setClockDivider(g_SPIspeed);
  DEBUGPRINT_F("\tCC3000: init_spi1\n\r");
  
  theCcspi->begin();
	
  DEBUGPRINT_F("\tCC3000: init_spi2\n\r");
  
  
  SpiConfigStoreMy(); // prime ccspi_my* values for ASSERT

  // Newly-initialized SPI is in the same state that ASSERT_CS will set it
  // to.  Invoke DEASSERT (which also restores SPI registers) so the next
  // ASSERT call won't clobber the ccspi_old* values -- we need those!
  CC3000_DEASSERT_CS;

  /* ToDo: Configure IRQ interrupt! */

  DEBUGPRINT_F("\tCC3000: Finished init_spi\n\r");
  
  return(ESUCCESS);
}
Esempio n. 2
0
int init_spi(void)
{

  DEBUGPRINT_F("\tCC3000: init_spi\n\r");
  
  /* Set POWER_EN pin to output and disable the CC3000 by default */
  pinMode(g_vbatPin, OUTPUT);
  digitalWrite(g_vbatPin, 0);
  delay(500);

  /* Set CS pin to output (don't de-assert yet) */
  pinMode(g_csPin, OUTPUT);

  /* Set interrupt/gpio pin to input */
#if defined(INPUT_PULLUP)
  pinMode(g_irqPin, INPUT_PULLUP);
#else
  pinMode(g_irqPin, INPUT);
  digitalWrite(g_irqPin, HIGH); // w/weak pullup
#endif

  SpiConfigStoreOld(); // prime ccspi_old* values for DEASSERT

  /* Initialise SPI (Mode 1) */
  SPI.begin();
  SPI.setDataMode(SPI_MODE1);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(g_SPIspeed);
  
  SpiConfigStoreMy(); // prime ccspi_my* values for ASSERT

  // Newly-initialized SPI is in the same state that ASSERT_CS will set it
  // to.  Invoke DEASSERT (which also restores SPI registers) so the next
  // ASSERT call won't clobber the ccspi_old* values -- we need those!
#ifdef SPI_HAS_TRANSACTION
  SPI.usingInterrupt(g_IRQnum);
  digitalWrite(g_csPin, HIGH);  // same as CC3000_DEASSERT_CS, but not
  SpiConfigPop();               // SPI.endTransaction, because none began
#else
  CC3000_DEASSERT_CS;
#endif

  /* ToDo: Configure IRQ interrupt! */

  DEBUGPRINT_F("\tCC3000: Finished init_spi\n\r");
  
  return(ESUCCESS);
}