]> git.sesse.net Git - pistorm/blob - i2c_updater/pi-i2c/src/i2c.hpp
Initial work on FPGA I2C programmer
[pistorm] / i2c_updater / pi-i2c / src / i2c.hpp
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef _I2C_HPP_
6 #define _I2C_HPP_
7
8 #include <string>
9 #include <vector>
10
11 class tI2c {
12 public:
13         tI2c(const std::string &Port);
14
15         bool write(uint8_t ubAddr, const std::vector<uint8_t> &vData);
16
17         bool read(uint8_t ubAddr, uint8_t *pDest, uint32_t ulReadSize);
18
19         template <typename t_tContainer>
20         bool read(uint8_t ubAddr, t_tContainer &Cont) {
21                 return read(ubAddr, Cont.data(), Cont.size());
22         }
23
24 private:
25         int m_I2cHandle;
26 };
27
28 #endif // _I2C_HPP_