Iβd like to help develop this further, if I understand things correctly.
The SPI connection between the imx and the lpc is working, we just need to add an interface for requesting and transmitting data?
I see that there is a uart connection from the imx and lpc as well, that is currently setup to transmit only due to keyboard resume issues?
// board_reform.c
// only send to reform, don't receive from it
/* Set 0.13 UART TXD */
LPC_IOCON->PIO1_13 &= ~0x07;
Digging into the keyboard firmware, I see that we can send usb commands to enable/disable the uart connection of lpc to the imx. With the imx being receive only uart from the lpc.
example path for enabling lpc reporting to imx:
imx β usb(βUAR1β) β kb β uart(β1uβ) β lpc
Seems like the automatic reporting is no longer a feature? I donβt see any uartSends in the lpc main loop. A periodic command from the imx to the kb to the lpc would be required to poll the battery condition to the uart with the current firmware, unless Iβm missing where the kb is triggering this periodic send.
imx β usb(βRPRTβ) β kb β uart(β0cβ) β lpc β uart(battery_state) β imu/kb
SPI battery reporting would be great, it is absolutely a short/mid term goal for us. Alternatively we could also use USB battery reporting features in the keyboard.
After learning a lot about device tree and kernel builds I have a patch that enable the usermode spi driver for mnt debian kernel package.
As well as a minimal change to the lpc firmware that fills the spi transmit buffer with basic battery stats.
And a quick python program (that should be rewritten and made a kernel driver instead) that reads the battery information from the spi device.
Once my account is approved in gitlab I can put a PR out for the kernel and fw changes while I work on a driver.
A more advanced design that implements a command and poll structure is ideal, but that requires adding spi interrupt handlers to the lpc since the spi buffer is only 8 bytes. This design fits the battery info in the 8 bytes making it trivial for the lpc to fill the byte buffer with the stats at its existing poll rate.