Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
gpio-inl.hpp
1 /*
2  Title --- gpio-inl.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_GPIO_INL_HPP_
23 #define _RPI_HW_GPIO_INL_HPP_
24 
25 namespace rpihw { // Begin main namespace
26 
27 template < typename T >
28 void
29 gpio::expand( uint8_t pin_base, T &expander ) {
30 
31  // Check the pin base
32  if ( pin_base <= RESERVED_PINS )
33  throw exception( utils::format( "(Fatal) `gpio::expand`: pin %d is reserved\n", pin_base ) );
34 
35  // Add the I/O expander to the standard GPIO connector
36  m_expanders.push_back( { pin_base, static_cast< driver::io_expander * >( &expander ) } );
37 }
38 
39 } // End of main namespace
40 
41 #endif /* _RPI_HW_GPIO_INL_HPP_ */
std::string format(const char *format,...)
Returns a formatted string like printf.
std::vector< expander_slot > m_expanders
List of I/O expanders.
Definition: gpio.hpp:151
void expand(uint8_t pin_base, T &expander)
Adds a I/O expander to the standard GPIO connector.
Definition: gpio-inl.hpp:29