-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/ws281x: Add gpio_ll and timer based driver #19891
Merged
+419
−3
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abf95d1
cpu/nrf5x: Tolerate NULL callback in timers
chrysn d32c32f
boards/nrf52: Defined TIMER_x_MAX_VALUE
chrysn 02285fd
drivers/periph: Add timer_poll feature and timer_poll_channel function
chrysn d86405c
drivers/ws281x: Add timer and gpio_ll based driver
chrysn 7b80348
drivers/ws281x: Fix Kconfig
MrKevinWeiss 0d31432
boards/nrf51: Defined TIMER_x_MAX_VALUE
MrKevinWeiss fb5ebea
boards/common/e104-bt50xxa-tb: Override WS281X_TIMER_*
MrKevinWeiss 6a0b1c5
boards/nrf9160dk: Override WS281X_TIMER_*
MrKevinWeiss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2015 Jan Wagner <[email protected]> | ||
* 2015-2016 Freie Universität Berlin | ||
* 2019 Inria | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup cpu_nrf5x_common | ||
* @ingroup drivers_periph_timer | ||
* @{ | ||
* | ||
* @file | ||
* @brief CPU specific part of the timer API | ||
* | ||
* @author Christian Amsüss <[email protected]> | ||
*/ | ||
|
||
#ifndef TIMER_ARCH_H | ||
#define TIMER_ARCH_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef DOXYGEN /* hide implementation specific details from Doxygen */ | ||
|
||
static inline bool timer_poll_channel(tim_t tim, int channel) | ||
{ | ||
return timer_config[tim].dev->EVENTS_COMPARE[channel]; | ||
} | ||
|
||
#endif /* DOXYGEN */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* TIMER_ARCH_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2023 HAW Hamburg | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
# | ||
|
||
menuconfig MODULE_PERIPH_GPIO_LL | ||
bool "Low-level GPIO peripheral driver" | ||
depends on HAS_PERIPH_GPIO_LL | ||
|
||
if MODULE_PERIPH_GPIO_LL | ||
|
||
config MODULE_PERIPH_GPIO_LL_IRQ_UNMASK | ||
bool "Unmask GPIO peripheral interrupts" | ||
default y | ||
depends on HAS_PERIPH_GPIO_LL_IRQ_UNMASK | ||
help | ||
Enables GPIO peripheral unmasking interrupts without | ||
clearing pending IRQs that came in while masked. | ||
|
||
endif # MODULE_PERIPH_GPIO_LL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,7 +31,7 @@ | |||||
* @{ | ||||||
*/ | ||||||
#ifndef WS281X_PARAM_PIN | ||||||
#define WS281X_PARAM_PIN (GPIO_PIN(0, 0)) /**< GPIO pin connected to the data pin of the first LED */ | ||||||
#endif | ||||||
#ifndef WS281X_PARAM_NUMOF | ||||||
#define WS281X_PARAM_NUMOF (8U) /**< Number of LEDs chained */ | ||||||
|
@@ -64,6 +64,47 @@ | |||||
WS281X_PARAMS | ||||||
}; | ||||||
|
||||||
/** @brief Timer used for WS281x (by the timer_gpio_ll implementation) | ||||||
* | ||||||
* A single timer is configured for any number of WS281x strands, so this does | ||||||
* not need to be part of params. | ||||||
* | ||||||
* It is required that the timer has at least 2 channels. (Future versions may | ||||||
* require a 3rd channel). | ||||||
* | ||||||
* It is required that the timer's MAX_VALUE is 2^n-1, which is a trivial but | ||||||
* not explicitly stated case. | ||||||
* | ||||||
* This timer is configured at WS281x initialization time, and kept stopped | ||||||
* outside of transmissions. | ||||||
* | ||||||
* The default value of 2 is chosen because the only platform on which the | ||||||
* module is usable is nRF5x, where TIMER_DEV(1) is in use by the radio module. | ||||||
* It is strongly advised to explicitly set this timer to a known free timer, | ||||||
* as the default may change without notice. | ||||||
* */ | ||||||
#if !defined(WS281X_TIMER_DEV) || defined(DOXYGEN) | ||||||
#define WS281X_TIMER_DEV TIMER_DEV(2) | ||||||
MrKevinWeiss marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
#endif | ||||||
|
||||||
/** @brief Maximum value of the timer used for WS281x (by the timer_gpio_ll implementation) | ||||||
* | ||||||
* This macro needs to be defined to the `TIMER_x_MAX_VALUE` corresponding to | ||||||
* the `TIMER_DEV(x)` in @ref WS281X_TIMER_DEV. | ||||||
* */ | ||||||
#ifndef WS281X_TIMER_MAX_VALUE | ||||||
#define WS281X_TIMER_MAX_VALUE TIMER_2_MAX_VALUE | ||||||
MrKevinWeiss marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
#endif | ||||||
|
||||||
/** @brief Frequency for the timer used for WS281x (by the timer_gpio_ll implementation) | ||||||
* | ||||||
* This should be set to a frequency that is a close multiple of 3MHz, | ||||||
* depending on the precise low and high times. A value of 16MHz works well. | ||||||
* */ | ||||||
#ifndef WS281X_TIMER_FREQ | ||||||
#define WS281X_TIMER_FREQ 16000000 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
reads a bit nicer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like using the MHZ macro causes some conflicts with the ESP so I think it best to just leave it out. |
||||||
#endif | ||||||
|
||||||
#ifdef __cplusplus | ||||||
} | ||||||
#endif | ||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always use
TIMER_DEV(1)
forWS281X_TIMER_DEV
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm reading that I wonder if there will be a conflict with the e104-bt50xxa-tb boards. But I guess that is only if both modules are used at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't use the radio module, so it can select
TIMER_DEV(1)
- and we don't have to clutter the board definitions withWS281X_TIMER_DEV
when there is nows281x
LED connected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it is better try not to conflict with a known value. If we add a radio and ws281x test it would fail. This is maybe a decision best left to @chrysn though...