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

[Core] Adjust PWM hardware audio driver for RP2040 #17723

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented Jul 19, 2022

Description

Enables the usage of the PWM hardware audio driver to be used with the RP2040 MCU.

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

@Jpe230
Copy link
Contributor

Jpe230 commented Jul 19, 2022

Sweet! Just tested this PR on my trusty Adafruit Macropad and can confirm that it is working amazingly -- albeit a little too loud for my taste but nonetheless amazing job as always!

@KarlK90 KarlK90 force-pushed the feature/rp2040-pwm-audio-driver branch from 715fe4d to fc58954 Compare July 27, 2022 11:44
@KarlK90 KarlK90 force-pushed the feature/rp2040-pwm-audio-driver branch from fc58954 to d4af24a Compare September 30, 2022 10:48
@KarlK90 KarlK90 marked this pull request as ready for review September 30, 2022 10:52
@KarlK90 KarlK90 requested review from sigprof and a team September 30, 2022 10:52
@KarlK90 KarlK90 force-pushed the feature/rp2040-pwm-audio-driver branch 2 times, most recently from e1853e5 to 13583d8 Compare October 11, 2022 07:17
Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

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

Doesn't seem to break anything, at least.

@yoichiro
Copy link
Contributor

yoichiro commented Oct 18, 2022

@KarlK90 Thank you for writing this code set to support the audio feature on RP2040 chip! I can't wait merging this pull request because I would like to use the audio feature on the Lunakey Pico keyboard which was designed by me and is using Raspberry Pi Pico. Therefore, I tried testing this code by using my keyboard. The diff I created is the following:

yoichiro@2477058

The circuit design of the Lunakey Pico is the following. The speaker is connected to the GP8 pin.

スクリーンショット 2022-10-18 19 47 16

When compiling the code set with the qmk command, I got the following output including Compiling: platforms/chibios/drivers/audio_pwm_hardware.c. That is, I believe that the built result has an audio feature.

...
Compiling: quantum/process_keycode/process_audio.c                                                  [OK]
Compiling: quantum/process_keycode/process_clicky.c                                                 [OK]
Compiling: quantum/audio/audio.c                                                                    [OK]
Compiling: platforms/chibios/drivers/audio_pwm_hardware.c                                           [OK]
Compiling: quantum/audio/voices.c                                                                   [OK]
Compiling: quantum/audio/luts.c                                                                     [OK]
Compiling: quantum/process_keycode/process_music.c                                                  [OK]
...

I wrote the uf2 file and restarted my keyboard, unfortunately I was not able to hear any sounds.

I have already confirmed that the speaker worked normally with KMK firmware. Did I forget to write something? Could you give me an advice to work the audio feature on my keyboard with your code?

@yoichiro
Copy link
Contributor

@Jpe230 Could you share me your code which you tried the audio feature using your keyboard?

@Jpe230
Copy link
Contributor

Jpe230 commented Oct 21, 2022

@Jpe230 Could you share me your code which you tried the audio feature using your keyboard?

Sure, here it is

@yoichiro
Copy link
Contributor

Finally, I can hear the sound from my keyboard using the code: yoichiro@65a383e The cause is wrong combination of PWMn and Channel. It is necessary to use the PWM4 and the Channel A (= 1) for GP8.

See: https://discordapp.com/channels/440868230475677696/1032861820228227132

I think that the diff of this pull request looks good to me and has comfirm that this code works normally. Thank you for the great contribution!

@drashna drashna requested a review from a team October 25, 2022 05:57
@KarlK90 KarlK90 force-pushed the feature/rp2040-pwm-audio-driver branch from 13583d8 to 36685a8 Compare October 25, 2022 13:32
@drashna drashna requested review from a team and removed request for yoichiro October 26, 2022 19:32
@KarlK90 KarlK90 force-pushed the feature/rp2040-pwm-audio-driver branch from 5178263 to dfa3479 Compare October 27, 2022 17:24
@KarlK90 KarlK90 merged commit 1914570 into qmk:develop Oct 27, 2022
@KarlK90 KarlK90 deleted the feature/rp2040-pwm-audio-driver branch October 27, 2022 17:26
@yoichiro
Copy link
Contributor

@KarlK90 Congrats!

ramonimbao pushed a commit to ramonimbao/qmk_firmware that referenced this pull request Nov 28, 2022
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.

None yet

4 participants