Re-using code from Arduino Uno AVR for Portenta H7

I have code that emulates I2C slaves for the Arduino Uno. I am trying to re-use the same code, but for the Portenta H7. However, when compiling the sketch, it cannot find / include a file since the original code is using the AVR core (Arduino Uno uses Atmel Atmega MCU). So I get the following error since Portenta is not AVR

C:\Users\cchen\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.3.0\libraries\Wire\utility\twi.c:26:10: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
          ^~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Portenta H7 (M4 core).

What can I do to reuse the code? Is there any way I can move some folders around so that it can find the file/directory? Or would it not work regardless since the MCU on the Portenta is ARM STM32 and not AVR? Thank you for your help.

We don't know what "it" is, because you didn't post the code.

It's impossible to answer, "will code that emulates I2C slaves for the Arduino Uno work on some other processor" in a definite way without getting into the details of that code. Because it is an implementation issue.

Did you write this code yourself?

You can't, on the Portenta. Any code that uses "avr/io.h" is specific to AVR processors.

BINGO!

Why is there a utilities directory under ...\libraries\Wire? It does not belong there. There should be only Wire.h and Wire.cpp.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.