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

spi_master Kinetis support #13098

Merged
merged 2 commits into from
Jun 8, 2021
Merged

spi_master Kinetis support #13098

merged 2 commits into from
Jun 8, 2021

Conversation

fauxpark
Copy link
Member

@fauxpark fauxpark commented Jun 3, 2021

Description

@firetech

Hopefully this works, or is at least close. Haven't tried compiling it yet.

Prerequisite for #13089 to be applied to the Ergodox Infinity.

Types of Changes

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

Issues Fixed or Closed by This PR

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).

@fauxpark fauxpark requested a review from a team June 3, 2021 18:30
@fauxpark
Copy link
Member Author

fauxpark commented Jun 3, 2021

handwired/onekey/teensy_32 compiles with a modified oled keymap and the following changes:

#define HAL_USE_SPI TRUE in halconf.h
#define KINETIS_SPI_USE_SPI0 TRUE in mcuconf.h

And config.h:

#define ST7565_A0_PIN  C7
#define ST7565_RST_PIN C8
#define ST7565_SS_PIN  C4

#define ST7565_SPI_CLK_DIVISOR 32

#define SPI_DRIVER   SPID1
#define SPI_SCK_PIN  C5
#define SPI_MISO_PIN D3
#define SPI_MOSI_PIN C6

#define SPI_SCK_PAL_MODE  PAL_MODE_ALTERNATIVE_2
#define SPI_MISO_PAL_MODE PAL_MODE_ALTERNATIVE_2
#define SPI_MOSI_PAL_MODE PAL_MODE_ALTERNATIVE_2

Note that the MISO config is currently required, but shouldn't be, as some SPI devices (like the ST7565) only have a MOSI line. So I have set it to D3, which can also be SPI0 MISO, but on the Ergodox Infinity this is used as one of the UART lines.

@firetech
Copy link
Contributor

firetech commented Jun 3, 2021

Note that the MISO config is currently required, but shouldn't be, as some SPI devices (like the ST7565) only have a MOSI line. So I have set it to D3, which can also be SPI0 MISO, but on the Ergodox Infinity this is used as one of the UART lines.

Yeah... I noticed. :P As far as I could see, the pin config is only used for setting the pin direction etc, not for setting up SPI, but I may be mistaken?

@firetech
Copy link
Contributor

firetech commented Jun 3, 2021

image

So this seems to work 👍

Edit: Code here.

@firetech firetech mentioned this pull request Jun 3, 2021
14 tasks
@fauxpark fauxpark marked this pull request as ready for review June 4, 2021 17:29
@fauxpark fauxpark merged commit 17d0fad into qmk:develop Jun 8, 2021
@fauxpark fauxpark deleted the spi-kinetis branch June 8, 2021 09:54
mechlovin pushed a commit to mechlovin/qmk_firmware that referenced this pull request Jul 30, 2021
mechlovin pushed a commit to mechlovin/qmk_firmware that referenced this pull request Jul 30, 2021
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
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.

3 participants