RadioHead/SPI driver for LORA Radio

98 views
Skip to first unread message

Dave Hojo

unread,
Apr 8, 2020, 6:27:33 PM4/8/20
to BeagleBoard
I am staring down a rabbit hole and wondering if it's going to be worth it.  I have a Dragino LORA/GPS hat. The LORA bit is SPI. There is a nice library (a fork of RadioHead) where I can just implement an SPI driver, but it's a few notches above my pay grade.  I successfully took some bbb SPI code and the spi_scan that comes with the RadioHead library to query a register and get a version off the device. That's a far cry from cutting into the code and making a new hardware driver for the BBB.  

What I'm most interested in are the ways I can access the SPI devices. I notice for the raspberry pi driver they're using a hardware library with function calls like this:
bcm2835_spi_setDataMode(mode);

For my test I used /dev/spidev0.0 with the ioctl and SPI_IOC_MESSAGE. Will I have to write ioctl functions like these or is there a hardware library I can leverage:
fd = open(SPI_PATH, O_RDWR);
ioctl(fd, SPI_IOC_WR_MODE, &mode);
...

I am up for a challenge but I do not want to try and replicate library functions if they exist. I looked at the Adafruit-beaglebone-io-python lib as it has SPI functions (and I might just try to use that) but it seems they, too, are using ioctl.

Shabaz Yousaf

unread,
Apr 9, 2020, 8:28:35 AM4/9/20
to BeagleBoard
Hi Dave,

As a possible option, see here for a combined GPIO, I2C and SPI library:

This library does not use ioctl, it uses direct register calls internally, so it is fast.
In a nutshell it exposes a function called spi_transact. You call it passing in the byte to transmit and the pointer to a byte for the received value, and it performs the SPI interaction.
It can be used in a loop to perform multiple byte tx or rx transfers.
It's very basic, it is up to the user to store the bytes into an array or handle any conversions.

As for support for the library.. I can't support the code much, I have other work too, but if it is a quick question I can try to answer it. It's not mega-complicated, but some C knowledge, maybe even a 'scope or logic analyzer may be needed to use and troubleshoot (not saying there will be issues to require this, but just want to pre-empt it).

Another thing is that working with radio devices can (sometimes) be non-trivial. The reason is, some radio events may occur asynchronously. Code may need to be multi-threaded to handle this. It's sometimes not as easy as 'fire-and-forget' so the code needs to implement a state machine to bring up a radio module, transmit, wait for a response, maybe retransmit upon some timer expiry, and so on. I don't know if the LoRa chip or module does that automatically or if the user is expected to implement such things in software.




From: beagl...@googlegroups.com <beagl...@googlegroups.com> on behalf of Dave Hojo <dhaj...@gmail.com>
Sent: 08 April 2020 23:27
To: BeagleBoard <beagl...@googlegroups.com>
Subject: [beagleboard] RadioHead/SPI driver for LORA Radio
 
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/d71c0ebc-a5b0-41cb-bd60-a26df4d3dfea%40googlegroups.com.

jonnymo

unread,
Apr 9, 2020, 10:42:23 AM4/9/20
to Beagle Board
Note, the code that shbaz has been pushing has not been touched for 6 years or so and has issues unresolved since 2014 so who knows what kernel it was used for.  
Thus, use it at your own peril.

Here is the link to save having to look through the Element14 page for it.


Jon 

Dave Hajoglou

unread,
Apr 9, 2020, 11:55:11 AM4/9/20
to beagl...@googlegroups.com
Thanks both of you.  This gives me something to go on at least.  I'm thinking if I can get something workable I can get it over to the RadioHead maintainer and maybe they can clean it up if they've been getting any queries.

You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/-jeR8pBmDMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAG99bkoPLGvm3zXq3GXC1hUoKd__6ufe5RbyX3haoLirE2NfHA%40mail.gmail.com.

Shabaz Yousaf

unread,
Apr 9, 2020, 5:02:55 PM4/9/20
to beagl...@googlegroups.com
Nonsense.
If you checked the date, you'll see I updated it in October.
I don't really care if you use it or not.



From: beagl...@googlegroups.com <beagl...@googlegroups.com> on behalf of Dave Hajoglou <dhaj...@gmail.com>
Sent: 09 April 2020 16:54
To: beagl...@googlegroups.com <beagl...@googlegroups.com>
Subject: Re: [beagleboard] RadioHead/SPI driver for LORA Radio
 

Shabaz Yousaf

unread,
Apr 9, 2020, 5:05:44 PM4/9/20
to beagl...@googlegroups.com
Hi Dave,

That's great, looking forward to your results. I've LoRa board (Semtech chipset) that I've been trying to construct for a while, but have no code written for currently.



Subject: Re: [beagleboard] RadioHead/SPI driver for LORA Radio
 
Reply all
Reply to author
Forward
0 new messages