esp-idf-cxx
esp-idf-cxx copied to clipboard
Fix for esp32c6
Description
A minor fix so esp-idf-cxx can compile correctly for esp32c6 (and maybe other?)
i2c_cxx incorrectly assumed that I2C_NUM_1 would exist if SOC_I2C_NUM >= 2. But that's not the case when the device has 1 HP i2c and 1 LP i2c.
This changes i2c_cxx to look at only the HP SOC_HP_I2C_NUM instead
Testing
My own code compiles now 😄
Checklist
Before submitting a Pull Request, please ensure the following:
- [x] 🚨 This PR does not introduce breaking changes.
- [ ] All CI checks (GH Actions) pass.
- [x] Documentation is updated as needed.
- [x] Tests are updated or added as necessary.
- [x] Code is well-commented, especially in complex areas.
- [x] Git history is clean — commits are squashed to the minimum necessary.
Tests fails for unrelated reasons
https://github.com/espressif/esp-idf/issues/14291 I think same issue by the way. Can you rerun tests?
Can you rerun tests?
I don't think I have permissions to do that
This will not fix the issue! Please see my proposed request: oops - removing the fork obviously closes a pull request.
I'm sorry. At least this should be rejected as the logic is not OK at all!
SOC_I2C_NUM is the total of I2C devices of the CPU. It's the sum of SOC_HP_I2C_NUM and SOC_LP_I2C_NUM. The problem arises from that respective check not accounting for this fact.
#if SOC_I2C_NUM >= 2
/* fix issue #38 "Build fails on ESP32-C6 due to missing I2C_NUM_1 in i2c_cxx.cpp". **
* This fix only adresses the problem at hand in case of the C6, where SOC_I2C_NUM == 2 **
* and we have "I2C_NUM_0" as well as "LP_I2C_NUM_0" defined, but no "I2C_NUM_1". */
# if SOC_LP_I2C_SUPPORTED && SOC_I2C_NUM == 2
static_assert( (LP_I2C_NUM_0 == 1), "LP_I2C_NUM_0 must be equal to 1, as I2C_NUM_0 already is equal to 0");
# else
static_assert( (I2C_NUM_1 == 1), "I2C_NUM_1 must be equal to 1");
# endif
#endif // SOC_I2C_NUM >= 2
Even this could logically be not completely correct. Please review.