25 #ifndef ACE_SEGMENT_SOFT_TMI_FAST_INTERFACE_H
26 #define ACE_SEGMENT_SOFT_TMI_FAST_INTERFACE_H
30 #if defined(ARDUINO_ARCH_AVR) || defined(EPOXY_DUINO)
35 namespace ace_segment {
75 uint8_t T_DELAY_MICROS
77 class SoftTmiFastInterface {
79 explicit SoftTmiFastInterface() =
default;
88 digitalWriteFast(T_CLK_PIN, LOW);
89 digitalWriteFast(T_DIO_PIN, LOW);
103 void startCondition()
const {
112 void stopCondition()
const {
124 uint8_t sendByte(uint8_t data)
const {
125 for (uint8_t i = 0; i < 8; ++i) {
144 uint8_t readAck()
const {
147 uint8_t ack = digitalReadFast(T_DIO_PIN);
159 void bitDelay()
const { delayMicroseconds(T_DELAY_MICROS); }
161 void clockHigh()
const { pinModeFast(T_CLK_PIN, INPUT); bitDelay(); }
163 void clockLow()
const { pinModeFast(T_CLK_PIN, OUTPUT); bitDelay(); }
165 void dataHigh()
const { pinModeFast(T_DIO_PIN, INPUT); bitDelay(); }
167 void dataLow()
const { pinModeFast(T_DIO_PIN, OUTPUT); bitDelay(); }
172 #endif // defined(ARDUINO_ARCH_AVR)