p3p / pio-framework-arduino-lpc176x

10 stars 20 forks source link

Fix for I2C #40

Closed Serhiy-K closed 3 years ago

Serhiy-K commented 3 years ago

Tested with Marlin-bugfix-2.0.x and my LPC1768 dev board.

p3p commented 3 years ago

I think removing the address bitshift inherited from mbed will require changing Marlin to not compensate for it, the update to the CMSIS implementation is interesting, that's the driver supplied by LPC so will need to try and confirm your change doesn't have any side effects.

Serhiy-K commented 3 years ago

I tested my LCD panel with I2C bus with boards based on AVR-mega2560 , STM32F103 and STM32F411. In this cases function Wire.beginTransmission(address) uses address param without bitshift. The address is shifted inside this function. And all works good. About CMSIS. In attached file in function _I2CMasterTransferData line number 892 if (TransferCfg->rx_count < (TransferCfg->rx_length - 1)) looks like my patch. In this data read cycle all bytes transfered with ACK except last byte according to Master Receiver mode description in UM10360. If TransferCfg->rx_count will be less (TransferCfg->rx_length - 2) then it point to pre-last byte. Attached CMSIS file was installed in CoIDE and used in my old project without correction. CMSIS may have mistakes as other programs. lpc17xx_i2c.zip

Serhiy-K commented 3 years ago

I tried to find lpc17xx_i2c with comparison (rx_count < x_length - 2) but only found with (rx_count < x_length - 1). In fact it was a file as I added in previous message. I think x_length - 2 is typo. About address bitshift - just add a comment that a left shift address is used.