Skip to content

drivers/leds: Add support for KTD2052 #16217

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

stbenn
Copy link
Contributor

@stbenn stbenn commented Apr 15, 2025

This commit adds support for the KTD2052 LED driver chip.

Summary

Driver implementation necessary to interface with KTD2052 LED driver chips.

Originally authored by @ArrestedLightning : https://github.com/ArrestedLightning/nuttx/tree/ktd2052

Impact

Adds Kconfig option to LED driver configuration. Does not change compatibility of existing drivers.

Testing

This driver was tested on a custom KTD2052 driver board.

This commit adds support for the KTD2052 LED driver chip.

Signed-off-by: Tyler Bennett <[email protected]>
@github-actions github-actions bot added Area: Drivers Drivers issues Size: L The size of the change in this PR is large labels Apr 15, 2025
@nuttxpr
Copy link

nuttxpr commented Apr 15, 2025

[Experimental Bot, please feedback here]

No, this PR description does not fully meet the NuttX requirements. Here's why and how to fix it:

  • Summary: While it states what was changed, it lacks crucial details:

    • Why? What problem does this solve? Why is this driver needed? (e.g., "Enables control of LEDs connected to a KTD2052 driver, allowing for..." or "Adds support for a commonly used LED driver, expanding hardware compatibility.")
    • How? "Driver implementation" is too vague. Briefly explain the mechanism. (e.g., "Uses I2C to communicate with the KTD2052, setting brightness levels through registers...")
    • Issues: Are there any related NuttX or NuttX Apps issues this addresses? Even if not, explicitly stating "N/A" is helpful.
  • Impact: While some impacts are addressed, others are missing or incomplete:

    • New Feature: Explicitly say "YES".
    • User Impact: Even if the answer is NO, briefly explain why. (e.g., "NO, this adds a new driver and does not affect existing LED functionality.")
    • Build Impact: YES - You added a Kconfig option. Describe how the build process is affected. (e.g., "YES, a new Kconfig option CONFIG_LED_KTD2052 enables the driver.")
    • Hardware Impact: Be specific about which architectures and boards are supported. (e.g., "YES, supports the KTD2052 on [architecture] platforms, tested on a custom board.")
    • Documentation: If no documentation was added, state that and why. (e.g., "NO, documentation will be added in a follow-up commit.") or "YES, a README.md file describing the driver usage has been added."
    • Security, Compatibility: Explicitly state "NO" (if applicable) with a brief explanation. (e.g., "NO, this driver does not introduce any new security concerns." / "NO, this is a new driver and maintains backward compatibility.")
  • Testing: Severely lacking detail.

    • Build Host: Provide specifics. (e.g., "Linux Ubuntu 22.04, x86_64, GCC 11.2")
    • Target: Provide specific architecture, board, and configuration. (e.g., "ARM Cortex-M4, Custom KTD2052 board, stm32f4discovery:nsh config")
    • Logs: The "before" logs might not be relevant for a new driver, but "after" logs demonstrating the driver's functionality are essential. Include examples showing successful LED control. If the logs are extensive, consider attaching a file instead of pasting them directly.

Example of Improved PR Description:

This commit adds support for the KTD2052 LED driver chip, expanding hardware compatibility for LED control within NuttX.

## Summary

This change adds a driver for the KTD2052 LED driver chip, allowing users to control LEDs connected to this chip. The driver communicates with the KTD2052 via I2C, setting brightness levels through specific registers. This addresses the need to support this commonly used LED driver chip.

Related NuttX Issue: N/A
Related NuttX Apps Issue/PR: N/A

## Impact

* New feature added? YES
* Impact on user: NO, this adds a new driver and does not affect existing LED functionality. Users wishing to use this new driver will need to configure their .config file appropriately.
* Impact on build: YES, a new Kconfig option `CONFIG_LED_KTD2052` enables the driver.
* Impact on hardware: YES, supports the KTD2052 on ARM platforms, tested on a custom KTD2052 board.
* Impact on documentation: NO, documentation will be added in a follow-up commit.
* Impact on security: NO, this driver does not introduce any new security concerns.
* Impact on compatibility: NO, this is a new driver and maintains backward compatibility.

## Testing

I confirm that changes are verified on a local setup and work as intended:

* Build Host(s): Linux Ubuntu 22.04, x86_64, GCC 11.2
* Target(s): ARM Cortex-M4, Custom KTD2052 board, `stm32f4discovery:nsh` config (adapted for the custom board)

Testing logs after change:

nsh> ktd2052_test # Example test application
Initializing KTD2052... Success!
Setting LED 1 to 50% brightness... Success!
Setting LED 2 to 100% brightness... Success!
...

By providing more detail and addressing all the required points, your PR will be much easier to review and merge.

@acassis
Copy link
Contributor

acassis commented Apr 15, 2025

@stbenn please include a Documentation to https://nuttx.apache.org/docs/latest/components/drivers/character/leds/index.html and an app testing application, this way users could use it without facing issues

****************************************************************************/

/* Set RGB value for a single module */
#define KTDIOSETRGB _PWMIOC(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use ioctl number from include/nuttx/leds/userled.h

@stbenn
Copy link
Contributor Author

stbenn commented Apr 15, 2025

@acassis I can add those, but it may be a little bit until I get around to it. If you would prefer to wait on this PR until those are implemented, that is understandable.

@acassis
Copy link
Contributor

acassis commented Apr 15, 2025

@stbenn we can merge it, but I think it is better wait for your commit with Documentation and apps example, it avoids we losing track of it. I will move this PR to draft, ok?

@stbenn
Copy link
Contributor Author

stbenn commented Apr 15, 2025

@acassis, sounds good to me 👍

@acassis acassis marked this pull request as draft April 15, 2025 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Drivers Drivers issues Size: L The size of the change in this PR is large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants