User avatar
Posts: 21
Joined: Mon Jun 03, 2013 12:55 am


Wed Nov 20, 2013 2:45 am

I've been trying to use spidev and SPI communication with my PI. I looked at the Arduino code and it looks like this:

Code: Select all

void Adafruit_ILI9340::writecommand(uint8_t c) {
  CLEAR_BIT(dcport, dcpinmask);
  //digitalWrite(_dc, LOW);
  CLEAR_BIT(clkport, clkpinmask);
  //digitalWrite(_sclk, LOW);
  CLEAR_BIT(csport, cspinmask);
  //digitalWrite(_cs, LOW);


  SET_BIT(csport, cspinmask);
  //digitalWrite(_cs, HIGH);
My question is does spidev handle the "CLEAR_BIT" and "SET_BIT" or do I need to manually do that myself? I've tried both ways and no luck. Arduino code works fine, but I wanted to write a userspace program that could communicate with my device (TFT display with ILI9340C).

I don't get errors sending, but device doesn't do anything I expected (tried a simple command to turn off the display).

Does anyone have a SPI userspace program they can share as an example?

User avatar
Posts: 42294
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: SPI on PI

Wed Nov 20, 2013 1:07 pm

There's a good python sample in the Quick2Wire stuff at
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Return to “C/C++”