Skip to content

SPIDecoder: Add CPHA and LSB/MSB option - #1105

Open
dj-bauer wants to merge 2 commits into
ngscopeclient:masterfrom
dj-bauer:master
Open

SPIDecoder: Add CPHA and LSB/MSB option#1105
dj-bauer wants to merge 2 commits into
ngscopeclient:masterfrom
dj-bauer:master

Conversation

@dj-bauer

@dj-bauer dj-bauer commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Implement 2 TODOs for the SPIDecoder.

  • Different CPHA/CPOL modes
  • selectable msb/lsb first direction
20260809_17h52m21s_grim

This commit moved the sampling of a specific bit into a separate helper function sampleBit(...) as it's now called twice depending on the value of CPHA.
As the state machine already tracks of falling and rising edges it was just necessary to sample depending on CPHA.

The MSB/LSB implementation was rather trivial as it expands on the existing byte modification.

if(endian == 0) { // LSB
    if(cur_data)
        current_byte = (1 << bitcount) | current_byte;
} else { // MSB
    if(cur_data)
        current_byte = 1 | (current_byte << 1);
    else
        current_byte = (current_byte << 1);
}

@dj-bauer

dj-bauer commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

As mentioned in #172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant