Testato / SoftwareWire

Creates a software I2C/TWI bus on every pins
GNU General Public License v3.0
148 stars 33 forks source link

Incompatible with Arduino Uno Wifi Rev. 2 #17

Closed Guerillah closed 3 years ago

Guerillah commented 5 years ago

Trying to use this library on the Arduino Uno Wifi Rev. 2 and am getting the error below. It still uses an 8 bit micro so I'm not sure what the incompatibility is. Hoping for some help/explanation. Thanks!

./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:megaavr:uno2018:mode=on -build-cache /tmp -build-path /tmp/212750505/build -verbose -prefs runtime.tools.avr-gcc.path=./opt/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.avrdude.path=./opt/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.arduinoOTA.path=./opt/tools/arduinoOTA/1.2.1 -libraries /tmp/212750505/custom -libraries /tmp/212750505/pinned /tmp/212750505/sketch_jan27a

Using library adafruit_unified_sensor_1_0_2 at version 1.0.2 in folder: /home/ubuntu/opt/libraries/latest/adafruit_unified_sensor_1_0_2

Using library adafruit_tsl2561_1_0_2 at version 1.0.2 in folder: /home/ubuntu/opt/libraries/latest/adafruit_tsl2561_1_0_2

/home/ubuntu/opt/libraries/latest/softwarewire_1_5_1/SoftwareWire.cpp: In constructor 'SoftwareWire::SoftwareWire(uint8_t, uint8_t, boolean, boolean)':

/home/ubuntu/opt/libraries/latest/softwarewire_1_5_1/SoftwareWire.cpp:133:39: error: 'portModeRegister' was not declared in this scope

_sdaDirReg = portModeRegister(port);

^

exit status 1

Koepel commented 5 years ago

Confirmed, but I don't know a solution.

The Arduino Wifi Rev. 2 uses the ATmega4809 which is like any other AVR microcontroller but with a modern touch. Arduino uses a seperate board/core environment for just the ATmega4809. That board/core environment is called "megaavr" and it has one thing missing: portModeRegister().

It is defined in "Arduino.h" or "variant.h". The "Arduino.h" of the "megaavr" board/core environment has the portOutputRegister() and portInputRegister, but the portModeRegister() is missing. I think it is a bug of the Arduino board/core environment.

The definitions for the pin are not the same. They are more like the newer SAMD21 processors and not like the old ATmega microcontrollers. I don't know how to add the missing line. It could be: #define portModeRegister(P) ( (volatile uint8_t *)( &portToPortStruct(P)->DIR ) )

Have you seen the list in the Wiki ? The SlowSoftWire should work on every board.