YukiWorkshop / SPPI

C++ wrapper of Linux's SPI userspace driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SPPI

C++ wrapper of Linux's SPI userspace driver

Features

  • Easy to use
  • Customizable chip selector, so you're not limited to the number of CS lines
  • Built-in access lock, enables multiple process accessing one SPI controller

Usage

using namespace YukiWorkshop;

Standard usage:

SPPI s("/dev/spidev0.1");

uint8_t tx[16];
uint8_t rx[16];

s.transfer(tx, rx);

uint8_t data = s.transfer(0x00);

Custom chip selector:

// The number after "." is irrelevant, just ensure it begins with spidev0 in this case
// This MAY conflict with SPI devices that are used by kernel 
SPPI s("/dev/spidev0.1", [&](bool cs_enable){
        if (cs_enable) {
                // Custom logic to select chip
        } else {
                // Custom logic to deselect chip
        }
});

For more usages, read the code.

License

MIT

About

C++ wrapper of Linux's SPI userspace driver

License:MIT License


Languages

Language:C++ 98.2%Language:CMake 1.8%