-
Notifications
You must be signed in to change notification settings - Fork 8k
drivers: led: is31fl3197 Arduino GIGA #96821
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
base: main
Are you sure you want to change the base?
Conversation
fd309e3
to
b69ff55
Compare
@pillo79 @facchinm and all - As far as I can tell, the basic parts of this PR are working. That is I can set the RGB led on the I am going to mark this as ready to review, however I know there are issues with twister, as it appears like the GIGA board Currently I have the sample setup to work with just specifying board as arduino_giga_r1//m7, as the shield currently Also should mention: that the code is hard coded similarly to the is31fl3194 code in that it assumes RED/GREEN/BLUE But before I go much further, it would help to know if this is a direction that Arduino wishes to go. |
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.
Hi @KurtE,
Thanks for this PR !
Can it be merged with the driver is31fl3194 ? into a is31fl319x driver ?
I didn't check but I am asking because in Linux the leds-is31fl319x driver supports the IS31FL319{0,1,3,6,9} models...
Good question, both of them have stuff in common, and I started off that way, but then found many of the registers @pillo79 As the one who originally did the 94 version, What do you think? |
Thanks Kurt! I also think this is worth merging with the existing driver, there's a lot of common code, and the few exceptions look like they can be specifically handled. Take a look at the end of Oh, and re/ Arduino attitude, upstream is the way to go so 👍 on that! By all means make it part of the Giga Display shield, that way it will be automatically available everywhere you use that and not only in the test code 🙂 |
@KurtE Lines 391 to 413 in 8843fd9
|
Can do. At least the basics, that the display shield uses. Don't have any other things to try more advanced stuff on. My first thoughts were to hack it and drive everything off of Product ID. I believe the 94 has a fixed ID of 0xce
I agree, that in the Zephyr world, having it all here under the shield is the way to go and not have to put the DT info in the Some questions on this, should I then remove the GIGA from the integration section of the sample.yaml? As I don't believe Include Portenta H7? I have a overlay I experimented with yesterday, that had the LEDS working on an H7 plugged into a MID Main Secondary Question: Currently with ArduinoCore-zephyr if I wish to build for a GIGA, it includes all of the Giga Shield stuff, regardless if I actually have a shield. With the MBED version, only the basics for the display are included with a board release in the library Arduino_H7_video, The I decided to try first with the LEDS as it is pretty self contained and not very large. Our zephyr version of Arduino library for this:
Longer term question: how much of the stuff in the ArduinoCore-zephyr overlays/config files maybe should be |
Sorry, another quick question: Is there any Boards other than the Nicla Sense ME that uses is31fl3194? |
8711ce0
to
4501da8
Compare
Pushed up first part of renaming. Note I did not yet do the KConfig... file was having issues with it not building Now for Part 2:
I am assuming from this conversation along this lines, For example with 97 with 4 channels, I should be able to:
Assumption of the above: led_0 uses channels 0-2 and led_1 uses channel 3. If I understand correctly:
If I call it like: And if implemented, should also be able to do: To set the last LED (WHITE) Is this reasonably correct? |
fc1363c
to
70fea85
Compare
@pillo79 @mjs513 @simonguinot - I split this up into multiple commits. I have the GIGA display shield working with it. |
9fc92b1
to
6589b00
Compare
In preparation to allow this driver to support more than one IS31FL319x object such as ...97, rename the source file and the functions to make them more generic. I also changed the enumeration/creation of object to generate the right names for the current 94 objects Still have not renamed the Kconfig file yet as was having issues with it not building... Did not load the .c file Signed-off-by: Kurt Eckhardt <[email protected]> Update README.rst
more refactoring, don't use the 94 registers everywhere. Introduce structure, with registers and fixed values, and use it. Signed-off-by: Kurt Eckhardt <[email protected]>
25ecad4
to
102b7f3
Compare
how? |
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.
Quite a better shape, thanks for the effort! 👍
Note that commit ' drivers: led: is31fl319x - redo color to channel ' introduces changes to the sample README.rst
that are later removed and then re-added in the following commits. 👀 Ideally, at that stage there should be no mention of other chips yet.
# zephyr-keep-sorted-start | ||
zephyr_library_sources_ifdef(CONFIG_HT16K33 ht16k33.c) | ||
zephyr_library_sources_ifdef(CONFIG_IS31FL3194 is31fl3194.c) | ||
zephyr_library_sources_ifdef(CONFIG_IS31FL3194 is31fl319x.c) |
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.
Missed the Kconfig rename:CONFIG_IS31FL3194
-> CONFIG_IS31FL319X
in the generalization commit. Should edit CMakeLists, Kconfig and Kconfig.is31fl314x (renamed from '94).
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.
Thanks,
When I was refactoring, I tried renaming the CONFIG file as mentioned, but at that time it would not build,
I got some strange error about missing some node or the like, when I did not rename the config file it worked.
Maybe something else was going wrong.
I will try again.
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.
@pillo79 - Tried again and I currently get a build error on the sample sketch:
.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c D:/zephyrproject/zephyr/samples/drivers/led/is31fl319x/src/main.c
←[01m←[KD:/zephyrproject/zephyr/samples/drivers/led/is31fl319x/src/main.c:←[m←[K In function '←[01m←[Kmain←[m←[K':
←[01m←[KD:/zephyrproject/zephyr/samples/drivers/led/is31fl319x/src/main.c:58:30:←[m←[K ←[01;31m←[Kerror: ←[m←[K'←[01m←[Kled_dev←[m←[K' undeclared (first use in this function)
58 | if (!device_is_ready(←[01;31m←[Kled_dev←[m←[K)) {
| ←[01;31m←[K^~~~~~~←[m←[K
←[01m←[KD:/zephyrproject/zephyr/samples/drivers/led/is31fl319x/src/main.c:58:30:←[m←[K ←[01;36m←[Knote: ←[m←[Keach undeclared identifier is reported only once for each function it appears in
[
My updated Kconfig.is31fl319x
# Copyright (c) 2024 Arduino SA
# SPDX-License-Identifier: Apache-2.0
config IS31FL319X
bool "IS31FL319X LED driver"
default y
depends on DT_HAS_ISSI_IS31FL3194_ENABLED || DT_HAS_ISSI_IS31FL3197_ENABLED
select I2C
help
Enable LED driver for Lumissil Microsystems (a division of ISSI)
IS31FL3194. This chip supports one RGB LED or 3 independent LEDs.
IS31FL3197. This chip supports 4 LEDs.
The problem is that the defines like: CONFIG_IS31FL3194 and CONFIG_IS31FL3197 are not longer defined.
Instead:
#define CONFIG_IS31FL319X
Thoughts?
EDIT: Could probably check using ones like:
#define CONFIG_DT_HAS_ISSI_IS31FL3194_ENABLED 1
EDIT2:
changed the main.c to check these instead and now fails with:
c && C:\WINDOWS\system32\cmd.exe /C "cd /D D:\zephyrproject\zephyr\samples\drivers\led\is31fl319x\build\zephyr && "C:\Program Files\CMake\bin\cmake.exe" -E true""
d:/users/kurte/downloads/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj):D:/zephyrproject/zephyr/samples/drivers/led/is31fl319x/src/main.c:37: undefined reference to `__device_dts_ord_86'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
←[91mFATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'D:\zephyrproject\zephyr\samples\drivers\led\is31fl319x\build'
←
|
||
#define IS31FL3194_CHANNEL_COUNT 3 | ||
|
||
#ifdef CONFIG_IS31FL3194 |
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.
Nit: you could wrap the #defines above as well, to make sure you catch any stray uses. Same thing for 97 below.
LOG_ERR("%s: invalid product ID 0x%02x (expected 0x%02x)", dev->name, prod_id, | ||
regs->prod_id_val); | ||
return -ENODEV; | ||
if (regs->prod_id_val != 0xff) { |
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.
Do not use magic numbers in code. Please consider the solution of keeping track of the expected chip in the static config and testing for that instead.
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.
Can do, I sort of resisted that earlier as have not looked through other chips in same family to know if these
differences are unique or similar for others as well. The other way I thought about doing it was:
add new item to config structure, like: uint8_t features and have either defines or enum with bit flags.
Like:
#define FEATURE_ID_IS_ADDR 0x01
#define FEATURE_SET_CURRENT 0x02
And have the enumerator at end for each chip pass in the appropriate flags.
Worth doing? Or wait until (if) other chips are supported?
any board where the devicetree has an I2C device node with compatible | ||
:dtcompatible:`issi,is31fl3194` enabled, along with the relevant bus | ||
controller node also being enabled. | ||
:dtcompatible:`issi,is31fl3194` or :dtcompatible:`issi,is31fl319` with the |
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.
typo: is31fl3197
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.
Instead of adding a 3197 file you can patch the Kconfig 3194 (that should be 319x after the generalization comit) to have a
depends on DT_HAS_ISSI_IS31FL3194_ENABLED || DT_HAS_ISSI_IS31FL3197_ENABLED
Removed the driver knowing anything about what color each channel is. When you output to an LED with a buffer it simply writes the channels out with buffer. Also removed the assumptions that the leds are either a) RGB or b) 3 channels and instead use them the way they are defined. That is for example if we have 4 channels, we could define an LED with just one color in it and we could define another with three. The user can define 4 leds each with color yellow. For each LED it counts how many buffers were used by previous LEDs and starts there and outputs N channels. Decided it looked cleaner to use helper function write channels, so implemented it and added it to the call table. Updated example sketch: It manually computes which channel maps to red, green and blue and then uses those indexes to map the table of colors to the right channels. Signed-off-by: Kurt Eckhardt <[email protected]> Update main.c
819bc45
to
6df2cd0
Compare
Add the registers and the like to the .c file plus add a Kconf file plus bindings. Updated example sketch: to also check for is31fl3197 boards Signed-off-by: Kurt Eckhardt <[email protected]>
Added is31fl3197@50 to overlay Also updated GIGA board yaml file to say that it supports i2c And updated sample sketch to mention it Signed-off-by: Kurt Eckhardt <[email protected]>
Fix documents run Signed-off-by: Kurt Eckhardt <[email protected]>
6df2cd0
to
7d93a96
Compare
|
Start of support for the is31fl3197 LED controller used by Arduino in the Arduino Giga Display shield.
So far there is just enough implemented that allows me to control the LEDS, to the same extent as our version of the library we implemented that runs on ArduinoCore-zephyr
@pillo79 @facchinm - I am not sure what direction Arduino is heading with functionality such as this.
Add support to zephyr? Or do it external as libraries within ArduinoCore-zephyr (either integrated within the zephyr builds or external libraries), This is also true, about for some of the other
features of the display, like the display itself. Should there be samples setup to actually
display something on the display, preferably without the need for LVGL.
So far this only has the minimal support for setting up to 4 LEDS (the GIGA only uses 3).
Added sample sketch that runs on the GIGA. Currently it works with just
west build -p -b arduino_giga_r1//m7
I put the device tree into sample/boards. Potentially it should be defined as part of the
overlay in the arduino_giga_display_shield, in which case the west build should
define the shield as part of the command.
Let me know know what you think.
Thanks