Romey-Rome
Posts: 13
Joined: Sun Mar 22, 2015 10:34 am

bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 10:56 am

Hello.

I need to send my device a reset frame - Pull CS low for 2 clock cycles, release, and wait 6 cycles.

In bus pirate I would do

Code: Select all

[&&]&&&&&&[<cmd> <data>]
Trying to move to C...

How can I accomplish this? All the functions seem to want to control CS for you.

Thanks!

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 11:10 am

Change the gpio mode from ALT0 to OUTPUT. Set it low then high. Set the gpio mode back to ALT0.

It may be difficult to get exact timing but it may reset the device.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 11:20 am

The above advice is correct, but not advised. Almost everyone will tell you to resist making your own CS. The reason is the precise timing. If you allow the system | libraries handle the clock line things will work much better because the timing is closer to the hardware and the interrupts, etc. ... just sayin... words to the wise.
marcus
:ugeek:

Romey-Rome
Posts: 13
Joined: Sun Mar 22, 2015 10:34 am

Re: bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 10:49 pm

Thanks guys.
I don't intend to manually CS for data. Just the reset. Also, the 2 & 6 are minumums, so if it's longer, it's OK.

User avatar
mikronauts
Posts: 2732
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 10:56 pm

Try sending a single null byte using the spi device driver.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: bcm2835 lib + SPI + manual CS

Sat Apr 25, 2015 10:59 pm

Romey-Rome wrote:Thanks guys.
I don't intend to manually CS for data. Just the reset. Also, the 2 & 6 are minumums, so if it's longer, it's OK.
I've not had problems setting the slave select lines outside the control of the SPI hardware. Given that the SPI hardware won't do what you want you don't seem to have a choice anyway.

Return to “C/C++”