sparkfun / Arduino_Apollo3

Arduino core to support the Apollo3 microcontroller from Ambiq Micro
83 stars 37 forks source link

using Wire1 on the core v 2.0.5 [probably needed to program the Artemis Global Tracker] #347

Closed jerabaul29 closed 3 years ago

jerabaul29 commented 3 years ago

I think (to be confirmed there by the experts :) ) that I need to be able to access specifically Wire1 to be able to use the GPS on the Artemis Global Tracker (see issue https://github.com/sparkfunX/Artemis_Global_Tracker/issues/18 ).

In the core v 2.0.5, doing:

#include <Wire.h>

void setup(){
  Wire1.begin();
}

as was doable in the core v1 seems to be impossible:

exit status 1
'Wire1' was not declared in this scope
jerabaul29 commented 3 years ago

Ok, looking here:

https://github.com/sparkfun/Arduino_Apollo3/blob/fbb2eaca27245627bf22b59f43faa232635bcd01/libraries/Wire/src/Wire.h#L68-L85

and there:

https://github.com/sparkfun/Arduino_Apollo3/blob/fbb2eaca27245627bf22b59f43faa232635bcd01/libraries/Wire/src/Wire.cpp#L161-L178

gives me good hope that this should be an easy fix.

jerabaul29 commented 3 years ago

Ok, got some help on the tracker website, it should be possible to set up a I2C with custom pins, looking at it now.

jerabaul29 commented 3 years ago

Ok, more problems coming up due to wrong pinmaps; taking the discussion on the Global Tracker issue though, feel free to help there.

jry-slc commented 3 years ago

This is probably another symptom of the same bug. Echoing my post to the sparkfun forum: Home . SparkFun . Artemis . Artemis Arduino Core Using Wire1 on Thing Plus

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

Wenn0101 commented 3 years ago

Alright. I went back thru the targets and added wire interfaces for some of the Wire interfaces that were labelled on the board but not defined in the software. This means that @jry-slc Wire1 should be available on the thing plus without you needing to define it yourself.

I wanted to clarify how to define a custom Wire when we don't have one defined on the pins you would like already.

#define mySDA \\YOUR PIN HERE
#define mySCL  \\YOUR PIN HERE
TwoWire myWire(mySDA, mySCL); 
//Name this anything you would like, myWire chosen in this example
//No need to change VARIANT_WIRE_INTFCS this is used internally when defining built in wire interfaces
//No need to use MbedI2C type, TwoWire will work
//Make sure to begin before using
void setup() {
  myWire.begin();
}