1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

adjust clock stretch

This commit is contained in:
Michael Graff 2015-07-14 11:05:53 -07:00
parent dece240830
commit 4b8f5342cd

View File

@ -1,9 +1,9 @@
/* /*
si2c.c - Software I2C library for esp8266 si2c.c - Software I2C library for esp8266
Copyright (c) 2015 Hristo Gochkov. All rights reserved. Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment. This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
@ -26,10 +26,10 @@ unsigned char twi_dcount = 18;
static unsigned char twi_sda, twi_scl; static unsigned char twi_sda, twi_scl;
#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) #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)
#define SDA_HIGH() (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high) #define SDA_HIGH() (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
#define SDA_READ() ((GPI & (1 << twi_sda)) != 0) #define SDA_READ() ((GPI & (1 << twi_sda)) != 0)
#define SCL_LOW() (GPES = (1 << twi_scl)) #define SCL_LOW() (GPES = (1 << twi_scl))
#define SCL_HIGH() (GPEC = (1 << twi_scl)) #define SCL_HIGH() (GPEC = (1 << twi_scl))
#define SCL_READ() ((GPI & (1 << twi_scl)) != 0) #define SCL_READ() ((GPI & (1 << twi_scl)) != 0)
#ifndef FCPU80 #ifndef FCPU80
@ -37,9 +37,9 @@ static unsigned char twi_sda, twi_scl;
#endif #endif
#if F_CPU == FCPU80 #if F_CPU == FCPU80
#define TWI_CLOCK_STRETCH 200 #define TWI_CLOCK_STRETCH 800
#else #else
#define TWI_CLOCK_STRETCH 400 #define TWI_CLOCK_STRETCH 1600
#endif #endif
void twi_setClock(unsigned int freq){ void twi_setClock(unsigned int freq){
@ -99,7 +99,7 @@ static bool twi_write_stop(void){
twi_delay(twi_dcount); twi_delay(twi_dcount);
SDA_HIGH(); SDA_HIGH();
twi_delay(twi_dcount); twi_delay(twi_dcount);
return true; return true;
} }