Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
mcp23s08.hpp
1 /*
2  Title --- driver/mcp23s08.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_MCP23S17_HPP_
23 #define _RPI_HW_DRIVER_MCP23S17_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/spi.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 mcp23s08
41  @brief 8-bit I/O Expander with SPI.
42 */
43 class mcp23s08 : public mcp23x08 {
44 
45 public:
46 
47  /*!
48  @brief Constructor method.
49  @param[in] dev_path The device path.
50  @param[in] dev_id The device identifier.
51  */
52  mcp23s08( const std::string &dev_path, uint8_t dev_id );
53 
54  //! Destructor method.
55  virtual ~mcp23s08();
56 
57 private:
58 
59  //! Serial Peripheral Interface.
61 
62  //! Device identifier.
63  uint8_t m_dev_id;
64 
65  //! Data buffer used for SPI transmission.
66  uint8_t m_buffer[3];
67 
68  //! Sends data to the device.
69  virtual void send( uint8_t reg, uint8_t data );
70 
71  //! Receives data from the device.
72  virtual uint8_t receive( uint8_t reg );
73 };
74 
75 } // End of drivers namespace
76 
77 } // End of main namespace
78 
79 
80 // Include inline methods
81 #include <rpi-hw/driver/mcp23s08-inl.hpp>
82 
83 #endif /* _RPI_HW_DRIVER_MCP23S17_HPP_ */
8-bit I/O Expander with SPI/I2C (skeleton).
Definition: mcp23x08.hpp:42
mcp23s08(const std::string &dev_path, uint8_t dev_id)
Constructor method.
virtual ~mcp23s08()
Destructor method.
8-bit I/O Expander with SPI.
Definition: mcp23s08.hpp:43
uint8_t m_buffer[3]
Data buffer used for SPI transmission.
Definition: mcp23s08.hpp:66
virtual void send(uint8_t reg, uint8_t data)
Sends data to the device.
Serial Peripheral Interface.
Definition: spi.hpp:45
virtual uint8_t receive(uint8_t reg)
Receives data from the device.
driver::spi * m_spi
Serial Peripheral Interface.
Definition: mcp23s08.hpp:60
uint8_t m_dev_id
Device identifier.
Definition: mcp23s08.hpp:63