Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
output.hpp
1 /*
2  Title --- iface/output.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_OUTPUT_HPP_
23 #define _RPI_HW_IFACE_OUTPUT_HPP_
24 
25 #include <initializer_list>
26 #include <vector>
27 
28 #include <rpi-hw/types.hpp>
29 #include <rpi-hw/exception.hpp>
30 #include <rpi-hw/math.hpp>
31 #include <rpi-hw/utils.hpp>
32 
33 #include <rpi-hw/iface/base.hpp>
34 
35 namespace rpihw { // Begin main namespace
36 
37 namespace iface { // Begin interfaces namespace
38 
39 /*!
40  @class output
41  @brief Output interface.
42 */
43 class output : public iface::base {
44 
45 public:
46 
47  /*!
48  @brief Constructor method.
49  @param[in] pins Sequence of `uint8_t` containing the GPIO pins.
50  */
51  output( std::initializer_list< uint8_t > pins );
52 
53  /*!
54  @brief Constructor method.
55  @param[in] pins Vector containing the GPIO pins.
56  */
57  output( const std::vector< uint8_t > &pins );
58 
59  //! Destructor method.
60  virtual ~output();
61 
62  /*!
63  @brief Sets an output pin.
64  @param[in] index The index position of the output pin.
65  @param[in] pin The new GPIO pin.
66  */
67  virtual void setPin( uint8_t index, uint8_t pin );
68 
69  /*!
70  @brief Writes a data on the interface.
71  @param[in] data The data to be written.
72  */
73  virtual void write( size_t data );
74 
75  /*!
76  @brief Writes a data on the interface pin.
77  @param[in] index The index position of the interface pin.
78  @param[in] data The data to be written.
79  */
80  virtual void write( uint8_t index, bool data );
81 };
82 
83 } // End of interfaces namespace
84 
85 } // End of main namespace
86 
87 
88 // Include inline methods
89 #include <rpi-hw/iface/output-inl.hpp>
90 
91 #endif /* _RPI_HW_IFACE_OUTPUT_HPP_ */
Output interface.
Definition: output.hpp:43
output(std::initializer_list< uint8_t > pins)
Constructor method.
Generic interface.
Definition: base.hpp:48
virtual void write(size_t data)
Writes a data on the interface.
virtual ~output()
Destructor method.
virtual void setPin(uint8_t index, uint8_t pin)
Sets an output pin.
Definition: output-inl.hpp:30