Using Wire1 on Thing Plus

Wire1 isn’t defined (fails to compile). From how I read the guide, Wire is for the Qwiic port, and through-hole pins 16, 17 for SDA1 and SCL1 use Wire1. Please don’t tell me I need to dig in and edit the variants file to enable two i2c ports.

I don’t think the pins are defined for wire1, you might need to define those in your begin statement.

Hmm. The failure is in the linker. Unresolved “Wire1” but I tried it on a different computer and it resolved. Both have the same artemis version in Arduino-IDE and the same ambiq SDK version. No problem on the second PC.

Curiouser and curiouser.

Looks like my distribution repository JSON settings are different. They’re both at the “latest” but the meaning of that differs. The older 1.2.0 has Wire1 defined, but the newer one (2.0.5) doesn’t. So at some point during the porting process to mbed-OS, the Wire1 port got dropped.

Looking at both versions of variant.h files, there are many differences. I haven’t gotten to the bottom of how to define a second I2C bus within the ambiq/mbed environment. But that’s not really my job.

Editing variant.h will get the second I2C device created, and the Arduino IDE compiles and links. But now there’s a runtime mbed-OS error

++ MbedOS Error Info ++

Error Status: 0x80010130 Code: 304 Module: 1

Error Message: pinmap not found for peripheral

Location: 0x26903

Error Value: 0x10

Current Thread: main Id: 0x10004C70 Entry: 0x28031 StackSize: 0x1000 StackMem: 0x100068F0 SP: 0x1000782C

For more info, visit: https://mbed.com/s/error?error=0x800101 … THING_PLUS

– MbedOS Error Info –

#if 1 // 2021-02-26 jry

#define VARIANT_WIRE_INTFCS 2

// Wire1 Pins

#define VARIANT_Wire1_SCL 17

#define VARIANT_Wire1_SDA 16

// end 2021-02-26 jry

#else // original

#define VARIANT_WIRE_INTFCS 1

#endif

Ive had LOTS of troubles with this kind of things. I had a running code on 1.3.0 using three I2C ports, updated to 2.0.2 to get BLE support and those multiple I2C ports didn’t work anymore. I tried tweaking every definition file I found with no luck and waited through versions 2.0.3 and 2.0.4 until it was suddenly solved in 2.0.5. You have to “manually” define your ports to work’, though, using “MbedI2C” object. Something like this:

MbedI2C myWire(SDA,SCL);

With SDA and SCL being the pin numbers on the Artemis Module. Then you use myWire object the same way you use Wire, Wire1, etc. Like this:

myWire.begin();

Hope it works for you.

Dang. Still the portmap runtime error.

I wonder what’s different between our situations?

(I tried both variants.h, i.e. #define VARIANT_WIRE_INTFCS 2, and defining VARIANT_Wire1_SCL/SDA; and the original 2.0.5)

My code is:

#define VARIANT_Wire2_SCL 17

#define VARIANT_Wire2_SDA 16

MbedI2C Wire2(VARIANT_Wire2_SDA,VARIANT_Wire2_SCL);

I wonder if the Wire2 name is special? Nah… tried a different name, same deal.

Fixed! Version 2.1.0 core did the trick.