zmk
zmk copied to clipboard
feat(drivers): add driver for MAX17048 fuel gauge
Adds a driver for MAX17048 I2C fuel gauge. Works on real hardware.
I'll incorporate the changes noted in the review for #1295 in the near future
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 zephyr/
as part of their path) and then tried to line by line add stuff from the latest driver to the older driver (that worked on my hardware) until I narrowed the issues down - see third commit in the linked repo.
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 set_rcomp_value()
and set_sleep_enabled()
.
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.
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.
Compiles and works fine for me, tested on 2 different PCBs. I'll keep an eye open for glitches and will report back, but seems to be working well!
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.