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

WS2812 ARM Driver (rgblight+rgb_matrix) #6675

Closed
wants to merge 14 commits into from
Closed

WS2812 ARM Driver (rgblight+rgb_matrix) #6675

wants to merge 14 commits into from

Conversation

kratsyn
Copy link

@kratsyn kratsyn commented Sep 5, 2019

I know there is an existing PR for RGB support for arm however there has not been much movement in those PRs and this implementation differs enough to warrant new discussion.

Description

This implementation uses a single timer and dma channel to avoid affecting an entire gpio port and reduces the chances of impacting other feature usage. One caveat to note is that we are forced to reduce the global system clock to avoid having to introduce a divisor to timer_read(). There are no system level performance impacts for this change as it will only affect the virtual timer implementation within chibi.

This PR has been tested against the following boards: planck rev6, preonic rev3, proton_c, f103 bluepill, f103 blackpill, and robodyn black pill (f303).

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

  • Unknown

Checklist

  • My code follows the code style of this project.
  • 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).

kratsyn and others added 12 commits September 3, 2019 02:04
…, tickless not supported on ST frquencies lower than 10khz. The alternate for this would be to add a divisor to timer_read() to account for the increased timer resolution. (lots of impacts to userland and custom builds)
brought back matrix.c and removed dipswitch specific functionality that is now covered by the quantum 'driver'.
This reverts commit 8bb1c26.

Issue actually introduced by problem with merge.
@drashna drashna requested a review from a team September 6, 2019 03:46
@drashna
Copy link
Member

drashna commented Sep 6, 2019

While the approach may not be identical, it's very similar.

#4670, #6301, #6516 all implement WS2812 support for ARM.

This is NOT a dig at you, this is mostly for notes and reference.

@kratsyn
Copy link
Author

kratsyn commented Sep 6, 2019 via email

@drashna
Copy link
Member

drashna commented Sep 6, 2019

I was not aware of #4670. It would be nice to have both options available.

Absolutely! However, that PR is (in theory) waiting on an update to ChibiOS (the main ARM HAL that we use).

@nooges
Copy link
Member

nooges commented Sep 8, 2019

There's quite a bit of mixing of tabs and spaces in the PR.

@kratsyn
Copy link
Author

kratsyn commented Sep 8, 2019 via email

@kratsyn
Copy link
Author

kratsyn commented Sep 22, 2019

I would like some input or normalizing the configuration on this pr. I'm not really a fan of WS2812 specific vars but i also do not want to make any choices in a vacuum.

@hsgw
Copy link
Contributor

hsgw commented Sep 22, 2019

@kratsyn
Hi, I tried this code on stm32f072 board.
I found wrong setting In ws2812.c L41,

#define WS2812_PWM_PERIOD                   (WS2812_PWM_FREQUENCY / 80000)

This should divide by 800000.
Could you test this?

@zvecr
Copy link
Member

zvecr commented Sep 22, 2019

This PR has been tested against the following boards: planck rev6, preonic rev3, proton_c, f103 bluepill, f103 blackpill, and robodyn black pill (f303).

@kratsyn are you sure this has been tested on f103? My understanding is PAL_MODE_ALTERNATE() does not exist on that platform.

@kratsyn
Copy link
Author

kratsyn commented Sep 22, 2019 via email

@kratsyn
Copy link
Author

kratsyn commented Oct 6, 2019

I've not spaced on this, dealing with family drama and will resume when i have the time the spare.


/**
* @brief System tick frequency.
* @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
# define CH_CFG_ST_FREQUENCY 100000
# define CH_CFG_ST_FREQUENCY 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

use space instead of tab

@@ -58,7 +58,7 @@
* The value one is not valid, timeouts are rounded up to
* this value.
*/
# define CH_CFG_ST_TIMEDELTA 2
# define CH_CFG_ST_TIMEDELTA 0
Copy link
Contributor

Choose a reason for hiding this comment

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

use space instead of tab

Copy link
Member

Choose a reason for hiding this comment

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

Ideally instead this should be run through clang-format instead

#define RGB_DI_PIN A1
#ifdef RGB_DI_PIN
#define RGBLED_NUM 9
#define DRIVER_LED_TOTAL RGBLED_NUM
Copy link
Contributor

Choose a reason for hiding this comment

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

use space instead of tab

#define RGB_DI_PIN A1
#ifdef RGB_DI_PIN
#define RGBLED_NUM 9
#define DRIVER_LED_TOTAL RGBLED_NUM
Copy link
Contributor

Choose a reason for hiding this comment

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

use space instead of tab

@@ -206,6 +209,9 @@ int main(void) {
#endif

keyboard_task();
#if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE)
#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE)

@zvecr
Copy link
Member

zvecr commented Nov 7, 2019

Now #7183 and #7173 have dropped, we now have a new entrypoint for a pwm based implementation. When fixing the merge conflicts, could you please target drivers/arm/ws2812_pwm.c instead 😃

@stale
Copy link

stale bot commented Dec 9, 2019

Thank you for your contribution!
This pull request has been automatically closed because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready.

@stale stale bot closed this Dec 9, 2019
@zvecr zvecr mentioned this pull request Jan 19, 2020
13 tasks
@kratsyn kratsyn deleted the ws2812_arm branch April 2, 2020 09:53
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.

6 participants