-
• #3
using printf - remove \ infront of #define - line was not displayed correct without
// insert after last [#include](https://forum.espruino.com/search/?q=%23include) extern int os_printf_plus(const char *format, ...) __attribute__((format(printf, 1, 2))); \#define printf os_printf_plus ....... error: i2c_master_stop(); //jsError("> I2C streching too long\n"); printf("> I2C streching too long\n"); return -1; }
compile output:
targets/esp8266/i2c_master.c: In function 'i2c_master_readByte': targets/esp8266/i2c_master.c:330:9: error: implicit declaration of function 'i2c_master_getDD' [-Werror=implicit-function-declaration] while ( i2c_master_getDD()==0 && count--) { // PB 36000/1000*4=144 ^ targets/esp8266/i2c_master.c: At top level:
-
• #4
typo : i2c_master_getDD -> i2c_master_getDC ?
compiles ;-)
-
• #5
Don't change "i2c_master_getDD" it's read the scl line.
and "i2c_master_getDC" read the sda line.Try the Attachment and see if it compiles ok.
-
• #7
I was hoping I could use JsError as in the file jshardware.c, where the call come from, maybe someone has a solution.
As you may see, I have tried with a lower value, to test that, so I could see that it worked.
I don't now if it work with different clockfreq, but try it, and let me know.
-
• #8
Did you adjust the timing constants to maintain the overall clock rate? It seems that the addition of your code must have affected the performance...
What does the 'DD' in i2c_master_getDD stand for? For reference, the DC in i2c_master_setDC stands for Data/Clock.
-
• #9
I am new to all this stof. There are lots I do not understand. But it is a wonderful world to dive into.
Did you adjust the timing constants to maintain the overall clock rate? It seems that the addition of your code must have affected the performance...
No my only wish was to make clock streching working for my HTU21D.
Yes I know it take longer with every read, because of the extra instructions.What does the 'DD' in i2c_master_getDD stand for? For reference, the DC in i2c_master_setDC stands for Data/Clock.
I had to find a name and saw this, and it only reads SDA
\#define i2c_master_getDC(void) ((GPIO_REG_READ(GPIO_IN_ADDRESS) >> pinSDA) & 1)
so I made one for SCL
\#define i2c_master_getDD(void) ((GPIO_REG_READ(GPIO_IN_ADDRESS) >> pinSCL) & 1) // PB
-
• #10
I was hoping I could use JsError as in the file jshardware.c, where the call come from, maybe someone has a solution.
you can't use JsError in i2c_master.c
use os_printf() or os_printf_plus(), both write to debug log
than use ESP8266.setLog(2); in the js code to switch debug log to uart0 (console)
-
• #11
you can't use JsError in i2c_master.c
Why? Surely it's just a matter of including
jsutils.h
? -
• #12
Hey, I have tryed that, but I get a lot of compiler fault.
So it is over my head at the moment.
I only seems that could be nice, with a message if it took too long.In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:15:29: error: conflicting types for 'uint32_t' typedef unsigned long uint32_t; ^ In file included from /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdint.h:9:0, from /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:23, from targets/esp8266/i2c_master.c:34: /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/stdint.h:81:22: note: previous declaration of 'uint32_t' was here typedef unsigned int uint32_t; ^ In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:17:29: error: conflicting types for 'int32_t' typedef signed long int32_t; ^ In file included from /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdint.h:9:0, from /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:23, from targets/esp8266/i2c_master.c:34: /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/include/stdint.h:80:20: note: previous declaration of 'int32_t' was here typedef signed int int32_t; ^ In file included from /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:24:0, from targets/esp8266/i2c_master.c:34: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:85:25: error: two or more data types in declaration specifiers typedef unsigned char bool; ^ In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:85:1: warning: useless type name in empty declaration [enabled by default] typedef unsigned char bool; ^ /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:87:0: warning: "true" redefined [enabled by default] [#define](https://forum.espruino.com/search/?q=%23define) true (1) ^ In file included from /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:24:0, from targets/esp8266/i2c_master.c:34: /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdbool.h:34:0: note: this is the location of the previous definition [#define](https://forum.espruino.com/search/?q=%23define) true 1 ^ In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:88:0: warning: "false" redefined [enabled by default] [#define](https://forum.espruino.com/search/?q=%23define) false (0) ^ In file included from /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:24:0, from targets/esp8266/i2c_master.c:34: /home/poul/Programmer/uPython/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdbool.h:35:0: note: this is the location of the previous definition [#define](https://forum.espruino.com/search/?q=%23define) false 0 ^ In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:89:0: warning: "TRUE" redefined [enabled by default] [#define](https://forum.espruino.com/search/?q=%23define) TRUE true ^ In file included from targets/esp8266/i2c_master.c:34:0: /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:116:0: note: this is the location of the previous definition [#define](https://forum.espruino.com/search/?q=%23define) TRUE (1) ^ In file included from /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/ets_sys.h:11:0, from targets/esp8266/i2c_master.c:35: /home/poul/Programmer/ESP8266_NONOS_SDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/include/c_types.h:90:0: warning: "FALSE" redefined [enabled by default] [#define](https://forum.espruino.com/search/?q=%23define) FALSE false ^ In file included from targets/esp8266/i2c_master.c:34:0: /home/poul/Programmer/Espruino/tve/Espruino/src/jsutils.h:115:0: note: this is the location of the previous definition [#define](https://forum.espruino.com/search/?q=%23define) FALSE (0) ^ cc1: warning: unrecognized command line option "-Wno-float-conversion" [enabled by default] cc1: warning: unrecognized command line option "-Wno-discarded-qualifiers" [enabled by default] make: *** [targets/esp8266/i2c_master.o] Fejl 1 make: *** Venter på uafsluttede job.... make: *** wait: Ingen børneprocesser. Stop.
I have made clock streching for HTU21D.
I need to get JsError to work. I've tried different header file, but I get compile errors.
Any help is welcome.
I made a git clone from @TVE and made some changes to the file: Espruino / targets / esp8266 / i2c_master.c.
Here are the file:
Should I mention it is on a esp8266-01 from my Pico kickstarter set.
1 Attachment