Serial Peripheral Interface?

Oleksandr Tymoshenko gonzo at bluezbox.com
Wed Jan 18 01:08:04 UTC 2017


George Mitchell (george+freebsd at m5p.com) wrote:
> The Raspberry Pi (among others) has two IIC interfaces on the GPIO
> connector, and there are /dev/iic0 and /dev/iic1 visible to userland.
> It also has two SPI interfaces, but despite the presence of "device
> spibus" and "device bcm2835_spi" in the RPI-B configuration file, I
> have been unable to detect any userland interface to the serial
> peripheral interface lines (except the dev.spibus and dev.spi sysctl
> entries).  Is it possible to use the SPI interfaces somehow from
> userland?

There is somewhat cumbersome spigen interface. It's not available as a
module (yet), only as kernel cimpile-time option. You'll have to add
"device spigen" to kernel config and rebuild the kernel. Also there are
some limitations. You can't specify mode or CS number from userland,
CS 0 and mode 0 is assumed. 

You can find usage example here:
https://github.com/gonzoua/freebsd-embedded-demos/blob/master/libssd1306/ssd1306_spi.c

There are plans to replace spigen with better API but I am not aware
about the actual timeline for this.

-- 
gonzo


More information about the freebsd-arm mailing list