当前位置: 首页>>代码示例>>C++>>正文


C++ HardwareSPI类代码示例

本文整理汇总了C++中HardwareSPI的典型用法代码示例。如果您正苦于以下问题:C++ HardwareSPI类的具体用法?C++ HardwareSPI怎么用?C++ HardwareSPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HardwareSPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: m_csPin

Mrf24w::Mrf24w(HardwareSPI &spi, uint8_t csPin, uint8_t intPin) : m_csPin(csPin), m_intPin(intPin), m_processEventFn(NULL) {
  const stm32_pin_info *csPinInfo = &PIN_MAP[csPin];
  g_mrf24wInstance = this;

  m_securityType = WF_SECURITY_OPEN;
  m_wirelessMode = WF_INFRASTRUCTURE;

  wf_spi = spi.c_dev();
  wf_cs_port = csPinInfo->gpio_device;
  wf_cs_bit = csPinInfo->gpio_bit;
}
开发者ID:joeferner,项目名称:maple-mrf24w,代码行数:11,代码来源:mrf24w.cpp

示例2: defined

void RHHardwareSPI::begin() 
{
#if defined(SPI_HAS_TRANSACTION)
    // Perhaps this is a uniform interface for SPI?
    // Currently Teensy and ESP32 only
   uint32_t frequency;
   if (_frequency == Frequency16MHz)
       frequency = 16000000;
   else if (_frequency == Frequency8MHz)
       frequency = 8000000;
   else if (_frequency == Frequency4MHz)
       frequency = 4000000;
   else if (_frequency == Frequency2MHz)
       frequency = 2000000;
   else
       frequency = 1000000;

#if ((RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && (defined(ARDUINO_SAM_DUE) || defined(ARDUINO_ARCH_SAMD))) || defined(ARDUINO_ARCH_NRF52) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F4)
    // Arduino Due in 1.5.5 has its own BitOrder :-(
    // So too does Arduino Zero
    // So too does rogerclarkmelbourne/Arduino_STM32
    ::BitOrder bitOrder;
#else
    uint8_t bitOrder;
#endif

   if (_bitOrder == BitOrderLSBFirst)
       bitOrder = LSBFIRST;
   else
       bitOrder = MSBFIRST;
   
    uint8_t dataMode;
    if (_dataMode == DataMode0)
	dataMode = SPI_MODE0;
    else if (_dataMode == DataMode1)
	dataMode = SPI_MODE1;
    else if (_dataMode == DataMode2)
	dataMode = SPI_MODE2;
    else if (_dataMode == DataMode3)
	dataMode = SPI_MODE3;
    else
	dataMode = SPI_MODE0;

    // Save the settings for use in transactions
   _settings = SPISettings(frequency, bitOrder, dataMode);
   SPI.begin();
    
#else // SPI_HAS_TRANSACTION
    
    // Sigh: there are no common symbols for some of these SPI options across all platforms
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) || (RH_PLATFORM == RH_PLATFORM_UNO32) || (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE || RH_PLATFORM == RH_PLATFORM_NRF52)
    uint8_t dataMode;
    if (_dataMode == DataMode0)
	dataMode = SPI_MODE0;
    else if (_dataMode == DataMode1)
	dataMode = SPI_MODE1;
    else if (_dataMode == DataMode2)
	dataMode = SPI_MODE2;
    else if (_dataMode == DataMode3)
	dataMode = SPI_MODE3;
    else
	dataMode = SPI_MODE0;
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(__arm__) && defined(CORE_TEENSY)
    // Temporary work-around due to problem where avr_emulation.h does not work properly for the setDataMode() cal
    SPCR &= ~SPI_MODE_MASK;
#else
 #if ((RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && defined(ARDUINO_ARCH_SAMD)) || defined(ARDUINO_ARCH_NRF52)
    // Zero requires begin() before anything else :-)
    SPI.begin();
 #endif

    SPI.setDataMode(dataMode);
#endif

#if ((RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && (defined(ARDUINO_SAM_DUE) || defined(ARDUINO_ARCH_SAMD))) || defined(ARDUINO_ARCH_NRF52) || defined (ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F4)
    // Arduino Due in 1.5.5 has its own BitOrder :-(
    // So too does Arduino Zero
    // So too does rogerclarkmelbourne/Arduino_STM32
    ::BitOrder bitOrder;
#else
    uint8_t bitOrder;
#endif
    if (_bitOrder == BitOrderLSBFirst)
	bitOrder = LSBFIRST;
    else
	bitOrder = MSBFIRST;
    SPI.setBitOrder(bitOrder);
    uint8_t divider;
    switch (_frequency)
    {
	case Frequency1MHz:
	default:
#if F_CPU == 8000000
	    divider = SPI_CLOCK_DIV8;
#else
	    divider = SPI_CLOCK_DIV16;
#endif
	    break;

	case Frequency2MHz:
//.........这里部分代码省略.........
开发者ID:Yveaux,项目名称:RadioHead,代码行数:101,代码来源:RHHardwareSPI.cpp

示例3: usingInterrupt

void RHHardwareSPI::usingInterrupt(uint8_t interrupt)
{
#if defined(SPI_HAS_TRANSACTION)
    SPI.usingInterrupt(interrupt);
#endif
}
开发者ID:Yveaux,项目名称:RadioHead,代码行数:6,代码来源:RHHardwareSPI.cpp

示例4: detachInterrupt

void RHHardwareSPI::detachInterrupt() 
{
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO || RH_PLATFORM == RH_PLATFORM_NRF52)
    SPI.detachInterrupt();
#endif
}
开发者ID:Yveaux,项目名称:RadioHead,代码行数:6,代码来源:RHHardwareSPI.cpp

示例5: beginTransaction

void RHHardwareSPI::beginTransaction()
{
#if defined(SPI_HAS_TRANSACTION)
    SPI.beginTransaction(_settings);
#endif
}
开发者ID:Yveaux,项目名称:RadioHead,代码行数:6,代码来源:RHHardwareSPI.cpp

示例6:

void GDClass::wr16(unsigned int addr, unsigned int v)
{
  __wstart(addr);
  SPI.transfer(lowByte(v));
  SPI.transfer(highByte(v));
  __end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:7,代码来源:Gameduino.cpp

示例7: xhide

void GDClass::xhide()
{
  SPI.transfer(lowByte(400));
  SPI.transfer(highByte(400));
  SPI.transfer(lowByte(400));
  SPI.transfer(highByte(400));
  spr++;
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:8,代码来源:Gameduino.cpp

示例8: voice

void GDClass::voice(int v, byte wave, unsigned int freq, byte lamp, byte ramp)
{
  __wstart(VOICES + (v << 2));
  SPI.transfer(lowByte(freq));
  SPI.transfer(highByte(freq) | (wave << 7));
  SPI.transfer(lamp);
  SPI.transfer(ramp);
  __end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:9,代码来源:Gameduino.cpp

示例9: sprite

void GDClass::sprite(int spr, int x, int y, byte image, byte palette, byte rot, byte jk)
{
  __wstart(RAM_SPR + (spr << 2));
  SPI.transfer(lowByte(x));
  SPI.transfer((palette << 4) | (rot << 1) | (highByte(x) & 1));
  SPI.transfer(lowByte(y));
  SPI.transfer((jk << 7) | (image << 1) | (highByte(y) & 1));
  __end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:9,代码来源:Gameduino.cpp

示例10: fill

void GDClass::fill(int addr, byte v, unsigned int count)
{
  __wstart(addr);
  while (count--)
    SPI.transfer(v);
  __end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:7,代码来源:Gameduino.cpp

示例11: sendFrame

void Element_GFX::sendFrame()
{
  int pixnum = 0;
  int idx = 0;
  uint16 data[3];
  
  // generate and write out data
  while (pixnum < ELEMENT_LEDS)
  {
    idx = 3 * ((ELEMENT_LEDS - 1) - pixnum);
    
    data[0] = gamma_table[framebuffer[idx + 0]];
    data[1] = gamma_table[framebuffer[idx + 1]];
    data[2] = gamma_table[framebuffer[idx + 2]];

    // sending out data on SPI - Teensy
    // one transfer for each byte
    led_spi.write((byte*)data, 6);  // sending out data on SPI 

    ++pixnum;
   }
   
   // toggle latch pin
   delay(1);
   digitalWrite(ELEMENT_LATCH, HIGH);
   delay(1);
   digitalWrite(ELEMENT_LATCH, LOW);
}
开发者ID:4ndreas,项目名称:PixelController,代码行数:28,代码来源:element_GFX.cpp

示例12: loop

void loop() {
   /* Send message */
   digitalWrite(NSS, LOW);
   spi1.write(buf, sizeof buf);
   digitalWrite(NSS, HIGH);
   delay(1000);
}
开发者ID:DuinoPilot,项目名称:openstm32sw,代码行数:7,代码来源:spi_master.cpp

示例13: rd

byte GDClass::rd(unsigned int addr)
{
  __start(addr);
  byte r = SPI.transfer(0);
  __end();
  return r;
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:7,代码来源:Gameduino.cpp

示例14: putstr

void GDClass::putstr(int x, int y, const char *s)
{
  GD.__wstart((y << 6) + x);
  while (*s)
    SPI.transfer(*s++);
  GD.__end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:7,代码来源:Gameduino.cpp

示例15: copy

void GDClass::copy(unsigned int addr, PROGMEM prog_uchar *src, int count)
{
  __wstart(addr);
  while (count--) {
    SPI.transfer(pgm_read_byte_near(src));
    src++;
  }
  __end();
}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:9,代码来源:Gameduino.cpp


注:本文中的HardwareSPI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。