Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / bus_busdev_i2c.c
blobfb255278d5b7637f97d0fbc18871c94eed46ada3
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <string.h>
22 #include <platform.h>
24 #if defined(USE_I2C)
26 #if !defined(UNUSED)
27 #define UNUSED(x) ((void)(x))
28 #endif
30 #include "drivers/bus.h"
31 #include "drivers/bus_i2c.h"
33 bool i2cBusWriteBuffer(const busDevice_t * dev, uint8_t reg, const uint8_t * data, uint8_t length)
35 const bool allowRawAccess = (dev->flags & DEVFLAGS_USE_RAW_REGISTERS);
36 return i2cWriteBuffer(dev->busdev.i2c.i2cBus, dev->busdev.i2c.address, reg, length, data, allowRawAccess);
39 bool i2cBusWriteRegister(const busDevice_t * dev, uint8_t reg, uint8_t data)
41 const bool allowRawAccess = (dev->flags & DEVFLAGS_USE_RAW_REGISTERS);
42 return i2cWrite(dev->busdev.i2c.i2cBus, dev->busdev.i2c.address, reg, data, allowRawAccess);
45 bool i2cBusReadBuffer(const busDevice_t * dev, uint8_t reg, uint8_t * data, uint8_t length)
47 const bool allowRawAccess = (dev->flags & DEVFLAGS_USE_RAW_REGISTERS);
48 return i2cRead(dev->busdev.i2c.i2cBus, dev->busdev.i2c.address, reg, length, data, allowRawAccess);
51 bool i2cBusReadRegister(const busDevice_t * dev, uint8_t reg, uint8_t * data)
53 const bool allowRawAccess = (dev->flags & DEVFLAGS_USE_RAW_REGISTERS);
54 return i2cRead(dev->busdev.i2c.i2cBus, dev->busdev.i2c.address, reg, 1, data, allowRawAccess);
56 bool i2cBusBusy(const busDevice_t *dev, bool *error)
58 #if defined(AT32F43x)
59 return i2cBusy(dev->busdev.i2c.i2cBus, error);
60 #endif
61 UNUSED(dev);
62 UNUSED(error);
63 return false;
65 #endif