Refactor SHIFTREGISTER management for multiple instances#2112
Open
D-Fed11 wants to merge 4 commits into
Open
Conversation
The #define directive on line 276 of src/obk_config.h was missing the # prefix, causing preprocessor errors and cascading compilation failures. Added the missing # to correctly enable the ShiftRegister driver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support Multiple Independent Shift Register Instances
Motivation
This change was driven by a real-world device that uses 2 separate 74HC595 shift register chips connected to different GPIO pins on the BK7231N. The previous implementation only supported a single shift register instance, causing the second chip to be ignored when
startDriver ShiftRegisterwas called a second time.Changes
Modified the shift register driver to support up to 4 independent shift register instances, each with separate GPIO pins and channel mappings.
Files Modified
src/driver/drv_shiftRegister.c
g_shiftRegs[MAX_SHIFT_REGISTERS])Shift_Init()to automatically find the next available slot instead of overwriting global stateShift_OnChannelChanged()to iterate through all active instances and route channel changes to the correct chipsrc/driver/drv_main.c
DRV_StartDriver()to allow ShiftRegister to be re-initialized multiple timesstartDriver ShiftRegistercalls create new instances instead of being rejectedUsage Example
// First 74HC595 chip (pins 2, 3, 4, channels 10-17)
startDriver ShiftRegister 2 3 4 10 1 1 0
// Second 74HC595 chip (pins 19, 20, 21, channels 18-25)
startDriver ShiftRegister 19 20 21 18 1 1 0