Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
mcp23017.hpp
1 /*
2  Title --- driver/mcp23017.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_DRIVER_MCP23017_HPP_
23 #define _RPI_HW_DRIVER_MCP23017_HPP_
24 
25 #include <rpi-hw/rpi.hpp>
26 
27 #include <rpi-hw/consts.hpp>
28 #include <rpi-hw/types.hpp>
29 #include <rpi-hw/exception.hpp>
30 #include <rpi-hw/utils.hpp>
31 
32 #include <rpi-hw/driver/i2c.hpp>
33 #include <rpi-hw/driver/mcp23x17.hpp>
34 
35 namespace rpihw { // Begin main namespace
36 
37 namespace driver { // Begin drivers namespace
38 
39 /*!
40  @class mcp23017
41  @brief 16-bit I/O Expander with I2C.
42 
43  @example driver/mcp23017.cpp
44 */
45 class mcp23017 : public mcp23x17 {
46 
47 public:
48 
49  /*!
50  @brief Constructor method.
51  @param[in] dev_path The device path.
52  @param[in] dev_addr The device address.
53  */
54  mcp23017( const std::string &dev_path, uint8_t dev_addr );
55 
56  //! Destructor method.
57  virtual ~mcp23017();
58 
59 private:
60 
61  //! Inter Integrated Circuit.
63 
64  //! Device address.
65  uint8_t m_dev_addr;
66 
67  //! Sends data to the device.
68  virtual void send( uint8_t reg, uint8_t data );
69 
70  //! Receives data from the device.
71  virtual uint8_t receive( uint8_t reg );
72 };
73 
74 } // End of drivers namespace
75 
76 } // End of main namespace
77 
78 
79 // Include inline methods
80 #include <rpi-hw/driver/mcp23017-inl.hpp>
81 
82 #endif /* _RPI_HW_DRIVER_MCP23017_HPP_ */
virtual void send(uint8_t reg, uint8_t data)
Sends data to the device.
driver::i2c * m_i2c
Inter Integrated Circuit.
Definition: mcp23017.hpp:62
virtual ~mcp23017()
Destructor method.
16-bit I/O Expander with I2C.
Definition: mcp23017.hpp:45
uint8_t m_dev_addr
Device address.
Definition: mcp23017.hpp:65
mcp23017(const std::string &dev_path, uint8_t dev_addr)
Constructor method.
Inter Integrated Circuit.
Definition: i2c.hpp:46
virtual uint8_t receive(uint8_t reg)
Receives data from the device.
16-bit I/O Expander with SPI/I2C (skeleton).
Definition: mcp23x17.hpp:42