stickbreaker / arduino-esp32

Arduino core for the ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: set and read SDA/SCL

suculent opened this issue · comments

Hello,

I've a question. I'm adding I2C slave implementation based on your code (porting from ESP8266 to ESP32), however I'm not sure, how to replace access to GPIO control registers (as in https://github.com/esp8266/Arduino/blob/master/cores/esp8266/esp8266_peri.h).

What I need to implement is:

#define GPES   ESP8266_REG(0x310) //GPIO_ENABLE_SET WO
#define GPEC   ESP8266_REG(0x314) //GPIO_ENABLE_CLR WO
#define GPI    ESP8266_REG(0x318) //GPIO_IN RO (Read Input Level)

#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_READ()  ((GPI & (1 << twi_sda)) != 0)
#define SCL_LOW()   (GPES = (1 << twi_scl))
#define SCL_HIGH()  (GPEC = (1 << twi_scl))
#define SCL_READ()  ((GPI & (1 << twi_scl)) != 0)

I don't have an answer. The 8266 and 32 have totally different hardware.

Chuck.