forked from pasko-zh/brzo_i2c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brzo_i2c.h
62 lines (47 loc) · 1.74 KB
/
brzo_i2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
brzo_i2c.h -- A fast i2c master for the esp8266 written in assembly language
Copyright (c) 2016 Pascal Kurtansky (pascal at kurtansky dot ch).
All rights reserved.
This file is part of the library brzo_i2c.
Brzo_i2c is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Brzo_i2c is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BRZO_I2C_h
#define _BRZO_I2C_h
#ifdef ARDUINO
#include "Arduino.h"
#else
#include <c_types.h>
// SDA on GPIO12, SCL on GPIO13
#define BRZO_I2C_SDA_MUX PERIPHS_IO_MUX_MTDI_U
#define BRZO_I2C_SCL_MUX PERIPHS_IO_MUX_MTCK_U
#define BRZO_I2C_SDA_GPIO 12
#define BRZO_I2C_SCL_GPIO 13
#define BRZO_I2C_SDA_FUNC FUNC_GPIO12
#define BRZO_I2C_SCL_FUNC FUNC_GPIO13
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ARDUINO
void brzo_i2c_setup(uint8_t sda, uint8_t scl, uint32_t clock_stretch_time_out_usec);
#else
void brzo_i2c_setup(uint32_t clock_stretch_time_out_usec);
#endif
void brzo_i2c_start_transaction(uint8_t slave_address, uint16_t SCL_frequency_KHz);
void brzo_i2c_write(uint8_t *data, uint32_t no_of_bytes, bool repeated_start);
void brzo_i2c_read(uint8_t *data, uint32_t nr_of_bytes, bool repeated_start);
void brzo_i2c_ACK_polling(uint16_t ACK_polling_time_out_usec);
uint8_t brzo_i2c_end_transaction();
#ifdef __cplusplus
}
#endif
#endif