arduino / arduino/ArduinoCore-samd
Check to see if TwoWire has already begun
- Dominant language
- C
- Stars
- 502
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
Looking at https://github.com/arduino/ArduinoCore-samd/blob/master/libraries/Wire/Wire.cpp#L37
It seems as though calling `begin` resets the bus and set the `pinPeripheral` configuration.
Instead, we should somehow track to see if `begin` has already been called and just nop on the additional `begin` calls.
This is necessary as many libraries, even official ones [like this one](https://github.com/arduino-libraries/Arduino_LSM6DS3/blob/master/src/LSM6DS3.cpp#L76) call `begin` in them. If one configures the ports differently as described [here](https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-wire), calling `begin` a second time in the library overwrites the configuration and renders the bus useless.
This was discussed in this issue here https://github.com/adafruit/Adafruit_BNO055/issues/84
Contributor guide
No contributing guide indexed for this repository
Research direction
Read libraries/Wire/Wire.cpp around line 37 and compare it with the linked LSM6DS3 begin call and the custom SERCOM configuration described in the linked guide. Verify the behavior when TwoWire.begin is called more than once: later calls should not reset the bus or overwrite pinPeripheral configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100