-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat(drivers): add driver for MAX17048 fuel gauge #1301
feat(drivers): add driver for MAX17048 fuel gauge #1301
Conversation
5e4bffe
to
c03ef6b
Compare
I'll incorporate the changes noted in the review for #1295 in the near future |
struct max17048_drv_data *const drv_data = dev->data; | ||
uint16_t dev_addr = ((struct max17048_config *)dev->config)->device_addr; | ||
|
||
uint16_t data = 0; |
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.
some people on the discord have noted that this code doesn't work very well, and should be changed to uint8_t[2]
instead. will fix soon.
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.
One other item needs fixing.
d439287
to
afc7187
Compare
Addressed the comments, including the bogus 16-bit register read/write routines -- they should be actually correct now. |
fixed formatting |
Any news on this one? Did I make a mistake in my implementation, or is the driver in its current state softbricking other boards too? Couldn't get my Osprey to work with the current state anymore. Can't really debug as it doesn't even enumerate over USB. Not sure if something about config syntax changed, or the driver itself has a problem. EDIT: Just tried off the latest master branch again, no chance :/ |
sorry, i haven't had much time to look at this recentl >< |
Haha, I just had it open when your answer popped up few seconds later. Sorry, I didn't want to rush you - you're doing this in your spare time and I can fully understand not spending countless hours on it! Just thought maybe you had a local dev branch that hadn't been pushed or something! I rolled back to the older version, works fine again for me. |
I've been trying to find out just what was wrong with the driver for me and ended up debugging a few things. This branch had the latest driver of yours added (I added files manually since I didn't know how to properly cherry-pic a commit). https://github.com/ebastler/zmk/tree/MAX17048_tempfix I then changed everything that was needed to get it to compile with the latest zephyr 3.2 based ZMK (not much, a few includes needed This was as far as I could get by just testing code, to write a proper fix that's not just "I comment the stuff out that breaks my board" I lack C knowledge. I do not know why the semaphores work flawlessly in other functions, but break Maybe my narrowing down helps you find the actual cause of the issues, and saves you some work. For now I'm happy I managed a workaround for my boards. |
I know what's the problem — I'm using the semaphore before I initialise it, in the driver init function. Silly me 🤡 I'll fix up this PR this week. Thanks for doing the investigation legwork! |
Oh, I did not realize it was initialized after those two functions are/may be called! Glad I could help, thank you very much for your work on this driver. It's awesome. |
412d075
to
1275419
Compare
1275419
to
c6f1429
Compare
I've updated the code so it compiles with the latest ZMK/Zephyr. Appreciate if this could be looked at again soon! |
Thanks for the update! I'll be away from home for another 1-2 weeks, once I return I will try the updated version on hardware. I have 2 different boards with this chip to test it. |
Tested your latest changes, still works as intended on my hardware. |
Zephyr 3.4 added its own MAX17048 driver https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/fuel_gauge/max17048. I would suggest incorporating that if possible, rather than maintaining a separate driver within ZMK. |
Previously, we were using the semaphore before initialising it; this is now fixed.
a8f6d96
to
d12a41d
Compare
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.
Looks good to me. Thanks!
Adds a driver for MAX17048 I2C fuel gauge. Works on real hardware.