eren-terzioglu opened a new pull request, #15906: URL: https://github.com/apache/nuttx/pull/15906
## Summary I2C Slave peripheral support added for ESP32C3, ESP32C6, ESP32H2, ESP32, ESP32S2 and ESP32S3 to use I2C driver in slave mode. * esp32[c3|c6|h2]: Add I2C slave support * esp32[s2|s3]: Add I2C Slave support ## Impact ESP32C3, ESP32C6, ESP32H2, ESP32, ESP32S2, ESP32S3 Impact on user: No (There wasn't any I2C Slave mode support and configuration system won't be affected for this addition) Impact on build: No Impact on hardware: ESP32, ESP32S2, ESP32S3, ESP32C3, ESP32C6, ESP32H2 Impact on documentation:Yes (Peripheral Support section for impacted devices updated) Impact on security:No Impact on compatibility:No ## Testing One ESP device used as master(could be any device) with using `esp32c3-generic:i2c` config for example. Other device used as slave device (must be esp32c3, esp32c6, esp32h2 or esp32s3) used with using these commands: #### To build for esp32c6 make -j distclean && ./tools/configure.sh esp32c6-devkit:i2s && kconfig-tweak -d CONFIG_ESPRESSIF_I2C0_MASTER_MODE && kconfig-tweak -e CONFIG_ESPRESSIF_I2C0_SLAVE_MODE && kconfig-tweak -e DEBUG_SYMBOLS && make olddefconfig && make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_BINDIR=./ ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom #### To build for esp32c3 make -j distclean && ./tools/configure.sh esp32c3-generic:i2s && kconfig-tweak -d CONFIG_ESPRESSIF_I2C0_MASTER_MODE && kconfig-tweak -e CONFIG_ESPRESSIF_I2C0_SLAVE_MODE && kconfig-tweak -e DEBUG_SYMBOLS && make olddefconfig && make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_BINDIR=./ ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom #### To build for esp32h2 make -j distclean && ./tools/configure.sh esp32h2-devkit:i2s && kconfig-tweak -d CONFIG_ESPRESSIF_I2C0_MASTER_MODE && kconfig-tweak -e CONFIG_ESPRESSIF_I2C0_SLAVE_MODE && kconfig-tweak -e DEBUG_SYMBOLS && make olddefconfig && make flash EXTRAFLAGS="-Wno-cpp -Werror" ESPTOOL_BINDIR=./ ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && minicom After flashing operation master device connected to slave device (GPIO5-GPIO5, GPIO6-GPIO6) and run `i2c dev 0x28 0x28`. Expected output should be like this: ``` nsh> i2c dev 0x28 0x28 NOTE: Some devices may not appear with this scan. You may also try a scan with the -z flag to discover more devices using a zero-byte write request. 0 1 2 3 4 Elapsed time: 0 1. STATUS: 6600c000 COUNT: 1 EVENT: SENDADDR ( 1) PARM: 00000028 TIME: 0 2. STATUS: 3700c001 COUNT: 1 EVENT: RCVMODEEN ( 3) PARM: 00000000 TIME: 0 3. STATUS: 3700c101 COUNT: 1 EVENT: RCVBYTE ( 4) PARM: 00000000 TIME: 0 4. STATUS: 3700c101 COUNT: 1 EVENT: STOP ( 5) PARM: 00000001 TIME: 0 5 6 7 8 9 a b c d e f 00: 10: 20: 28 30: 40: 50: 60: 70: ``` Alternatively, bitbang driver can be used to test it on single device with connecting pins (GPIO0-GPIO5, GPIO1-GPIO6) with applying same command explained upper. To test Xtensa devices (e.g ESP32S3), same steps should be applied but pins might be different. For example esp32s3 connection to master device should be (GPIO1-GPIO5, GPIO2-GPIO6). Update: I tested write functionality with a small script and read message on master device with `i2c get -a 0x28` command. You can use this code to test slave write functionality: ``` #define ESP_I2C_SLAVE_PATH "/dev/i2cslv0" int main(int argc, char *argv[]) { int i2c_slave_fd; int ret; uint8_t buffer[5] = {0xAA}; i2c_slave_fd = open(ESP_I2C_SLAVE_PATH, O_RDWR); ret = write(i2c_slave_fd, buffer, 5); close(i2c_slave_fd); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org