From a25ccb2ef7893d7f9a33b16a63fb72f996051eea Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 17 Nov 2020 02:30:12 +0200 Subject: [PATCH] Fix Wire.begin causing divide by zero Fixes: https://github.com/espressif/arduino-esp32/issues/4530 --- cores/esp32/esp32-hal-i2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index cfc620f2..df9eace7 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -1798,6 +1798,10 @@ i2c_t * i2cInit(uint8_t i2c_num, int8_t sda, int8_t scl, uint32_t clk_speed){ if(i2c_num >= 2){ return NULL; } + if(!clk_speed){ + //originally does not change the speed, but getFrequency and setFrequency need to be implemented first. + clk_speed = 100000; + } i2c_t * out = NULL; if(i2c_ports[i2c_num] == NULL){ out = (i2c_t*)malloc(sizeof(i2c_t));