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