WiringX SPI settings

I’ve written a program that does SPI with WiringX. Bitbang just isn’t quick enough. But I need to set it so WiringX sends LSB first. The docs don’t mention it anywhere, and I’ve googled hard - and found nothing. Should be settings for clock polarity & phase, msb or lsb first, CS active high or low. There’s no mention of any of this.

I would also like it to do CS active high. But it only does active low, so I have a 2N2222 transistor inverting the CS line so the display is happy. But then it wants LSB first, so I’m still stuck.

Am I going to have to reverse every byte I send to make this work? That’s dumb. Maybe the settings are there and it’s just really terrible docs.

Does this help ?


1 Like

Nope. I tried it. Errors out in compilation.

Looked through ioctl.h. Nothing there that helps.

I think I’ll try reversing all bytes. If I do it with a lookup table it won’t hurt my speed very much.

Ok… Reversing bytes did work, but once again, WiringX is not flexible enough to do it without screwing around.

I had it set up to have WiringX handle the CS line through my little transistor inverter circuit. That works, and gets the speeds, but the display wants CS to go high - then send write command - then send the framebuffer - and then CS to go low at the end. WiringX instead raises and lowers CS for each send (actually it lowers and raises it - and I invert that). The display ignores that and displays nothing.

I removed the hardware controlled CS and my inverter and went back to controlling CS myself on a GPIO pin. I lose a tiny bit of speed, but it’s not noticeable. I then cranked the WiringX SPI speed way up and the display now runs great. Nice and quick.

I pushed WiringX SPI up to 8000000 speed. That gets me 125 nS clock cycles. At 9000000 it starts to go wrong - I can see that the clock is stuttering - the clock cycles become unstable and aren’t steady anymore (or is it my logic analyzer? I don’t know). But 125 nS drives the display very fast. I’m totally happy with that.

IIRC, this video was shot at 6000000 SPI speed.