LCOV - code coverage report
Current view: top level - SITL - SIM_I2C.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : 
      16             : /*
      17             :   Simulated i2c buses and devices
      18             : */
      19             : 
      20             : #pragma once
      21             : 
      22             : #include <AP_Param/AP_Param.h>
      23             : 
      24             : #include "stdint.h"
      25             : 
      26             : namespace SITL {
      27             : 
      28             : class I2C {
      29             : public:
      30        2096 :     I2C() {}
      31             : 
      32             :     // update i2c state
      33             :     void update(const class Aircraft &aircraft);
      34             : 
      35             :     int ioctl(uint8_t ioctl_type, void *data);
      36             : 
      37             :     // the following must be identical to AP_HAL_SITL/I2CDevice.h
      38             : #define I2C_M_RD 1
      39             : #define I2C_RDWR 0
      40             :     struct i2c_msg {
      41             :         uint8_t bus;
      42             :         uint8_t addr;
      43             :         uint8_t flags;
      44             :         uint8_t *buf;
      45             :         uint16_t len; // FIXME: what type should this be?
      46             :     };
      47             :     struct i2c_rdwr_ioctl_data {
      48             :         i2c_msg *msgs;
      49             :         uint8_t nmsgs;
      50             :     };
      51             :     // end "the following"
      52             : 
      53             : private:
      54             :     // one-time setup of the simulated device table.  Self-guarded by
      55             :     // initialised and called lazily from update()/ioctl() (either may
      56             :     // run first), so the simulated bus needs no external init() call.
      57             :     void init();
      58             :     bool initialised;
      59             : 
      60             :     int ioctl_rdwr(i2c_rdwr_ioctl_data *data);
      61             : 
      62             : };
      63             : 
      64             : }

Generated by: LCOV version 1.14