OVMS3-idf/components/driver
Wangjialin 94b91ee4af 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.
2017-03-19 16:09:44 +08:00
..
include/driver Merge branch 'bugfix/free_iram' into 'master' 2017-03-03 14:08:10 +08:00
test esp32: add [ignore] tag to some unit test cases for CI 2017-01-18 17:08:20 +08:00
component.mk build system: Refactor component.mk to not need component_common.mk 2016-11-10 15:52:22 +11:00
gpio.c gpio: Attach gpio intr to the isr_server on the right core. 2017-01-20 14:56:59 +11:00
i2c.c bugfix: i2c driver not working in 'RELEASE' configuration 2017-03-19 16:09:44 +08:00
i2s.c Add i2s driver 2016-12-29 17:29:14 +08:00
ledc.c driver: ledc - update fading functions, add example and doc 2017-01-05 17:57:52 +08:00
pcnt.c Merge branch 'bugfix/driver_cleanup_log' into 'master' 2016-12-12 10:15:25 +08:00
periph_ctrl.c Add SPI Master driver, example, test and docs 2017-01-06 14:20:32 +08:00
rmt.c RMT driver: Rename rmt_set_evt_intr_en to rmt_set_tx_thr_intr_en 2016-12-28 10:17:56 +11:00
rtc_module.c rtc_gpio: Replace RTC_GPIO_IS_VALID_GPIO macro with inline function 2017-02-20 10:39:29 +11:00
sdmmc_host.c sdmmc: Use slot width as default slot_config width parameter, instead of 4 2017-03-03 14:59:15 +11:00
sdmmc_private.h sdmmc: add peripheral driver and protocol layer 2017-01-09 04:51:24 +08:00
sdmmc_transaction.c sdmmc: add peripheral driver and protocol layer 2017-01-09 04:51:24 +08:00
sigmadelta.c driver: sigma-delta 2016-12-18 17:20:17 +08:00
spi_master.c Use THRESH_DMA_TRANS define everywhere, make code match "smaller or equal" description 2017-02-21 18:27:56 +08:00
timer.c Convert DOS line ends to Unix line ends in drivers 2016-12-15 09:45:40 +08:00
uart.c bugfix: fix uart 2-stop-bit error 2017-03-12 11:38:14 +08:00