SPI-CONFIG(1)

πŸ“¦
version 1.0.2 Β· 3 versions
, in alpine 3.24, fedora 43, fedora 44, nixos 26.05, opensuse-leap 16.0

πŸ’… SPI-CONFIG β€” ok bestie, let's talk SPI

so this is the spi-config page from the SPI-tools manual, section 1 (User Commands), and honestly? she's a baddie. let's get into it 🫢


✨ NAME ✨

spi-config β€” set or query SPI configuration. that's it, that's the job. set it or query it, no cap. πŸ’–


🌸 SYNOPSIS 🌸

spi-config options...

just options, one after another. no positional args, she's a flags-only kind of girlie. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. spi-config sets or queries the configuration of a SPI port. that's the whole vibe.

then it hands you the entire menu of flags, and here they all are, every single one, don't skip:

  • -d, --device=DEVICE β€” use the given Linux spidev character device. like, this is the device you're talking to. point her at the right one. πŸ“
  • -q, --query β€” print the current configuration. a lil peek at what's going on rn. πŸ”
  • -m, --mode=[0-3] β€” set the spi mode. modes live down below in SPI MODES, iykyk. 🎚️
  • -l, --lsb={0,1} β€” set LSB first (1) or MSB first (0). bit order, pick a lane. πŸ”€
  • -b, --bits=[7...] β€” set the number of bits per word. seven or more, she said what she said. πŸ”’
  • -s, --speed=FREQUENCY β€” set clock frequency, and it's in Hz. so yes, 1000000 means 1 MHz. do the math bestie. ⚑
  • -r, --spirdy={0,1} β€” set the SPI READY mode flag. 🏁
  • -s, --wait β€” block, keeping the file descriptor open. see WAIT OPTION below, it matters fr fr. βœ‹
  • -h, --help β€” display the help screen and exit. the classic. πŸ†˜
  • -v, --version β€” display the version number and exit. 🏷️
ok so not me noticing that -s shows up twice in this list, once for --speed and once for --wait, and that WAIT OPTION below talks about a -w option. i'm literally just reading you what's on the page, bestie. i don't make the rules, i just serve them. πŸ’€

πŸ”₯ SPI MODES πŸ”₯

four modes, and the only thing that changes is the idle level and which edge she samples on. clock behavior tea:

  • mode 0 β€” low iddle level, sample on leading edge.
  • mode 1 β€” low iddle level, sample on trailing edge.
  • mode 2 β€” high iddle level, sample on leading edge.
  • mode 3 β€” high iddle level, sample on trailing edge.

see the pattern? leading/trailing alternates inside each pair, low/high flips between the pairs. slay. πŸ’…


🧚 WAIT OPTION 🧚

here's the tea, and it's a lil spicy: on some platforms, the speed is reset to a default value when the file descriptor is closed. 😭

to avoid that, one can use the -w option β€” it keeps the file descriptor open. see also the last example below. 🫢


🌈 EXAMPLES 🌈

get help:

$ spi-config -h

query current configuration:

$ spi-config --device=/dev/spidev0.0 -q

change clock frequency to 1 MHz:

$ spi-config --device=/dev/spidev0.0 --speed=1000000

set a configuration and keep the device open:

$ spi-config --wait --speed=1000000 & PID=$!

close device previously open:

$ kill $PID

see how the last two go together? open her, keep her open, then kill her when you're done. main character lifecycle fr. πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

written by Christophe BLAESS <https://www.blaess.fr/christophe>. thank you for your service, legend. 🫑


πŸ’€ REPORTING BUGS πŸ’€

github home page: <https://github.com/cpb-/spi-tools.git>

found a bug? take it to the repo, bestie, don't suffer in silence. πŸ›


copyright Β© 2014 Christophe Blaess.

licensed under GPLv2 <http://gnu.org/licenses/gpl.html>.

this is free software: you are free to change and redistribute it.

there is NO WARRANTY, to the extent permitted by law. no cap, no promises, no take-backs. πŸ™ˆ

and that's the whole page, you ate it. πŸ’…βœ¨ this was SPI-tools, August 2014, SPI-CONFIG(1) β€” mwah, go configure something cute. πŸŽ€πŸ¦‹