I2C with PCF8574 for HD44780 LCD module

As in Arduino UNO I’ve included

#include <PCF8574_HD44780_I2C.h>
PCF8574_HD44780_I2C lcd(0x3F,16,2);

but I have the errors below highligthed in bold, if I include or do not wire.h.

Any suggestion?


ATTENZIONE: la libreria Wire dichiara di funzionare sulle architetture samd e potrebbe non essere compatibile con la tua scheda che utilizza l’architettura samd_beta
In file included from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.25\cores\arduino/WVariant.h:22,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.25\variants\mkrvidor4000/variant.h:24,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.25\libraries\Wire/Wire.h:24,

from C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:16,

from C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:11:

C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: “LITTLE_ENDIAN” redefined

#define LITTLE_ENDIAN 1

In file included from c:\users\morsani\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,

from c:\users\morsani\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,

from C:\Users\morsani\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.25\cores\arduino/Print.h:23,

from C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:15,

from C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:11:

c:\users\morsani\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition

#define LITTLE_ENDIAN _LITTLE_ENDIAN

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp: In member function ‘void PCF8574_HD44780_I2C::begin(uint8_t, uint8_t, uint8_t)’:

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:82:13: error: ‘_BV’ was not declared in this scope

write4bits(_BV(P4) | _BV(P5));

^~~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:82:13: note: suggested alternative: ‘_B’

write4bits(_BV(P4) | _BV(P5));

^~~

_B

In file included from C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:11:0:

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp: In member function ‘void PCF8574_HD44780_I2C::backlight()’:

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:29:23: error: ‘_BV’ was not declared in this scope
#define LCD_BACKLIGHT _BV(P3) // Led ON

^

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:215:16: note: in expansion of macro ‘LCD_BACKLIGHT’

_backlightval=LCD_BACKLIGHT;

^~~~~~~~~~~~~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:29:23: note: suggested alternative: ‘_B’

#define LCD_BACKLIGHT _BV(P3) // Led ON

^

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:215:16: note: in expansion of macro ‘LCD_BACKLIGHT’

_backlightval=LCD_BACKLIGHT;

^~~~~~~~~~~~~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp: In member function ‘virtual size_t PCF8574_HD44780_I2C::write(uint8_t)’:

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:33:12: error: ‘_BV’ was not declared in this scope
#define Rs _BV(P0) // Register select
** ^**

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:228:14: note: in expansion of macro ‘Rs’

send(value, Rs);

^~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:33:12: note: suggested alternative: ‘_B’

#define Rs _BV(P0) // Register select

^

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:228:14: note: in expansion of macro ‘Rs’

send(value, Rs);

^~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp: In member function ‘void PCF8574_HD44780_I2C::pulseEnable(uint8_t)’:

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:31:12: error: ‘_BV’ was not declared in this scope

#define En _BV(P2) // Enable

^

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:256:24: note: in expansion of macro ‘En’

expanderWrite(_data | En); // En high

^~

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.h:31:12: note: suggested alternative: ‘_B’

#define En _BV(P2) // Enable

^

C:\Users\morsani\Documents\Arduino\libraries\PCF8574_HD44780_I2C\PCF8574_HD44780_I2C.cpp:256:24: note: in expansion of macro ‘En’

expanderWrite(_data | En); // En high

^~

exit status 1
Errore durante la compilazione per la scheda Arduino MKR Vidor 4000.

Is it trying to use AVR library for ARM Cortex M0?
If I remember right _BV is only defined for AVR

Yes, it could be, it is, but I cannot find a similar library specified for SAMD (_beta).
Do tou where I can find it?

Thanks once more for your help Limba.

Found a solution to the _BV undefined.

Put a

#define _BV(x) bit(x)

on PCF8574_HD44780_I2C.h file to resolve the undefined.

Now the display on I2C works.