NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bus_i2c.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight 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.
8  *
9  * Ninjaflight 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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #define I2C_SHORT_TIMEOUT ((uint32_t)0x1000)
21 #define I2C_LONG_TIMEOUT ((uint32_t)(10 * I2C_SHORT_TIMEOUT))
22 #define I2C_DEFAULT_TIMEOUT I2C_SHORT_TIMEOUT
23 
24 typedef enum I2CDevice {
28 } I2CDevice;
29 
30 void i2cInit(I2CDevice index);
31 bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data);
32 bool i2cWrite(uint8_t addr_, uint8_t reg, uint8_t data);
33 bool i2cRead(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf);
34 uint16_t i2cGetErrorCounter(void);
35 void i2cSetOverclock(uint8_t OverClock);
void i2cInit(I2CDevice index)
Definition: bus_i2c_stm32f10x.c:324
uint16_t i2cGetErrorCounter(void)
Definition: bus_i2c_stm32f10x.c:376
Definition: bus_i2c.h:26
Definition: bus_i2c.h:27
bool i2cRead(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t *buf)
Definition: bus_i2c_stm32f10x.c:158
bool i2cWrite(uint8_t addr_, uint8_t reg, uint8_t data)
Definition: bus_i2c_stm32f10x.c:153
bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
Definition: bus_i2c_stm32f10x.c:116
I2CDevice
Definition: bus_i2c.h:24
void i2cSetOverclock(uint8_t OverClock)
Definition: bus_i2c_stm32f10x.c:78
Definition: bus_i2c.h:25
uint16_t data
Definition: config.c:91