Skip to content

Conversation

jaenrig-ifx
Copy link
Member

By creating this pull request you agree to the terms in CONTRIBUTING.md.
https://github.com/Infineon/.github/blob/master/CONTRIBUTING.md
--- DO NOT DELETE ANYTHING ABOVE THIS LINE ---

CONTRIBUTING.md also tells you what to expect in the PR process.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the Arduino variant pin definitions to use plain numeric IDs and adjusts TwoWire to accept those pin IDs via its constructor.

  • Switch I²C pin macros from HAL-specific names to numeric IDs and expose SDA/SCL constants
  • Change TwoWire constructor and members from cyhal_gpio_t to pin_size_t
  • Update Wire.cpp to map pin_size_t values through mapping_gpio_pin when calling cyhal_i2c_init

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
variants/CY8CKIT-062S2-AI/pins_arduino.h Redefine I²C, SPI, and ADC pins as numeric IDs and add SDA, SCL, A0, A1 aliases
libraries/Wire/src/Wire.h Update TwoWire constructor signature and member types to use pin_size_t
libraries/Wire/src/Wire.cpp Use mapping_gpio_pin lookup for SDA/SCL in cyhal_i2c_init
Comments suppressed due to low confidence (3)

variants/CY8CKIT-062S2-AI/pins_arduino.h:44

  • [nitpick] Add a comment explaining which physical port this numeric ID (9) corresponds to, e.g. // P9_1 or similar, to aid future maintainers.
#define I2C1_SDA_PIN    9

libraries/Wire/src/Wire.cpp:14

  • [nitpick] Consider adding unit tests for this constructor to verify that passing different pin_size_t values initializes sda_pin/scl_pin as expected and triggers the correct HAL mapping.
TwoWire::TwoWire(pin_size_t sda, pin_size_t scl) : sda_pin(sda), scl_pin(scl) {

libraries/Wire/src/Wire.cpp:33

  • Ensure that mapping_gpio_pin is declared and populated before use. If this lookup array lives in another translation unit, include its header or declare it extern to avoid unresolved symbol errors.
w_status = cyhal_i2c_init(&i2c_obj, mapping_gpio_pin[sda_pin], mapping_gpio_pin[scl_pin], NULL);

@jaenrig-ifx jaenrig-ifx merged commit 90cea9a into main Jun 5, 2025
12 checks passed
@jaenrig-ifx jaenrig-ifx deleted the wire-pins-update branch June 5, 2025 07:07
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

Successfully merging this pull request may close these issues.

3 participants