1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

Update LiquidCrystal_I2C.cpp

Ensure that pipelined I/O requests complete before the next one is set up.
This commit is contained in:
Neil McKechnie 2023-02-22 21:06:39 +00:00
parent 4eb277f19e
commit 4deb323802

View File

@ -194,6 +194,7 @@ void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) {
uint8_t lownib = ((value & 0x0f) << BACKPACK_DATA_BITS) | mode; uint8_t lownib = ((value & 0x0f) << BACKPACK_DATA_BITS) | mode;
// Send both nibbles // Send both nibbles
uint8_t len = 0; uint8_t len = 0;
rb.wait();
outputBuffer[len++] = highnib|En; outputBuffer[len++] = highnib|En;
outputBuffer[len++] = highnib; outputBuffer[len++] = highnib;
outputBuffer[len++] = lownib|En; outputBuffer[len++] = lownib|En;
@ -208,6 +209,7 @@ void LiquidCrystal_I2C::write4bits(uint8_t value) {
// I2C clock cycle time of 2.5us at 400kHz. Data is clocked in to the // I2C clock cycle time of 2.5us at 400kHz. Data is clocked in to the
// HD44780 on the trailing edge of the Enable pin. // HD44780 on the trailing edge of the Enable pin.
uint8_t len = 0; uint8_t len = 0;
rb.wait();
outputBuffer[len++] = _data|En; outputBuffer[len++] = _data|En;
outputBuffer[len++] = _data; outputBuffer[len++] = _data;
I2CManager.write(_Addr, outputBuffer, len, &rb); // Write command asynchronously I2CManager.write(_Addr, outputBuffer, len, &rb); // Write command asynchronously
@ -216,6 +218,7 @@ void LiquidCrystal_I2C::write4bits(uint8_t value) {
// write a byte to the PCF8574 I2C interface. We don't need to set // write a byte to the PCF8574 I2C interface. We don't need to set
// the enable pin for this. // the enable pin for this.
void LiquidCrystal_I2C::expanderWrite(uint8_t value) { void LiquidCrystal_I2C::expanderWrite(uint8_t value) {
rb.wait();
outputBuffer[0] = value | _backlightval; outputBuffer[0] = value | _backlightval;
I2CManager.write(_Addr, outputBuffer, 1, &rb); // Write command asynchronously I2CManager.write(_Addr, outputBuffer, 1, &rb); // Write command asynchronously
} }