SPI on Raspberry B+

Bernd Walter ticso at cicely7.cicely.de
Wed Aug 3 03:49:13 UTC 2016


On Wed, Aug 03, 2016 at 05:28:30AM +0200, Bernd Walter wrote:
> I'm currently writing a kernel driver for APA102 LEDs on 11-BETA3.
> With some help of older threads on this list I've managed to
> get my driver attached and sending data.
> However, what I didn't manged yet is setting the SPI parameters.
> 
> The SPI mode seems to match fine.
> 
> The byte order is unfortunately wrong.
> I need MSB first and the driver is sending LSB first.
> Of course I could rotate all the bits, but would like to avoid it
> for performance reasons.
> 
> The clock is only 500kHz according to scope.
> I've heared that there is no device specific speed support, but since I'm
> not using any other SPI device setting the global speed would be fine.

I've found out about sysctl dev.spi.0.clock.
That works fine.

> I'm calling SPIBUS_TRANSFER with multiple bytes.
> There is a gap of 2 microseconds between the bytes.
> Don't know if it just skipping a full clock cycle and the gap will
> be shorter with a higher clockrate, or if the driver really needs
> 2 full microseconds between each bytes.
> I somehow believe (and hope) it is just a full cycle in the controller.

It also remains at one clock cycle gap, so with higher speed the
gap will be shorter as well.

Unfortunately there is no byteorder sysctl.

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.


More information about the freebsd-arm mailing list