travistrue2008
Posts: 18
Joined: Thu Oct 05, 2017 6:09 pm
Location: Las Vegas
Contact: Website Facebook

Software vs Hardware SPI

Thu Jan 25, 2018 10:13 pm

I'm writing a device driver based off of the GPIO gamecon driver code. It uses direct registers to interface with the GPIO, and implements SPI in software. I'm going this route because I won't have physical access to all of the pins I need on the board due to the cramped enclosure the Pi has to go into. Will there be a serious performance loss with a software implementation of SPI?
Sic parvis magna.

chaosjug
Posts: 18
Joined: Wed Nov 05, 2014 8:24 pm

Re: Software vs Hardware SPI

Tue Jan 30, 2018 7:27 pm

This really depends on your application. How fast your SPI device is and how much data you want to transfer.
There are two things to consider: Hardware SPI can use higher frequencies (if your SPI device is fast enough) and at least SPI0 can use DMA so you can transfer large amounts of data without the CPU. And second, even if the software SPI is as fast as your device, this can lead to a high CPU load, especially if you use a PI with only one core.
Btw. you are aware that there is a software SPI driver in the linux kernel, so you don't need to implement that yourself?

travistrue2008
Posts: 18
Joined: Thu Oct 05, 2017 6:09 pm
Location: Las Vegas
Contact: Website Facebook

Re: Software vs Hardware SPI

Wed Jan 31, 2018 8:18 pm

That's good to know. I only need to read 13 bits of data 100 times a second. I wasn't aware of the SPI driver in the Linux kernel, but I did know about the GPIO driver. I was going off of the gamecon source code, which works off of direct register access to the GPIO.
Sic parvis magna.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 4 guests