1
- /*
1
+ /*
2
2
si2c.c - Software I2C library for esp8266
3
3
4
4
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
5
5
This file is part of the esp8266 core for Arduino environment.
6
-
6
+
7
7
This library is free software; you can redistribute it and/or
8
8
modify it under the terms of the GNU Lesser General Public
9
9
License as published by the Free Software Foundation; either
@@ -26,20 +26,20 @@ unsigned char twi_dcount = 18;
26
26
static unsigned char twi_sda , twi_scl ;
27
27
28
28
#define SDA_LOW () (GPES = (1 << twi_sda)) //Enable SDA (becomes output and since GPO is 0 for the pin, it will pull the line low)
29
- #define SDA_HIGH () (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
29
+ #define SDA_HIGH () (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
30
30
#define SDA_READ () ((GPI & (1 << twi_sda)) != 0)
31
- #define SCL_LOW () (GPES = (1 << twi_scl))
32
- #define SCL_HIGH () (GPEC = (1 << twi_scl))
31
+ #define SCL_LOW () (GPES = (1 << twi_scl))
32
+ #define SCL_HIGH () (GPEC = (1 << twi_scl))
33
33
#define SCL_READ () ((GPI & (1 << twi_scl)) != 0)
34
34
35
35
#ifndef FCPU80
36
36
#define FCPU80 80000000L
37
37
#endif
38
38
39
39
#if F_CPU == FCPU80
40
- #define TWI_CLOCK_STRETCH 200
40
+ #define TWI_CLOCK_STRETCH 800
41
41
#else
42
- #define TWI_CLOCK_STRETCH 400
42
+ #define TWI_CLOCK_STRETCH 1600
43
43
#endif
44
44
45
45
void twi_setClock (unsigned int freq ){
@@ -99,7 +99,7 @@ static bool twi_write_stop(void){
99
99
twi_delay (twi_dcount );
100
100
SDA_HIGH ();
101
101
twi_delay (twi_dcount );
102
-
102
+
103
103
return true;
104
104
}
105
105
0 commit comments