Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SRPI.h
Go to the documentation of this file.
1
19
#ifndef SRPI_H
20
#define SRPI_H
21
22
#include "
GPIO.h
"
23
30
template
<u
int
8_t BITORDER, BOARD::pin_t DATA_PIN, BOARD::pin_t CLOCK_PIN>
31
class
SRPI
{
32
public
:
38
SRPI
()
39
{
40
m_data
.
input
();
41
m_clock
.
output
();
42
}
43
50
uint8_t
read
()
51
{
52
uint8_t res = 0;
53
if
(BITORDER == LSBFIRST) {
54
uint8_t mask = 1;
55
do
{
56
m_clock
.
toggle
();
57
res |= (
m_data
? mask : 0);
58
m_clock
.
toggle
();
59
mask <<= 1;
60
}
while
(mask);
61
}
62
else
{
63
uint8_t mask = 0x80;
64
do
{
65
m_clock
.
toggle
();
66
res |= (
m_data
? mask : 0);
67
m_clock
.
toggle
();
68
mask >>= 1;
69
}
while
(mask);
70
}
71
return
(res);
72
}
73
78
void
operator>>
(uint8_t& value)
79
{
80
value =
read
();
81
}
82
83
protected
:
84
GPIO<DATA_PIN>
m_data
;
85
GPIO<CLOCK_PIN>
m_clock
;
86
};
87
88
#endif
SRPI
Definition:
SRPI.h:31
SRPI::m_data
GPIO< DATA_PIN > m_data
Definition:
SRPI.h:84
SRPI::operator>>
void operator>>(uint8_t &value)
Definition:
SRPI.h:78
SRPI::m_clock
GPIO< CLOCK_PIN > m_clock
Definition:
SRPI.h:85
SRPI::SRPI
SRPI()
Definition:
SRPI.h:38
GPIO::input
GPIO< PIN > & input()
Definition:
GPIO.h:36
GPIO.h
SRPI::read
uint8_t read()
Definition:
SRPI.h:50
GPIO::toggle
void toggle()
Definition:
GPIO.h:113
GPIO::output
void output()
Definition:
GPIO.h:56
GPIO< DATA_PIN >
src
SRPI.h
Generated on Sat Oct 14 2017 16:03:22 for Arduino-GPIO by
1.8.11