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

handwired/onekey/blackpill_f401: Fix I2C pin config mismatch #10322

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

sigprof
Copy link
Contributor

@sigprof sigprof commented Sep 15, 2020

Description

By default the i2c_master driver for ChibiOS uses the B6 pin for I2C1_SCL and the B7 pin for I2C1_SDA. However, the ChibiOS board file used for the F401 Blackpill board (ST_STM32F401C_DISCOVERY) configures B6 as I2C1_SCL and B9 as I2C1_SDA, and if that configuration is left unchanged, enabling the i2c_master driver results in having two pins (B7 and B9) configured as I2C1_SDA at the same time, which does not work properly (experimental results show that the B9 pin still works as I2C1_SDA in that case, and the B7 pin does not work).

Configure the B9 pin as an input with pull-up in board_init(), so that the B7 pin can be configured as I2C1_SDA by the I2C driver.

Tested on a Blackpill board marked “WeAct V3.0” with STM32F401CCU6 and several OLED displays (with a keymap for OLED testing which will go in a separate PR).

Note that handwired/onekey/blackpill_f411 does not need a similar change, because its ChibiOS setup is based on the ST_NUCLEO64_F411RE board definition, which does not configure any pins for I2C1-related alternate functions.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

By default the `i2c_master` driver for ChibiOS uses the B6 pin for
`I2C1_SCL` and the B7 pin for `I2C1_SDA`.  However, the ChibiOS board
file used for the F401 Blackpill board (`ST_STM32F401C_DISCOVERY`)
configures B6 as `I2C1_SCL` and B9 as `I2C1_SDA`, and if that
configuration is left unchanged, enabling the `i2c_master` driver
results in having two pins (B7 and B9) configured as `I2C1_SDA` at the
same time, which does not work properly (experimental results show that
the B9 pin still works as `I2C1_SDA` in that case, and the B7 pin does
not work).

Configure the B9 pin as an input with pull-up in `board_init()`, so that
the B7 pin can be configured as `I2C1_SDA` by the I2C driver.
@sigprof
Copy link
Contributor Author

sigprof commented Sep 19, 2020

The same unrelated keymaps as in #10320 also failed here, in addition to the backlight keymap which is fixed by #10320.

@drashna drashna requested a review from a team September 20, 2020 01:44
@fauxpark fauxpark requested a review from zvecr September 20, 2020 02:41
@stale
Copy link

stale bot commented Nov 5, 2020

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@tzarc tzarc merged commit 0dee334 into qmk:master Nov 12, 2020
@sigprof sigprof deleted the fix-onekey-blackpill-f401-i2c branch January 8, 2021 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants