Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
shift-base.hpp
1 /*
2  Title --- iface/shift-base.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_IFACE_SHIFT_BASE_HPP_
23 #define _RPI_HW_IFACE_SHIFT_BASE_HPP_
24 
25 #include <rpi-hw/types.hpp>
26 #include <rpi-hw/exception.hpp>
27 #include <rpi-hw/math.hpp>
28 #include <rpi-hw/utils.hpp>
29 #include <rpi-hw/time.hpp>
30 
31 #include <rpi-hw/iface/base.hpp>
32 
33 namespace rpihw { // Begin main namespace
34 
35 namespace iface { // Begin interfaces namespace
36 
37 /*!
38  @class shiftBase
39  @brief Shift base interface.
40 */
41 class shiftBase : public iface::base {
42 
43 public:
44 
45  //! Shift interface pins.
46  enum ShiftPins {
47 
48  DATA = 0, //!< The data pin.
49  CLOCK = 1 //!< The clock pin.
50  };
51 
52  //! Bit orders.
53  enum BitOrder {
54 
55  MSBFIRST = 0, //!< Most significant bit first.
56  LSBFIRST = 1 //!< Least significant bit first.
57  };
58 
59  /*!
60  @brief Constructor method.
61  @param[in] data_pin The data pin.
62  @param[in] clock_pin The clock pin.
63  @param[in] order The bit order.
64  @param[in] delay The delay time of the clock.
65  */
66  shiftBase( uint8_t data_pin, uint8_t clock_pin, BitOrder order, size_t delay = 0 );
67 
68  //! Destructor method.
69  virtual ~shiftBase();
70 
71  //! Toggles the clock.
72  virtual void strobe();
73 
74 protected:
75 
76  //! The order to shift out the bits.
78 
79  //! The delay time of the clock.
80  size_t m_delay;
81 };
82 
83 } // End of interfaces namespace
84 
85 } // End of main namespace
86 
87 
88 // Include inline methods
89 #include <rpi-hw/iface/shift-base-inl.hpp>
90 
91 #endif /* _RPI_HW_IFACE_SHIFT_BASE_HPP_ */
virtual void strobe()
Toggles the clock.
shiftBase(uint8_t data_pin, uint8_t clock_pin, BitOrder order, size_t delay=0)
Constructor method.
ShiftPins
Shift interface pins.
Definition: shift-base.hpp:46
Generic interface.
Definition: base.hpp:48
BitOrder m_order
The order to shift out the bits.
Definition: shift-base.hpp:77
Most significant bit first.
Definition: shift-base.hpp:55
size_t m_delay
The delay time of the clock.
Definition: shift-base.hpp:80
Shift base interface.
Definition: shift-base.hpp:41
virtual ~shiftBase()
Destructor method.
Least significant bit first.
Definition: shift-base.hpp:56