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(...)
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?