difference between wire twowire

aster
Tue Dec 05, 2017 12:59 am
hello,
i am using a library which uses the TwoWire instance instead of Wire, which is exactly the difference?
from the repo i can see that twoWire is used inside softWire but i don’t think that theTwoWire inside the library would like to use a software emulation
that lib has been made firstly for teensy boards, is it possible that there TwoWire refers to the hardware i2c?

stevestrong
Tue Dec 05, 2017 9:46 am
The F103 Wire lib now includes the hardware I2C interface.
#include <Wire.h>
...
HardWire bus;

RogerClark
Tue Dec 05, 2017 10:03 am
Just to elaborate on what Steve said

TwoWire is Arduino’s internal class name for the Wire class

i.e Wire is an instance of TwoWire on AVR and ARM Arduino boards

In the LibMaple core, there are 2 implementations of I2C, HardWire and SoftWire

I guess for greater compatibility then perhaps we should rename the HardWire class to TwoWire, but I’m not sure why that library needs to create its own instance of the I2C class


stevestrong
Tue Dec 05, 2017 10:42 am
[RogerClark – Tue Dec 05, 2017 10:03 am] –
… but I’m not sure why that library needs to create its own instance of the I2C class

It makes sense because this way you can configure to use the interface you want without changing the library.


RogerClark
Tue Dec 05, 2017 10:51 am
Steve

Yes. I agree

Unfortunately this means , I must change the Hardwire class name to TwoWire :-(

I’ll need to try it and see what happens

It will break anything which references Hardwire


aster
Tue Dec 05, 2017 12:34 pm
[RogerClark – Tue Dec 05, 2017 10:03 am] – I guess for greater compatibility then perhaps we should rename the HardWire class to TwoWire

Wow so my guesses about twowire were actually corrects

I think that following straigh forward the arduino API would be the best practise. The library i posted in the first message works on arduino boards, teensy boards and also here, isn t this magic?

If you don t have time i will fork and then open a pull request (hoping to do all correctly)


stevestrong
Tue Dec 05, 2017 1:48 pm
We could simply rename HardWire to TwoWire, and the old TwoWire to SoftWire.
And define HardWire to TwoWire.

mrburnette
Tue Dec 05, 2017 3:48 pm
After being this way for years… I vote NO to changing names. If it were important, we would have done it back with the libmaple port effort to Arduino 1.5.

I think it is too late to worry about such things. If it is not documented in the WiKi, it should be. That should be enough.

Ray

UPDATE:

I have decided that I really don’t care (anymore.)

Because there are constant forces pressing to change “this” or change “that” and I might as well accept that no one really cares about how or why things are the way they are … folks just want what they want. Fortunately, I am a unique member and can do what the heck I want locally and I do not rely upon the forum or the STM32duino github cores for my own homebrew. Lastly, I’m tired… it is rare that I use the STM32F103 anymore… newer boards, more SRAM and more flash at the same or lower price-point of the Baite Maple Mini of 3 years ago. It is good to be eclectic.


aster
Tue Dec 05, 2017 4:59 pm
So if i am not wrong:

WireBase is the actual library which do the i2c stuffs (in arduino is twi)
Wire is exactly the same as Arduino’s Wire

Ray, i am just an hobbiest so i am the last person who could take word over a programming problem but the arduino core is powerful, it s not anymore true that arduino = avr, now arduino is a simpler interface to use many different architectures

Arduino will continue to exist (i am not sure about CMSIS, HAL or others) and their api will become bigger and with the time more and more hardware will use it. At some point in the future we will change it, why don t do it today?


RogerClark
Tue Dec 05, 2017 7:49 pm
i have not checked or tried this, but we may just be able to add

#define TwoWire Hardwire

in Wire.h


mrburnette
Wed Dec 06, 2017 2:18 pm
[aster – Tue Dec 05, 2017 4:59 pm] –

Ray, i am just an hobbiest so i am the last person who could take word over a programming problem but the arduino core is powerful, it s not anymore true that arduino = avr, now arduino is a simpler interface to use many different architectures

The issue I object to is that STM32duino as ported (a long history here) will never make everyone happy as-is. Therefore change is inevitable; but change must be managed. Only Roger implements changes and he looks to the community here to balance fixing something over breaking something.

We must be prudent on changes. Changing a function or class simply to rename it is IMHO very low priority, approaching 0 in need.

No one coming over from Arduino.cc should expect immediate gratification; we have a WiKi that absolutely is required reading although some newbies seem to post without reading. STM32duino was built for seasoned Arduino users to move over to a more powerful & less expensive architecture; in the beginning, it was even stated that the forum was not for beginning Arduino users simply because one needs to have a good handle on things “Arduino” before venturing into the STM32 waters. That said, we do welcome beginners, but there are no official forum moderators to manage newbie questions – thus, the WiKi must incorporate roadblocks and to-do knowledge.

Therefore, rather than simply renaming a function or a class and risk breaking something, the end-user should simply deal-with-it. That is my opinion.

Ray

Added:
We have documentation history from the original forum that gets lost or muddled if we go willynilly changing stuff without thinking:
http://forums.leaflabs.com/forums.leafl … ge=2&id=28

leaflabsandy quoted here:
<Testing of DS3231 RTC>
I got Wire to compile.

Changes to my sketch.(above)
Made instance “TwoWire Wire;”

Changed SDA pin in Wire.h from 7 to 5

Testing DS3231 Results: Failed.
Time/date is “garbled” or received time / date values are out of range?

Testing changes:
Changed I2C delay from 1 to (2 thru 5) with no results.

Note: I did check the end of transmission return values and they were 0;
Note: The DS3231 ChronoDot was previously tested good on another 3.3 VDC
microcontroller.
Note: I only copied “Wire” into the libraries if other changes were made to other
modules then let me know.
Note: The DS3231 has a fast clock I2C interface. (400KHz)


aster
Wed Dec 06, 2017 9:21 pm
Roger,

pull request created https://github.com/rogerclarkmelbourne/ … 2/pull/399

as you can see from the immage we will break just 2 codes: one is a example for the ssd1306 and the other a version of the famous i2c_scanner which will work anyway
i think we could handle this


RogerClark
Wed Dec 06, 2017 10:10 pm
This is quite a major change (though I agree it does bring the core in line with the internals of the official Arduino core)

I will need to wait for significant testing by everyone and also feedback via github and here

This change needs its own thread


aster
Thu Dec 07, 2017 12:35 am
[RogerClark – Wed Dec 06, 2017 10:10 pm] –
This is quite a major change (though I agree it does bring the core in line with the internals of the official Arduino core)

I will need to wait for significant testing by everyone and also feedback via github and here

This change needs its own thread

Ok, would you mind to open the thread? English is not my first language and i think you would be better to point out the difference between the two choise


RogerClark
Thu Dec 07, 2017 12:41 am
OK

Leave a Reply

Your email address will not be published. Required fields are marked *