Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/soc/i2c.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2020 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _I2C_H_
19
#define _I2C_H_
20
21
#include <utils/types.h>
22
23
#define I2C_1 0
24
#define I2C_2 1
25
#define I2C_3 2
26
#define I2C_4 3
27
#define I2C_5 4
28
#define I2C_6 5
29
30
void i2c_init(u32 i2c_idx);
31
int i2c_recv_buf(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr);
32
int i2c_send_buf_big(u32 i2c_idx, u32 dev_addr, u8 *buf, u32 size);
33
int i2c_recv_buf_big(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr, u32 reg);
34
int i2c_send_buf_small(u32 i2c_idx, u32 dev_addr, u32 reg, const u8 *buf, u32 size);
35
int i2c_recv_buf_small(u8 *buf, u32 size, u32 i2c_idx, u32 dev_addr, u32 reg);
36
int i2c_send_byte(u32 i2c_idx, u32 dev_addr, u32 reg, u8 val);
37
u8 i2c_recv_byte(u32 i2c_idx, u32 dev_addr, u32 reg);
38
39
#endif
40
41