GCC Code Coverage Report


Directory: ./
File: util/I2CUtils.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #pragma once
2 /*
3 * This file is part of the Falcon Player (FPP) and is Copyright (C)
4 * 2013-2022 by the Falcon Player Developers.
5 *
6 * The Falcon Player (FPP) is free software, and is covered under
7 * multiple Open Source licenses. Please see the included 'LICENSES'
8 * file for descriptions of what files are covered by each license.
9 *
10 * This source file is covered under the LGPL v2.1 as described in the
11 * included LICENSE.LGPL file.
12 */
13
14 // PLUGIN ABI: native plugins compile against this header and are loaded with
15 // dlopen(), so parts of it are baked into binaries FPP did not build.
16 // - I2CUtils' size and layout: plugins `new I2CUtils(...)` themselves, so
17 // the allocation is the plugin's compiled-in sizeof and FPP's constructor
18 // writes into it; isOk() is inline.
19 // Any such change must bump FPP_PLUGIN_API_VERSION in Plugin.h. Without the
20 // bump, a plugin built against the previous header still loads and silently
21 // uses the old layout - FPP 10.2 shipped exactly that and crash-looped fppd.
22 // See .claude/PLUGIN-ABI.md for which plugins use what.
23
24 #include <stdint.h>
25
26 class I2CUtils {
27 public:
28 I2CUtils(int bus, int address);
29 I2CUtils(const char* i2cdev, int address);
30 I2CUtils(int bus, int address, bool skipDetect);
31 ~I2CUtils();
32
33 int readDevice(uint8_t* buf, int count);
34 int writeDevice(uint8_t* buf, int count);
35
36 int readByte();
37 int writeByte(unsigned val);
38
39 int readByteData(int reg);
40 int writeByteData(int reg, unsigned val);
41 int readWordData(int reg);
42 int writeWordData(int reg, unsigned val);
43
44 // these are limitted to 32bytes due to smbus protocol restrictions
45 int writeBlockData(int reg, const uint8_t* buf, int count);
46 int writeI2CBlockData(int reg, const uint8_t* buf, int count);
47 int readI2CBlockData(int reg, uint8_t* buf, int count);
48
49 // this writes the bytes directly via i2c and would be limitted to the
50 // 254 bytes data (+byte for len +byte for reg)
51 int writeRawI2CBlockData(int reg, const uint8_t* buf, int count);
52
53 15 bool isOk() { return file != -1; }
54
55 private:
56 void Init(const char*, int address, bool skipDetect);
57 int file;
58 int address;
59 unsigned long funcs;
60 };
61