bugfix: i2c driver not working in 'RELEASE' configuration
bugfix: i2c driver not working in 'RELEASE' configuration

This issue is reported from https://github.com/espressif/esp-idf/issues/304.
We found that when we operate the hw command registers in I2C struct, sometimes the behaviour would be different in DEBUG/RELEASE optimisation level:

The code looks like this:
I2C[i2c_num]->command[p_i2c->cmd_idx].byte_num -= 0;

In DEBUG configuration:
I2C[i2c_num]->command[p_i2c->cmd_idx].byte_num -= 0;
400f3ab0:    3388          l32i.n    a8, a3, 12
400f3ab2:    14c882            addi    a8, a8, 20
400f3ab5:    a08840            addx4    a8, a8, a4
400f3ab8:    0020c0            memw
400f3abb:    2898          l32i.n    a9, a8, 8
400f3abd:    0020c0            memw
400f3ac0:    28b8          l32i.n    a11, a8, 8
400f3ac2:    74a090            extui    a10, a9, 0, 8
400f3ac5:    00af92            movi    a9, 0xffffff00
400f3ac8:    109b90            and    a9, a11, a9
400f3acb:    2099a0            or    a9, a9, a10
400f3ace:    0020c0            memw
400f3ad1:    2899          s32i.n    a9, a8, 8

In RELEASE configuration:
I2C[i2c_num]->command[p_i2c->cmd_idx].byte_num -= 0;
400f2ba2:    580572            l8ui    a7, a5, 88
400f2ba5:    747070            extui    a7, a7, 0, 8
400f2ba8:    0020c0            memw
400f2bab:    584572            s8i    a7, a5, 88

Looks like the compiler will make it a 8bit operation after optimisation.
But the register value changes from 0x901 to 0x101.
After this 8-bit optimisation, the 11th bit changed from 1 to zero, which caused this error.

We are still trying to find out why that happens, because there might be some risk when operating the register struct.
This is a workaround to avoid "-=" operation on I2C register struct fields.

dantonets/Pingzee-ESP32,espressif/esp-idf,espressif/esp-idf,empoweredhomes/esp-idf,MIhanguangyi/esp-idf,Hermiedapwdrman/esp-idf,www220/esp-idf,wmpluto/esp-idf,tidyjiang8/esp-idf-zh,hwmaier/esp-idf,dschaefer/esp-idf,mashaoze/esp-idf,MIhanguangyi/esp-idf,www220/esp-idf,empoweredhomes/esp-idf,nineisk/esp-idf,ajs124/esp-idf,armada-ai/esp-idf,jaracil/esp-idf,nineisk/esp-idf,www220/esp-idf,mashaoze/esp-idf,Hermiedapwdrman/esp-idf,wmpluto/esp-idf,jaracil/esp-idf,mashaoze/esp-idf,tidyjiang8/esp-idf-zh,MIhanguangyi/esp-idf,empoweredhomes/esp-idf,Hermiedapwdrman/esp-idf,dantonets/Pingzee-ESP32,dschaefer/esp-idf,dantonets/Pingzee-ESP32,www220/esp-idf,mashaoze/esp-idf,empoweredhomes/esp-idf,nineisk/esp-idf,dantonets/Pingzee-ESP32,shukyisme/esp-idf-kwik,ajs124/esp-idf,wmpluto/esp-idf,jaracil/esp-idf,tidyjiang8/esp-idf-zh,espressif/esp-idf,tidyjiang8/esp-idf-zh,MIhanguangyi/esp-idf,shukyisme/esp-idf-kwik,Hermiedapwdrman/esp-idf,armada-ai/esp-idf,armada-ai/esp-idf,dschaefer/esp-idf,mashaoze/esp-idf,empoweredhomes/esp-idf,dschaefer/esp-idf,espressif/esp-idf,dschaefer/esp-idf,ajs124/esp-idf,wmpluto/esp-idf,Hermiedapwdrman/esp-idf,shukyisme/esp-idf-kwik,hwmaier/esp-idf,www220/esp-idf,MIhanguangyi/esp-idf,nineisk/esp-idf,jaracil/esp-idf,hwmaier/esp-idf,shukyisme/esp-idf-kwik,hwmaier/esp-idf,shukyisme/esp-idf-kwik,tidyjiang8/esp-idf-zh,ajs124/esp-idf,armada-ai/esp-idf