Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
SRPO.h
Go to the documentation of this file.
1 
19 #ifndef SRPO_H
20 #define SRPO_H
21 
22 #include "GPIO.h"
23 
30 template<uint8_t BITORDER, BOARD::pin_t DATA_PIN, BOARD::pin_t CLOCK_PIN>
31 class SRPO {
32 public:
38  SRPO()
39  {
40  m_data.output();
41  m_clock.output();
42  }
43 
49  void write(uint8_t value)
50  {
51  if (BITORDER == LSBFIRST) {
52  uint8_t mask = 1;
53  do {
54  m_data = value & mask;
55  m_clock.toggle();
56  mask <<= 1;
57  m_clock.toggle();
58  } while (mask);
59  }
60  else {
61  uint8_t mask = 0x80;
62  do {
63  m_data = value & mask;
64  m_clock.toggle();
65  mask >>= 1;
66  m_clock.toggle();
67  } while (mask);
68  }
69  }
70 
75  void operator<<(uint8_t value)
76  {
77  write(value);
78  }
79 
80 protected:
83 };
84 
85 #endif
void write(uint8_t value)
Definition: SRPO.h:49
Definition: SRPO.h:31
void operator<<(uint8_t value)
Definition: SRPO.h:75
SRPO()
Definition: SRPO.h:38
void toggle()
Definition: GPIO.h:113
void output()
Definition: GPIO.h:56
GPIO< DATA_PIN > m_data
Definition: SRPO.h:81
GPIO< CLOCK_PIN > m_clock
Definition: SRPO.h:82