25 #ifndef ACE_SEGMENT_HARD_SPI_FAST_INTERFACE_H
26 #define ACE_SEGMENT_HARD_SPI_FAST_INTERFACE_H
32 namespace ace_segment {
59 template <
typename T_SPI, u
int8_t T_LATCH_PIN>
67 static const uint32_t kClockSpeed = 8000000;
70 #if defined(ARDUINO_ARCH_STM32)
71 static const BitOrder kBitOrder = MSBFIRST;
73 static const uint8_t kBitOrder = MSBFIRST;
77 static const uint8_t kSpiMode = SPI_MODE0;
98 pinModeFast(T_LATCH_PIN, OUTPUT);
102 pinModeFast(T_LATCH_PIN, INPUT);
107 mSpi.beginTransaction(SPISettings(kClockSpeed, kBitOrder, kSpiMode));
108 digitalWriteFast(T_LATCH_PIN, LOW);
109 mSpi.transfer(value);
110 digitalWriteFast(T_LATCH_PIN, HIGH);
111 mSpi.endTransaction();
116 mSpi.beginTransaction(SPISettings(kClockSpeed, kBitOrder, kSpiMode));
117 digitalWriteFast(T_LATCH_PIN, LOW);
118 mSpi.transfer16(value);
119 digitalWriteFast(T_LATCH_PIN, HIGH);
120 mSpi.endTransaction();
123 void send16(uint8_t msb, uint8_t lsb)
const {
124 uint16_t value = ((uint16_t) msb) << 8 | (uint16_t) lsb;