本文整理汇总了C++中HardwareSPI::setBitOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareSPI::setBitOrder方法的具体用法?C++ HardwareSPI::setBitOrder怎么用?C++ HardwareSPI::setBitOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareSPI
的用法示例。
在下文中一共展示了HardwareSPI::setBitOrder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: begin
void GDClass::begin()
{
delay(250); // give Gameduino time to boot
pinMode(SS_PIN, OUTPUT);
#ifdef BOARD_maple
SPI.begin(SPI_4_5MHZ, MSBFIRST, 0);
#else
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPSR = (1 << SPI2X);
#endif
digitalWrite(SS_PIN, HIGH);
GD.wr(J1_RESET, 1); // HALT coprocessor
__wstart(RAM_SPR); // Hide all sprites
for (int i = 0; i < 512; i++)
GD.xhide();
__end();
fill(RAM_PIC, 0, 1024 * 10); // Zero all character RAM
fill(RAM_SPRPAL, 0, 2048); // Sprite palletes black
fill(RAM_SPRIMG, 0, 64 * 256); // Clear all sprite data
fill(VOICES, 0, 256); // Silence
fill(PALETTE16A, 0, 128); // Black 16-, 4-palletes and COMM
GD.wr16(SCROLL_X, 0);
GD.wr16(SCROLL_Y, 0);
GD.wr(JK_MODE, 0);
GD.wr(SPR_DISABLE, 0);
GD.wr(SPR_PAGE, 0);
GD.wr(IOMODE, 0);
GD.wr16(BG_COLOR, 0);
GD.wr16(SAMPLE_L, 0);
GD.wr16(SAMPLE_R, 0);
GD.wr16(SCREENSHOT_Y, 0);
GD.wr(MODULATOR, 64);
}
示例2: begin
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:
//.........这里部分代码省略.........
示例3: begin
void RHHardwareSPI::begin()
{
// 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)
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
SPI.setDataMode(dataMode);
#endif
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(SPI_HAS_TRANSACTION)
uint32_t frequency32;
if (_frequency == Frequency16MHz) {
frequency32 = 16000000;
} else if (_frequency == Frequency8MHz) {
frequency32 = 8000000;
} else if (_frequency == Frequency4MHz) {
frequency32 = 4000000;
} else if (_frequency == Frequency2MHz) {
frequency32 = 2000000;
} else {
frequency32 = 1000000;
}
uint8_t bOrder;
if (_bitOrder == BitOrderLSBFirst) {
bOrder = LSBFIRST;
} else {
bOrder = MSBFIRST;
}
_settings = SPISettings(frequency32, bOrder, dataMode);
#endif
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && !defined(CORE_TEENSY)
// Arduino Due in 1.5.5 has its own BitOrder :-(
::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:
#if F_CPU == 8000000
divider = SPI_CLOCK_DIV4;
#else
divider = SPI_CLOCK_DIV8;
#endif
break;
case Frequency4MHz:
#if F_CPU == 8000000
divider = SPI_CLOCK_DIV2;
#else
divider = SPI_CLOCK_DIV4;
#endif
break;
case Frequency8MHz:
divider = SPI_CLOCK_DIV2; // 4MHz on an 8MHz Arduino
break;
case Frequency16MHz:
divider = SPI_CLOCK_DIV2; // Not really 16MHz, only 8MHz. 4MHz on an 8MHz Arduino
break;
}
SPI.setClockDivider(divider);
SPI.begin();
#elif (RH_PLATFORM == RH_PLATFORM_STM32) // Maple etc
spi_mode dataMode;
// Hmmm, if we do this as a switch, GCC on maple gets v confused!
if (_dataMode == DataMode0)
//.........这里部分代码省略.........
示例4: begin
void RHHardwareSPI::begin()
{
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) || (RH_PLATFORM == RH_PLATFORM_UNO32)
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
SPI.setDataMode(dataMode);
#endif
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && !defined(CORE_TEENSY)
// Arduino Due in 1.5.5 has its own BitOrder :-(
::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:
divider = SPI_CLOCK_DIV16;
break;
case Frequency2MHz:
divider = SPI_CLOCK_DIV8;
break;
case Frequency4MHz:
divider = SPI_CLOCK_DIV4;
break;
case Frequency8MHz:
divider = SPI_CLOCK_DIV2;
break;
case Frequency16MHz:
divider = SPI_CLOCK_DIV2; // Not really 16MHz, only 8
break;
}
SPI.setClockDivider(divider);
SPI.begin();
#elif (RH_PLATFORM == RH_PLATFORM_STM32) // Maple etc
spi_mode dataMode;
// Hmmm, if we do this as a switch, GCC on maple gets v confused!
if (_dataMode == DataMode0)
dataMode = SPI_MODE_0;
else if (_dataMode == DataMode1)
dataMode = SPI_MODE_1;
else if (_dataMode == DataMode2)
dataMode = SPI_MODE_2;
else if (_dataMode == DataMode3)
dataMode = SPI_MODE_3;
else
dataMode = SPI_MODE_0;
uint32 bitOrder;
if (_bitOrder == BitOrderLSBFirst)
bitOrder = LSBFIRST;
else
bitOrder = MSBFIRST;
SPIFrequency frequency; // Yes, I know these are not exact equivalents.
switch (_frequency)
{
case Frequency1MHz:
default:
frequency = SPI_1_125MHZ;
break;
case Frequency2MHz:
frequency = SPI_2_25MHZ;
break;
case Frequency4MHz:
frequency = SPI_4_5MHZ;
break;
case Frequency8MHz:
frequency = SPI_9MHZ;
break;
//.........这里部分代码省略.........
示例5: begin
void RHHardwareSPI::begin()
{
// 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)
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)
// 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))
// Arduino Due in 1.5.5 has its own BitOrder :-(
// So too does Arduino Zero
::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:
#if F_CPU == 8000000
divider = SPI_CLOCK_DIV4;
#else
divider = SPI_CLOCK_DIV8;
#endif
break;
case Frequency4MHz:
#if F_CPU == 8000000
divider = SPI_CLOCK_DIV2;
#else
divider = SPI_CLOCK_DIV4;
#endif
break;
case Frequency8MHz:
divider = SPI_CLOCK_DIV2; // 4MHz on an 8MHz Arduino
break;
case Frequency16MHz:
divider = SPI_CLOCK_DIV2; // Not really 16MHz, only 8MHz. 4MHz on an 8MHz Arduino
break;
}
SPI.setClockDivider(divider);
SPI.begin();
#elif (RH_PLATFORM == RH_PLATFORM_STM32) // Maple etc
spi_mode dataMode;
// Hmmm, if we do this as a switch, GCC on maple gets v confused!
if (_dataMode == DataMode0)
dataMode = SPI_MODE_0;
else if (_dataMode == DataMode1)
dataMode = SPI_MODE_1;
else if (_dataMode == DataMode2)
dataMode = SPI_MODE_2;
else if (_dataMode == DataMode3)
dataMode = SPI_MODE_3;
else
dataMode = SPI_MODE_0;
uint32 bitOrder;
if (_bitOrder == BitOrderLSBFirst)
bitOrder = LSBFIRST;
else
bitOrder = MSBFIRST;
SPIFrequency frequency; // Yes, I know these are not exact equivalents.
//.........这里部分代码省略.........