tmedicci opened a new pull request, #17100:
URL: https://github.com/apache/nuttx/pull/17100
## Summary
* risc-v/espressif/i2c: Update common source code functions
- Updates the common source code for the I2C peripheral used by
Espressif's RISC-Vs SoCs. This enables newer SoCs to be supported in the future
while maintaining backwards compatibility.
## Impact
Impact on user: No.
Impact on build: No.
Impact on hardware: Not yet: newer Espressif SoCs can be supported on NuttX
following this change.
Impact on documentation: No.
Impact on security: No.
Impact on compatibility: No. It's totally backwards compatible.
## Testing
Testing can be performed using any of the `i2c` defconfigs available for any
of Espressif's RISC-V-based devices (ESP32-C3, ESP32-C6, or ESP32-H2). The
behavior of the UART-related peripherals didn't change, and this PR's results
are the same of the results before it. To test it, it's required to have a
master and a slave device. This can be achieved using the same device,
attaching the pins externally, or using a different device as master or slave.
Focusing on "self-test", i.e., using a single device with two I2C
peripherals (one set as master and the other as slave) and attaching the pins
externally, please note that to the following considerations:
- ESP32-C3, ESP32-C6 and ESP32-H2 have at least one HP core I2C peripheral
(that can act as master or slave).
- ESP32-H2 has two HP-core I2C peripherals (one can be set as master and the
other as slave).
- ESP32-C6 has one HP-core I2C peripheral (set as slave) and one LP-core I2C
peripheral (that can act as master only);
- ESP32-C3 has only one single HP-core peripheral (set as slave). The I2C
bitbang (currently only implemented to act as master) will be used for the
self-test.
### Building
#### ESP32-C3
```
make -j distclean && ./tools/configure.sh esp32c3-generic:i2c &&
kconfig-tweak --set-val CONFIG_I2CTOOL_MAXBUS 3 && kconfig-tweak --set-val
ESPRESSIF_I2C0_SCLPIN 4 && kconfig-tweak -e ESPRESSIF_I2C0_SLAVE_MODE &&
kconfig-tweak -e ESPRESSIF_I2C_BITBANG && kconfig-tweak --set-val
ESPRESSIF_I2C_BITBANG_SCLPIN 6 && kconfig-tweak --set-val
ESPRESSIF_I2C_BITBANG_SDAPIN 7 && make olddefconfig && make flash
ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && picocom -b 115200 /dev/ttyUSB0
```
#### ESP32-C6
```
make -j distclean && ./tools/configure.sh esp32c6-devkitc:i2c &&
kconfig-tweak --set-val CONFIG_I2CTOOL_MAXBUS 3 && kconfig-tweak --set-val
ESPRESSIF_I2C0_SCLPIN 4 && kconfig-tweak -e ESPRESSIF_I2C0_SLAVE_MODE &&
kconfig-tweak -e ESPRESSIF_LP_I2C0 && make olddefconfig && make flash
ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && picocom -b 115200 /dev/ttyUSB0
```
#### ESP32-H2
```
make -j distclean && ./tools/configure.sh esp32h2-devkit:i2c &&
kconfig-tweak --set-val CONFIG_I2CTOOL_MAXBUS 3 && kconfig-tweak --set-val
ESPRESSIF_I2C0_SCLPIN 4 && kconfig-tweak -e ESPRESSIF_I2C1_SLAVE_MODE && make
olddefconfig && make flash ESPTOOL_PORT=/dev/ttyUSB0 -s -j$(nproc) && picocom
-b 115200 /dev/ttyUSB0
```
### Running
#### ESP32-C3
Connect I2C0 (slave) `SCL` to I2C3 (bitbang/master) `SCL` and I2C0 (slave)
`SDA` to I2C3 (bitbang/master) `SDA` pins externally:
| | SCL | SDA |
| -------------| --- | --- |
| I2C0 | 4 | 5 |
| I2C3 bitbang | 6 | 7 |
And run `i2c dev -b 3 0x28 0x28`.
#### ESP32-C6
Connect I2C0 (slave) `SCL` to LPI2C (master) `SCL` and I2C0 (slave) `SDA` to
LPI2C (master) `SDA` pins externally:
| | SCL | SDA |
| ------| --- | --- |
| I2C0 | 4 | 5 |
| LPI2C | 7 | 6 |
And run `i2c dev -b 2 0x28 0x28`.
#### ESP32-H2
Connect I2C1 (slave) `SCL` to I2C0 (master) `SCL` and I2C1 (slave) `SDA` to
I2C1 (master) `SDA` pins externally:
| | SCL | SDA |
| -----| --- | --- |
| I2C0 | 4 | 5 |
| I2C1 | 2 | 1 |
And run `i2c dev -b 0 0x28 0x28`.
### Results
#### ESP32-C3
```
nsh\> i2c dev -b 3 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 5 6 7 8 9 a b c d e f 00:\
10:\
20: 28\
30:\
40:\
50:\
60:\
70:
```
#### ESP32-C6
```
nsh\> i2c dev -b 2 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: 00000000 COUNT: 1 EVENT: SENDADDR ( 1) PARM: 00000028 TIME: 0
2. STATUS: 37000001 COUNT: 1 EVENT: RCVMODEEN ( 3) PARM: 00000000 TIME: 0
3. STATUS: 37000101 COUNT: 1 EVENT: RCVBYTE ( 4) PARM: 00000000 TIME: 0
4. STATUS: 37000101 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:
```
#### ESP32-H2
```
nsh\> i2c dev -b 0 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: 0000c000 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:
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]