ChibiOS/QMK backlight for Infinity60 - reading hardware register

lunas

02 May 2017, 21:27

I posted this question over on GH, but thought I'd try here as well. I'm on the last stages of porting over matt3o's and flabbergast's whitefox TMK led code to QMK for the infinity60. Since both boards use the same led controller I've just reused and expanded the work matt3o did. However, I've run into an issue with reading from a hardware register.

What I'm trying to do is set the Capslock led (or any led) to blink if all leds are already on (full backlight). This involves reading a byte from the blink register on the controller and toggling a bit for the led. I'm using a mailbox to queue actions and most of the time the code works fine, but eventually it starts reading the blink register byte incorrectly when all the keys are lit and returns 0xFF/1F/EF etc. when it should be 0x00. My guess is that it has to do with the controller not keeping up with requests and sending a byte from another register.

The main functions involved
Code:

Code: Select all

led_set --> is31_read_register(page, byte address, buffer) --> i2cMasterTransmitTimeout(...)
i2cMasterTransmitTimeout reads the byte from the hardware register.

I've tried sleeping (chThdSleepMilliseconds) as well as a blind attempt at locking the mailbox thread (chSysUnconditionalLock). This is my first go at C and ChibiOS so not sure where to look next.

Anyone know what may be causing inconsistent reads from the controller and a way to avoid them using ChibiOS's mailbox if requests are maybe coming quickly from the keyboard?

Post Reply

Return to “Workshop”