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

variants are missing SDA and SCL macros & using inconsistent Wire/Wire0 symbol naming #4

Open
bperrybap opened this issue Feb 3, 2023 · 0 comments

Comments

@bperrybap
Copy link

bperrybap commented Feb 3, 2023

The Arduino.cc core platforms have macros in their pins_arduino.h header file to represent the Arduino digital pins used by the Wire library Wire object.
This core platform uses names that are inconsistent with the symbol names defined and used by Arduino.cc in the variant pins_arduino.h header files.

When two i2c buses exist, Arduino.cc uses symbol names Wire and Wire1 to represent the two Wire library objects for the two different i2c buses.
This core does the same.
However there is an inconsistency when it comes to the macro symbol names of the digital pins used for each for the Wire objects

Arduino.cc uses:

  • SDA and PIN_WIRE_SDA are used for the Arduino digital pin number for the Wire object sda pin
  • SCL and PIN_WIRE_SCL are used for the Arduino digital pin number for the Wire object scl pin
  • SDA1 and PIN_WIRE1_SDA are used for the Arduino digital pin number for the Wire1 object sda pin
  • SCL1 and PIN_WIRE1_SCL are used for the Arduino digital pin number for the Wire1 object scl pin

This core uses:

  • PIN_WIRE0_SDA is used for the Arduino digital pin number for the Wire object sda pin
  • PIN_WIRE0_SCL is used for the Arduino digital pin number for the Wire object scl pin
  • PIN_WIRE1_SDA is used for the Arduino digital pin number for the Wire1 object sda pin
  • PIN_WIRE1_SCL is used for the Arduino digital pin number for the Wire1 object scl pin
    And this core does not provide the symbols SDA and SCL

Note that Arduino.cc does not use "WIRE0" in its macro names for the first i2c bus but rather just "WIRE"
This is to provide a consistency between the Wire library object name and the macro symbol name.
i.e. Wire object uses PIN_WIRE_XXX and Wire1 uses PIN_WIRE1_XXX
Also note that ALL Arduino.cc variants provide the symbols SDA and SCL which are the names of the digital pins used by the first Wire object or the only Wire object should there only be a single Wire library object.
SDA and SCL symbols exist for backward compatibility with years of existing code since SDA and SCL existed LONG before PIN_WIRE_SDA and PIN_WIRE_SCL

This core could provide better comparability by following the naming conventions provided by Arduino.cc
Nearly all 3rd party cores have SDA and SCL symbols.
i.e. some code breaks from the missing symbols.

In the case of this core, for compatibility purposes of existing Longan code, it may need to preserver the PIN_WIRE0_SDA and PIN_WIRE0_SCL symbols.
For compatibility with Arduino.cc and other 3rd party cores, and existing code that may use their Wire library symbols, this core should create the SDA, SCL, PIN_WIRE_SDA, and PIN_WIRE_SCL symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant