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

SPI on PI

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);

  spiwrite(c);

  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
DougieLawson
Posts: 35791
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: SPI on PI

Wed Nov 20, 2013 1:07 pm

There's a good python sample in the Quick2Wire stuff at https://github.com/quick2wire/quick2wire-python-api
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “C/C++”