Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jerabaul29 opened this issue Feb 11, 2021 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jerabaul29
Copy link

jerabaul29 commented Feb 11, 2021

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 sparkfunX/Artemis_Global_Tracker#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
  • any way to get this to work already in core v 2.0.5?
  • if not, can this be fixed? Any timeline? I really need this fix badly, any "hack" that could make it work?
@jerabaul29
Copy link
Author

Ok, looking here:

#if VARIANT_WIRE_INTFCS > 0
extern arduino::MbedI2C Wire;
#endif
#if VARIANT_WIRE_INTFCS > 1
extern arduino::MbedI2C Wire1;
#endif
#if VARIANT_WIRE_INTFCS > 2
extern arduino::MbedI2C Wire2;
#endif
#if VARIANT_WIRE_INTFCS > 3
extern arduino::MbedI2C Wire3;
#endif
#if VARIANT_WIRE_INTFCS > 4
extern arduino::MbedI2C Wire4;
#endif
#if VARIANT_WIRE_INTFCS > 5
extern arduino::MbedI2C Wire5;
#endif

and there:

#if VARIANT_WIRE_INTFCS > 0
arduino::MbedI2C Wire(VARIANT_Wire_SDA, VARIANT_Wire_SCL);
#endif
#if VARIANT_WIRE_INTFCS > 1
arduino::MbedI2C Wire1(VARIANT_Wire1_SDA, VARIANT_Wire1_SCL);
#endif
#if VARIANT_WIRE_INTFCS > 2
arduino::MbedI2C Wire2(VARIANT_Wire2_SDA, VARIANT_Wire2_SCL);
#endif
#if VARIANT_WIRE_INTFCS > 3
arduino::MbedI2C Wire3(VARIANT_Wire3_SDA, VARIANT_Wire3_SCL);
#endif
#if VARIANT_WIRE_INTFCS > 4
arduino::MbedI2C Wire4(VARIANT_Wire4_SDA, VARIANT_Wire4_SCL);
#endif
#if VARIANT_WIRE_INTFCS > 5
arduino::MbedI2C Wire5(VARIANT_Wire5_SDA, VARIANT_Wire5_SCL);
#endif

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

@jerabaul29
Copy link
Author

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
Copy link
Author

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

@ghost ghost assigned Wenn0101 Feb 26, 2021
@ghost ghost added the bug Something isn't working label Feb 26, 2021
@ghost ghost added this to the v2.1.0 milestone Mar 2, 2021
@jry-slc
Copy link

jry-slc commented Mar 3, 2021

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
Copy link
Contributor

Wenn0101 commented May 12, 2021

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();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants